03-14-2014 12:45 PM
hi
i have a switch and i want to ever that i press it, i have a Voltage in two other wire.
and i want to have number of press the key.
03-14-2014 12:59 PM
I don't want to sound rude so I will do my best. Your diagram is incorrect for several reasons. Lets just say Windows does not give voltage access to each USB port on your computer. There is no way for your computer, let alone Windows, let alone any programming language, to know if there is 5V on a USB data pin.
You need a ADC somewhere that can sample the voltage and determine the value of it. NI sells several cheap USB devices for taking analog in readings, or digital in readings. The MyDAQ is great for learning. If that is too expensive look at the Arduino LIFA toolkit.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-14-2014 01:14 PM
03-14-2014 01:15 PM
@Dennis_Knutson wrote:
With a pullup resistor...
Yeah don't forget that one. If you do then when the switch is on you will see 5V. When the switch is off you could see 5V or you could see the value climb, or you could see the value fall but you will likely not see 0V.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-14-2014 01:26 PM
03-14-2014 01:42 PM
thanks
can i do this with another port?(for exapmle serial)
in c++ i can turn on a LED.
but in labview i can't do it
i want to perss the key and LED turn on
thank you so much
03-14-2014 02:35 PM
It is possible with Serial, but certainly not with USB.
You can access the pins of the serial port via VISA.
You will need to show some code to let us know at what stage you are with your program otherwise describing each and every tiny step will be very tedious.
Shane.
03-14-2014 02:59 PM
please explain for me how can do this with serial.
if it possible for you give me a vi example
thanks
03-14-2014 04:33 PM
hamedi wrote:
in c++ i can turn on a LED.
but in labview i can't do it
How are you doing this in C++? If you share the code, we might be able to explain how to do the same thing in LabVIEW.
03-15-2014 03:10 PM
You could also use some sort of USB enabled device - like arduino or some FTDI USB chip
as you want. I did such a device with an atxmega controller for a machine which gives some simple IO
that i use with labview application for displaying some process values. I did this via
a virtual serial port (called CDC) which is very easy to use an requires no USB
related programming.
Then you can connect to VISA serial functions an communicate strings.
With very little labview code you should the be able to decode and count the edges
of the button input.
With this solution you should also be able to do more complex USB IO in future.