LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can use usb?

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.

usb.jpg

0 Kudos
Message 1 of 13
(2,953 Views)

Smiley Indifferent

 

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.

0 Kudos
Message 2 of 13
(2,940 Views)
If you want to design a usb device, then you need hardware and firmware on the device. As mentioned, you cannot do anything with just a wire. Refer to www.usb.organd and do some basic research. I would also recommend an arduino. With a pullup resistor and the lifa toolkit, you are done.
0 Kudos
Message 3 of 13
(2,933 Views)

@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.

0 Kudos
Message 4 of 13
(2,929 Views)
I guess I was assuming that the op understood some elementary electronics and would have the other side of the switch grounded. Probably a big mistake to make any such assumption.
0 Kudos
Message 5 of 13
(2,921 Views)

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

 

 

0 Kudos
Message 6 of 13
(2,912 Views)

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.

0 Kudos
Message 7 of 13
(2,898 Views)

please explain for me how can do this with serial.

 

if it possible for you give me a vi example

 

thanks

0 Kudos
Message 8 of 13
(2,891 Views)

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.

0 Kudos
Message 9 of 13
(2,875 Views)

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.

0 Kudos
Message 10 of 13
(2,836 Views)