Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to get consistant digital output timing

Hi,
 
I am trying to use Labview 8.0 software and a NI USB-6251 board to fire 4 solenoids.  The solenoids need to be fired either all at once (0mS between each solenoid) or at some specified delay interval between each solenoid.  The delay intervals start at 5mS delay between each solenoid and increase from there in 5mS increments.  Therefore a 5mS delayed solenoid firing would consist of the 1st solenoid firing at 0mS, the second solenoid firing at 5mS, the thrid solenoid firing at 10ms and the 4th solenoid firing at 15mS. 
 
To accomplish this I used a timed loop structure and 4 timed sequence structures (see attached VI).  I used the t0 pin of each sequence to specify what the delay times should be between each solenoid firing.  The problem I am having is that at low delay times between solenoids the timing becomes quite inaccurate as veiwed by a scope (mainly at 0mS, 5mS, 10mS and 15 mS delays.)  An example is that if I request a delay of 5mS the solenoids may fire erratically with a delay around 10-15ms.  I have looked at the expected loop start and actual loop start terminal of the timed structure and they appear to start on the correct tick number (ie a 5mS delay gives a 0, 5, 10, and 15 for actual start times for each timed sequence.)
 
How can I make the timing correct?
 
Thanks
Dan 
 
 
0 Kudos
Message 1 of 3
(3,304 Views)
Dan,

Thanks for posting to the NI Forums.  To be able to ensure proper timing you will need to use hardware timing.  In other words you will need to use the onboard clocks of the USB-6251 to control the timing between firing solenoids rather than using timed loops.  The issue that you are experiencing is due to the fact that you cannot obtain absolute control over timing with Windows XP.  Windows decides when to provide resources to LabVIEW and may not provide LabVIEW with resources in a timely manner.  Obtaining this type of control in software generally requires a real-time operating system that provides deterministic behavior.  Luckily, the USB-6251 has the capability to achieve what you are looking for without switching to an RT operating system.  It will require using more of the features of the board but it is possible.  Let me provide a recommendation as to how this could be done:

1.  You will need program the USB-6251 to generate a clock to control timing.  This can be done with the onboard counters.  See the Gen Dig Pulse Train - Continuous example in the LabVIEW example finder (Help >> Find Examples, then Hardware Input and Output >> DAQmx >> Generating Digital Pulses) for how you could generate this clock.  The clocks rate should be set such that it matches the smallest increment in the delay (in your case 5 ms or 200 Hz)

2. Next you will set up a timed digital output task that will use the generated clock as a sample clock.  You will need to output on port 0, timed digital is only supported on this port on the USB-6251.  You will write to the task the samples required for each solenoid for the entire sequence.  You will then start the task.

Let me provide an example of what you would write to the channel:

Say for example you would like to fire the first solenoid then wait 5ms until the next solenoid fire and then wait 10 ms before the next one fires.  The entire sequence will then last 15 ms.  I set the clock to 5ms rate and choose rising edge for my sample clock.  I would write the following before starting the task:

Channel 1: 1   1   1   1
Channel 2: 0   1   1   1
Channel 3: 0   0   0   1

On the first rising clock edge channel 1 will be activated.  On the second rising edge 5ms later the second channel will be activated.  On the 4th rising edge the 3rd channel will be activated.

Hopefully I have been able to clearly explain my recommendation.  However, feel free to post back if you have additional questions about what I am suggesting.  Let me know how it goes.

Regards,

Neil S.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(3,292 Views)

Thanks Neil,

I will give that Idea a try.

Thanks again,

Dan

0 Kudos
Message 3 of 3
(3,282 Views)