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.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Run Vi using TTL input from external source

Hello, 

 

Thanks for replying. 

 

For point 1, how will I be able to solve this? I've been sending a 500Hz TTL to it and it seems to activate as soon as it reads the signal.

 

For the second point, I just need to set up the task outside the case structure and the start within the true case of the case structure? 

and sorry yes I did notice, I was trying some different things and forgot to delete the outer loop haha!

0 Kudos
Message 11 of 18
(612 Views)

For point 1) If it works in your current set-up and it is not mission-critical, then use it like it is. Otherwise a hardware trigger like discussed above would be the solution.

 

For point 2) I have an example on mind, but cannot find it. Maybe I have seen it in the Embedded Control and Monitoring course. This will do: 4. NI-DAQmx Trigger. The "Create a Trigger in LabVIEW" screenshot it is. After adapting it to your setup of course (e.g. from AI to DO etc.). Only the nodes from Start Task to Stop Task will be inside the loop.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 12 of 18
(602 Views)

Hi, 

 

I've been working on the VI. This image shows my final VI. The TTL input from the Arduino is displayed on the graph. At 1Hz, the graph becomes very slow to respond but I don't know the reason for this. 

 

I tried to use the "simulate signal" VI to output a square wave voltage from A0. On the oscilloscope, it shows that it is output the correct frequency etc but the LED doesn't seem to respond accurately. What could be the cause for this?

Thanks for your help!

Download All
0 Kudos
Message 13 of 18
(573 Views)

It is very hard to help you when there is only a screenshot of the VI and not the VI itself. Please consider attaching your full project the next time instead Smiley Happy

 

I noticed that inside your loop there are two things forced to happen in parallel although they are probably not meant to be: Your voltage reading task looks to be set to read infinite ("-1") samples (cannot check because it is just a png), and your PWM generator will start afterwards. Looks odd.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 14 of 18
(558 Views)

I apologise, I didn't have access to my files at the time of the reply, only a previous screenshot.

I have attached both vi's to this reply.

Download All
0 Kudos
Message 15 of 18
(555 Views)

Don't worry^^

 

Wait, what exactly are you trying to do? I don't get it fully from your code and have the feeling there are two things mixed: You are reading the analog signal to catch a trigger, and if so, you start your PWM output part. Intentionally, the execution will wait until the PWM output is done. During this time, the Analog Wfm Read won't happen and the TTL Signal chart not updated.

 

I attached a slighty cleaner VI that doesn't do the Channel Creating and Task Clearing every loop iteration but only outside of it once. It'll still update your PWM setting to the UI every loop iteration. No guarantee though, I don't have any hardware here to test.

 

If you want to have the graph updated at a steady rate anyways but still catch all triggers, this will lead to a more complicated  approach. Because then you need one loop to read the input and update the graph and one in parallel to execute the PWM out. These two loops need to talk to each other so the second loop gets notified when the first one sees triggers. Is this what you want? Depends on your application of course. Maybe you already mentioned if, but I was not sure reading through this thread again.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 16 of 18
(548 Views)

I cannot use the pause trigger property node therefore I am using a case structure to pause and start the pwm of the LED

 

The TTL signal arrives from the Arduino to an analogue input on the mydaq which starts or stops the case structure depending if it is true or false

 

I need the input from the Arduino which is shown on the graph to continuously catch a trigger and start and stop the led accordingly

0 Kudos
Message 17 of 18
(545 Views)

I'd implement this the following way:

  1. Have a loop that reads the TTL input repeatedly and decides if the PWM output needs to be started or stopped
  2. Create a Functional Global Variable to manage the PWM output. It needs at least these cases:
    1. Initialize
    2. Change Settings
    3. Start PWM
    4. Stop PWM
    5. Close
  3. Have an event structure that reacts on changed to the settings on the UI (in case you want to be able to change the Duty Cycle and Frequency during run time)

This way you uncouple the PWM output from your input loop. Here is some information on Functional Global Variables (FGV):


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 18 of 18
(538 Views)