LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the 6023E in LV 7.1, how can I get timing between two events to microsecond precision?

I am a student and I have only been using LV for a few weeks so cut me some slack. I know similar questions have been on the forum 10 times but I am still having problems. I am sending a signal to a PIC microcontroller that controls the signal generation of a 40KHz acoustic ranging circuit. The output of the hardware goes high when an echo is detected. I need LV to start/restart a clock every time a signal is sent to the microcontroller and stop the clock when an echo is detected. It will use the time to computer the range. I am using the 6023E board and LV 7.1 and I know everything on my hardware is working correctly. I have a digital output going to the microcontroller and an analog input with a VI for detecting a voltage threshold listening for when an echo is received. I have looked through some other forum questions and examples and have come up with three different approaches. Originally I was trying to use the ms tick count VI but I've already read up on why that deos not work.

The first VI posted below (ALIS2wavd) uses a timed loop. I can't seem to get the timed loop to run correctly with a 1 MHz clock. I am currently trying to use the DAQMx Create Timing Source.vi. Basically, the timed loop should run at 1 MHz and I would use the loop count to see how many times it runs before a signal is received. I also use the loop count to control how long I send the signal to the microcontroller, and how long to wait for an echo before starting over. In all of my VI's, the goal is to send a signal to the microcontroller for about .1ms and listen for an echo for 1-2ms.

The second VI posted uses a VI for timing that I found on devzone. The timing VI that I found is also below. This really looks like a mess right now, sorry. You may want to look at the timing VI first. It uses counters to get a pre and post count and subtract to find the total time elapsed. I have the DAQmx read.vi's in the loop so that it will be subtracting the time of the first pulse from the time of the echo each iteration. At its closest point to working, this VI would return the same number for the range every time, meaning it was counting the same amount of time each iteration. I know the timing VI works accurately so I am guessing that there is a problem with my structure or the way I am using the DAQmx functions.

In the last VI I am trying to use a counter to do something similar to what the timed loop VI should have been doing. I am setting up an egde count and controlling the transmit and detect time with this count. The value of the count when an echo is detected would be used to determine the elapsed time. Im not sure why this isn't working either.

NOTE In all of these VIs there is an enable button and a PIC microcontroller frequency test. The VIs won't step into the case structure without both of these as true so you might want to get rid of them if you want to try to test anything. In trying to fix these VIs I may have made little changes that actually made the situation worse so keep that in mind too. Originally I was using just DAQ Assistant VIs to do the input and output but I switched the the DAQmx functions in the loops because I thought the assistant VIs might be causing the problem. Also, I noticed that there is a count events or time.vi on the traditional counter palette. I can't use the traditional functions at the same time as the DAQmx functions so I was wondering if there is an equivalent time counter VI for DAQmx that I just do not have?
0 Kudos
Message 1 of 8
(3,540 Views)
It sounds like you will need to be using the real time(RT) hardware for that kind of precision.
0 Kudos
Message 5 of 8
(3,516 Views)
I would think the onboard 20Mhz timebase would be able to handle it. If I can't get it to work then I will have to try counting with my microcontroller, but I would rather do it with LV. I thought I read about other people on the forum getting similar precision using the 20Mhz clock, so thats why I think Im just making a stupid mistake in my code. Do you think this is impossible without LV realtime?
0 Kudos
Message 6 of 8
(3,512 Views)
Have you got the option set at this note??

http://zone.ni.com/devzone/conceptd.nsf/webmain/28A6979ECA9A0CAF862569050053D92D
0 Kudos
Message 7 of 8
(3,503 Views)
I am running XP pro with LV 7.1 so im not sure that the information on that site still applies. It says the problem was for LV 5.1 and earlier. I will check that out anyway.
0 Kudos
Message 8 of 8
(3,489 Views)