LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering outgoing TTL pulse based on incoming position signal

Hello all,  

 

For my research study looking at reflex responses in human subjects, I have the subject's ankle attached to a motor that moves the joint back and forth through a 30 degree range. I am sending a 5-V TTL pulse from a NI BNC-2090A to a constant current stimulator (Digitimer DS7A) each time the ankle passes a specific angle. I want one pulse sent out each time the ankle passes the target angle. The VI works fairly well, but it does not fire at the exact target I set 100% of the time (sometimes off by a degree or so). We are sampling at 2000 Hz, reading 100 scans per channel with the DAQmx Read.vi. The median of the position signal is constantly being evaluated and sent to the In Range and Coerce function, the output of which is sent to a Case Structure. The min and max inputs to the In Range function are set at what I have found to be the ideal parameters (translates to roughly + or - 0.5 degrees). If I set them any narrower, the pulse is not always sent out. 

 

I've attached what I believe are the relevant parts of code. If anyone has any ideas of how I can make this vi run more smoothly and accurately, it would be much appreciated. Thanks in advance.  

 

0 Kudos
Message 1 of 8
(3,465 Views)

The VI you posted is reading from a spreadsheet rather than a DAQ device.  File I/O is expensive so if this is what you're doing you should cut it out and just read straight from the DAQ card as the data is being acquired.  It should help quite a bit.

 

Regardless, what you should really be doing is to generate the pulse entirely based on hardware triggering.  The 2090A is just the name of the terminal block, what is the model of the DAQ card it is connected to?  As an example, some DAQ hardware will allow you to configure an analog trigger and issue a hardware-timed counter output pulse whenever the voltage reaches a certain level.

 

 

Best Regards,

John Passiak
Message 2 of 8
(3,454 Views)

Thanks for the reply, John. The actual vi I'm running is reading from a DAQ device; sorry about the confusion. I just left the lab, so I'll have to get back to you about the DAQ card. Regardless, what you describe sounds like something I should try. Do you have any example code or links I can look at? 

 

 

0 Kudos
Message 3 of 8
(3,447 Views)

Well you would essentially combine this with this.  The trigger source for the counter task would be the analog comparison event (which I think might be considered an "advanced" terminal).

 

Only some NI DAQ cards support analog triggering though.  If yours doesn't you might consider just building a comparator yourself and using its output to trigger the counter output.

 

 

Best Regards,

John Passiak
Message 4 of 8
(3,440 Views)

Thanks! I will try this out tomorrow. But don't be surprised to hear from me again. 🙂

0 Kudos
Message 5 of 8
(3,428 Views)

John, we have a NI PCI-6229 DAQ. I don't know if that will allow me to do what you've suggested, as far as the analog triggering. I've attached the actual vi I've been trying to use so you can see what I've done (sorry about the messiness). It sends a pulse out every other time the position signal passes through the target angle (voltage). 

 

With the equipment I'm using, will I need to go with your second suggestion of building a comparator myself? I'm not sure how far off what I've done already is from what you are suggesting. I appreciate the help. 

 

0 Kudos
Message 6 of 8
(3,386 Views)

Triggering with the DAQ card:

 

The 6229 unfortunately doesn't support analog triggering.  Comparable cards which do are the 625x or 635x (also the more expensive 628x and 636x).  On such cards there is an Analog Window Triggering feature that would produce the exact signal I think you are looking for (see X Series user manual).  So if you have one of these handy or are looking to acquire new hardware then this would be a good solution.

 

 

Software detection for trigger signal:

 

If you want to continue using the 6229, see if something like the following would give what you want.  Keeping the loop simple might help make this approach usable for your application depending on how long the window is you are looking for.  It still isn't as reliable as a hardware-triggered approach.

 

AI_Feedback_test.png

 

 

External circuitry:

 

The simplest external comaprator circuit would just consist of an op-amp.  You could use the analog output to set the threshold.  The comparator output could trigger a counter output which would issue a pulse of some pre-defined width.  The issue here is that the output signal would not be high during your exact window, but rather a fixed amount of time starting at the beginning of your window (so if the speed is changing it might not be what you are looking for). 

 

You could in theory just build your own external circuit to generate the exact window trigger as well at which point you wouldn't need to output anything from the DAQ card (except for perhaps control voltages for this circuit).  If you're at a university perhaps you could look for a EE student that you might be able to contract the work out to?

 

 

Best Regards,

John Passiak
Message 7 of 8
(3,375 Views)

Thanks for all the help! I'll give this code a try. There is also an engineering student in the lab who is willing to help me out with the hardware solution in lieu of getting a better DAQ card. 

0 Kudos
Message 8 of 8
(3,348 Views)