Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

I am having trouble with timing my digital output using USB-6009.

Hello all,

 

I am using code that I found in the NI developer zone to send a digital pulse train to light up an LED (code attached below), and I am having trouble controling the "wait" functions properly. 

 

What I want the code to do is to pulse a digital high for 1ms then have a 9ms relaxation period.  In order to do this, I have a 0ms wait in the digital high part of the loop and an 8ms wait in the digital low part.   When I hook up the DAQ to an oscilliscope, I find that my signal is not consistant - the length of the digital high and low will change from pulse to pulse.  What is weird though is that if I have a 0ms wait in both the digital high and digital low part of the loop then the length of both the digital high and low are always exactly 1ms.

 

Does anyone have any insight into what may be the cause of the inconsistant timing when using the wait function but perfect timing if there is no wait function?

 

Thanks in advance!

 

ps - the code is written in LV 2009, if anyone needs it in an older version just let me know I can re-save and re-post it.

0 Kudos
Message 1 of 5
(3,719 Views)

Hartloper,

 

I believe this behaviour is becuase this is software timed application.  Also after looking at the Wait help file, it says that there is a plus or minus 1 ms margin of error for the function.  You did say that when you have no wait, then they are exactly one millisecond.  Could you write 1 high and then 9 lows?  This would essentially do the same thing but you wouldn't have to used the wait function.  Please let me know if this helps.

 

Regards,

 

Brian P.

Applications Engineer
National Instruments
Message 2 of 5
(3,693 Views)

Hey Brian,

 

Thanks for pointing out the +/-1ms in the help file, that could explain why it doesn't work...

 

I made a looping function to make it write 1 high (with no wait) and 9 lows (with no wait) but the output signal was identical to when there was just one high and one low with no wait function.

 

I'm really at a loss at what to do, looking into using an external trigger at the moment.

0 Kudos
Message 3 of 5
(3,690 Views)

Hartloper,

 

The 6009 only supports software timed pulses, if you need something tighter than that, you will need to get a card with both a counter gate and a counter source in order to generate hardware timed pulses.  When dealing with software, there are so many variables that you cannot control the pulses with a lot of accuracy, but if you used a hardware time card, such as an M-Series card, you will be able to generate pulses with a lot more accuracy.  I hope that helps.

 

Regards,

 

Brian P. 

Applications Engineer
National Instruments
Message 4 of 5
(3,683 Views)

Hey Brian,

 

Do you know how short the pulses can be (can you go shorter than 1ms)?  Also, is it more difficult to write a code to control the pulses when using a hardware time card?

 

Thanks,

 

 

Colin

0 Kudos
Message 5 of 5
(3,678 Views)