11-21-2013 10:39 PM
So anyways, the code attached in this file wirtten by someone else.
What this code does is, if detect port0/line1 digital input, wait 100ms, send digital output to port0/line2.
I want to edit the code so that it does the following
If detect digital input port0/line1 (sensor)
wait 100ms;
send digital output to port0/line2 (turn on red led)
wait 2000ms
send a reverse output to port0/line2 (turn off red led)
If detect digital input port0/line3 (sensor)
wait 100ms;
send digital output to port0/line4 (turn on green led)
wait 2000ms
send a reverse output to port0/line4 (turn off green led)
The code have to run continously.
11-22-2013
09:58 AM
- last edited on
12-19-2024
09:11 AM
by
Content Cleaner
Hey Hunkeelin,
We can certainly help you get this code working. What part are you having trouble with?
If you're new to LabVIEW check out the Self Paced LabVIEW training here: https://learn.ni.com/learn/article/labview-tutorial
-Sam K
LabVIEW Hacker
Join / Follow the LabVIEW Hacker Group on google+
11-22-2013 05:02 PM
Ok. I have no problem doing the first if loop, but I have trouble making the second if loop (LED blue).
11-25-2013 08:58 AM
You also seem to have a problem explaining your problem. You have no blue LED in your question. To control the green LED, you simply copy and paste existing code and change the line numbers and task names. From your description, you don't have any relationship between monitoring line 1 and line 3 so the copy/paste should work. You could also use a single tasks for reading and writing.
11-25-2013 12:38 PM
I see. So how can I turn off the LED?
11-25-2013 01:28 PM
Send the opposite logic level that you use to turn the LED on.
11-25-2013 01:41 PM
Yea, how exaclty do I do that in labview? I only see send digital signal.
11-25-2013 02:09 PM
Exactly. You send out a digital signal to turn on or off your external LED. In your explanation, this is what you have defined as port0/line2, correct? You can also had a front panel Boolean indicator to show the state of the hardware.
11-25-2013
02:50 PM
- last edited on
12-19-2024
09:12 AM
by
Content Cleaner
Hey hunkeelin,
It sounds like you're pretty new to LabVIEW and DAQmx.
I highly recommend you take a step back and start with some simple examples. As I mentioned in my first post you can find some great tutorials for getting started with LabVIEW here : https://learn.ni.com/learn/article/labview-tutorial
An introduction to Data Acquisition here: https://www.ni.com/en/shop/data-acquisition.html
And lots of information on DAQmx here: https://www.ni.com/en/support/documentation/supplemental/06/getting-started-with-ni-daqmx--main-page...
From your first post it sounds like you have some code you got from someone else and just want it to work, but I highly recommend you take the time to go through some of this getting started material to understand how the code works and how to can change it to do anything you need. It will really be worth your time in the long run.
Please let us know if you have additional questions.
Thanks!
-Sam K
LabVIEW Hacker
Join / Follow the LabVIEW Hacker Group on google+
11-25-2013 11:23 PM
Anyway, I went through some the labs, it's helpful but not something I want. I will learn along the way, but the labview part is a very small part of my project. For me to write the if loop all my byself (which seems easy because the guy in this forum who help me out only took 15 min of his time) will take weeks or months. Best if someone could modify my code where it could send a opposite logical signal after 200ms for the LED.
Anyways, for my learning purpose:
1) I am suspecting there should be a modification in DAQmx write but I am really not sure. I code in matlab and c/c++ labview seems to be completely different. I don't even see an "if loop" here.
Thanks.