LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

start vi by a TTl-trigger

I get a 0-5 Volt TTl-signal from a signalgenerator (connected to parallel port) and want to use this signal as a trigger for a Vi, that sends out values to a power supply. So with every rising edge, I want to sent out a value, keep it for a certain period of time, return to a threshhold value and with the next rising edge again send again the first value! Communication to signal generator and power supply are already working. I just need help, how to bring the two applications together! Thanks a lot!
0 Kudos
Message 1 of 9
(3,215 Views)
Here is a solution but it requires more hardware. You can connect your TTL signal to a Digital Input module. The VI would have to continuously read the DI and fire an event when the input switches from low to high. (Or use a case structure instead of an event structure.) The event would contain code to control the power supply. Take care to fire the event only once, upon the input rising signal, not everytime the continuous loop reads the DI signal as being high.
Hope this helps.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 9
(3,215 Views)
Thanks so far! Can not get more hardware! I tried to write a case structure..but I still have this problem you mentioned above! Do you have any example code, with which you can provide me?
Thanks a lot!
0 Kudos
Message 3 of 9
(3,215 Views)
Sorry I don't have example code. I just moved into a new position and don't have LV installed yet on my new computer. I'll try to explain it to you. You should create an indicator (#1) to show the incoming TTL pulse state. Initialize it to false. Also create another indicator (#2) which will show the previous state. Initialize it to false. Then create a while loop. Inside the loop, first read your incoming TTL line. After reading the TTL signal, set the indicator #1 to the TTL state (true=hi, false=lo). Then create a case statement. The True condition should execute only if the previous state indicator (#2) is false and the current TTL indicator (#1) is true. After executing the case (regardless of which case was executed), set the #2
indicator to the same as #1 indicator. End of loop.
The loop starts with #1 and #2 both False, and nothing changes until the TTL signal goes hi. Then #1 goes True and with #2 still False, the True case executes (containing your special code). After that, #2 is set to True. The loop continues now with both #1 and #2 being True, and the True case does not execute anymore. When the TTL signal goes low, the #1 and #2 indicator will both become False. The cycle repeats again, waiting for TTL signal to go high. Use a stop button of whatever is necessary to exit the while loop.
Sorry I could not give an example at this time.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 9
(3,215 Views)
Hi tbob,

thank you very much for your answer! Till now, I couldn´t try your solution! But by the way just one question: what do you mean with initializing an indicator? Thank you so far! I will modify my VI the next days!
0 Kudos
Message 5 of 9
(3,215 Views)
Initializing means to define the state of the variable at the very beginning of the program. You can set the default condition of the indicators to False from the front panel (right click - Data Operations - Make Current Value Default, only if it is already false. If not, click on Change Value to True, then click Make Current Value Default). Or you can do this in the block diagram by wiring a False constant to the indicator at the very beginning of the block diagram. By doing it in the block diagram, the indicator will be initialized every time you re-run the vi. What I mean is that if you run the vi for the first time, and at the end of the vi, the last state of the indicator is True, then the next time you run it the indic
ator will still be True. By initializing, you guarantee that the indicator will always start off in the False state.
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 9
(3,215 Views)
thank you very much! I will try this modifications next week! Now I found a solution with shift registers..but I am not sure if it is a good solution!
Thanks!
0 Kudos
Message 7 of 9
(3,215 Views)
I finally got LV installed on my new computer. Here is an example of using a shift register to do what you need. You can replace the parts I marked with your special code and it should work fine.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 9
(3,215 Views)
Thanks a lot for the code! I was out of office the last three weeks! I think it will work now! Thank you!
0 Kudos
Message 9 of 9
(3,215 Views)