From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

5 V TTL-Trigger for audio-output

Solved!
Go to solution

Hello everyone,

 

as the title says, I would like to use a 5 V TTL-Trigger to start the output of an acoustic signal. The 5 V TTL-Trigger is generated by a camera after capturing a frame and send to an USB-Port.

I would like LabView to recognize each of these pulses, wait e.g. until 5 pulses have been sent to the computer and then start a short acoustic pulse (which I have already written).

 

Is this possible in principle? Do I need any additional hardware like a DAQ-card? Is there a way for LabView to recognize that pulse without connecting a separate measuring device?

 

 

Thanks in advance,

 

MrKSE

0 Kudos
Message 1 of 12
(4,812 Views)

Try looking at the USB example:  Help->Find examples. You'll be using VISA to talk to the USB port.

0 Kudos
Message 2 of 12
(4,795 Views)

If you are trying to capture TTL pulses, then you need something that can measure the TTL level.  A simple DAQ card with a counter should do just fine for your situation.  From what I can tell, the USB-6501 should do the job for you.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 12
(4,784 Views)

So there is no option via the VISA communication VIs to recognize this pulse like natasftw implied?

 

But thanks for your recommendation. So I either have to acquire such a card or to ask the microscope company to change the output signal e.g. to a ASCII-code..

 

0 Kudos
Message 4 of 12
(4,748 Views)
How is your USB connection enumerated in Windows device manager? Was there a driver from the vendor that you installed for it?
0 Kudos
Message 5 of 12
(4,662 Views)

Up to now, I cannot tell you,sorry.

 

The microscope company is still working on the 5 V TTL-output at the moment. But I will ask if there will be a special driver.

Would it make a difference? And can you tell me please: The above mentioned USB-DAQ-card ist connected via USB to the PC and not to the device which voltage is to be measured, or am I wrong? So for the case that the microscope company succeeds at outputting 5 V TTL pulses via an USB-cable, I have to cut this USB-cable to connect it to the DAQ-card?

 

Kind regards

0 Kudos
Message 6 of 12
(4,510 Views)

So now I got the program from the supplier and some information:

 

After a user-specified number of frames, the logical state of a serial port is changed for a user-specified time. Accordingly, the "pulses" are as long as the user wants to and have a value of 12 V. This pulse is then converted by a RS-232 to USB converter. The driver for the converter is a VCP driver from FTDI (http://www.ftdichip.com/Drivers/VCP.htm).

Fortunately, the program now also writes a "1" to the serial port.

 

Would it be possible to recognize this trigger at the USB port (maybe because the state of the USB-port is changed during this time?)

 

The other possibility would be to use the "1", which is sent immediately before the logic state of the serial port is changed. Will this number remain in the buffer during the pulse?

My idea was to simply create a while-loop, constantly requesting the bytes at the serial port until a byte arrives (see an example attached).

Is this a good idea or is it maybe slow?

 

Thanks in advance

0 Kudos
Message 7 of 12
(4,376 Views)
I don't understand your description. A serial port does not have a logic state. If it's a com port like you said, the only thing you can read is this '1'. You need to distinguish the format of this. A single byte with a value of 0x01 or the ASCII character '1'.
0 Kudos
Message 8 of 12
(4,358 Views)

First of all, I apaologize for my lack of knowledge concerning serial ports.

 

After I have done some "research", I assume to understand how it is done, now.

 

The microscope-pc is connected via USB to a USB-to-serial adapter with 8 ports. That adapter is connected via a null-modem cable with another USB-to-serial adapter, which is connected via USB to another PC.

 

When the imaging program has imaged a specified number of frames, the RTS-Pin of one of the serial ports on the adapter is set to state "0", which corresponds to a voltage of +12 V at this pin. After the trigger-length, the RTS-Pin is set to  "1" or -12 V. It writes a "1" to the port. This is what I understand from the python excerpt below:

 

global frame_counter

frame_counter = frame_counter +1

if frame_counter == triger_pos:

 

ser.write('1')

print "write 1"

 

print  "set rts to 0"

ser.setRTS(0)

 

time.sleep(trigger_nelgth)

 

print "set rts to 1"

ser.setRTS(1)

 

frame_counter = 0

 

Just for interest, did I understand this right? So I suppose that, as you said, I only can use the "1" which is written.

Indeed, I can read 1 byte from the buffer, but I am a little bit confused by the format. The output of VISA read is a string, which contains a 1. If I choose the hexadecimal display, there is a 31, which does not correspond to the ASCII 1 and would be 0001111 in binary. What does this mean?

 

 

0 Kudos
Message 9 of 12
(4,340 Views)
Solution
Accepted by topic author MrKSE
You do have the ability to read the rts line with a VISA property node.
0 Kudos
Message 10 of 12
(4,326 Views)