Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect a mechanical switch to the USB-6009

Hi there!

 

I'm having a hard time setting up a simple switch in my program. I want to trigger a while loop with a mechanical switch. I have two cables sticked into the DAQ-Module: one in the +2,5V-Port and the other one in the P0.0 Digital I/O. Between those cables a switch is soldered. By pressing the switch the programm should detect a voltage increase and trigger a "true". For some reason nothing happens when pressing the switch - even in SignalExpress the green indicator doesn't light up. Any suggestions?

0 Kudos
Message 1 of 17
(8,123 Views)

Why do you think you should see a voltage increase. There is a weak pull-up on each digital input so you would be seeing a logic one with the switch open and closed. You want to switch closure to ground the input.

Message 2 of 17
(8,106 Views)

The 2.5V output on that 600x board is a 1mA reference for the A/D - it is not intended to be used as a power output.

 

Also, the DIO's on there are 5V; the 2.5V you're putting on it is in the gray area so it may or may not make the transition from ground to 2.5 or 2.5 to ground.

 

There's a pull-up resistor in the DAQ, the DIO's should read high with nothing on them.  Attach the lead that's on the 2.5V signal to a ground pin, then see that the DIO toggles low when the switch is pressed.  You can invert the boolean in software to get a true when the switch is pressed.

Message 3 of 17
(8,101 Views)

In addition to the excellent advice already given by the other two posters, I wanted to add in that the the USB 6008/6009 User Guide and Specifications shows how you can connect your switch (see case #4 below):

 

        2011-06-01_175437.png

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 17
(8,068 Views)

Hi, John. I have a task to activate a dc motor using a light sensor.  My atention is to run the motor when there is no light detected (in a dark situation), so act as digital switch. It means both input and output are digital. I tried to configure the diagram shown in the usb 6008 manual, but I dont know how to connect the LDR, where in mechanical switch it will grounded as the switch is activated.  I use simple program, using two DAQ assistant, one is for digital input and the other one is for digital output. (I just try this program, very new with LabVIEW), it might be wrong. I am appreciate if anyone in the committee can help me. Please see the attachment for both connections and the program.

 

0 Kudos
Message 5 of 17
(7,738 Views)

Similar to a mechanical switch, your photoresistor has to be connected between the dig i/o line and GND. The dig i/o usually has a weak pull-up resistor so if the ldr has high impedance the input will be in high state, and in low state if the ldr has low resistance. However I would strongly recommend using a so-called Schmitt-trigger circuit which will create clear output states. In your case, if the ldr has medium resistance, the input level will be in an undefined region and the usb device might react randomly. It is always wise to feed a digital i/o with true ttl signals generated by some ttl compatible circuitry. 

 

I think using a simple 74LS14 Schmitt trigger inverter (you have to connect two inverters in series) will improve performance of your circuit.  

0 Kudos
Message 6 of 17
(7,715 Views)

Thanks for the replied, now I decide to use a complete light sensor circuit available at http://www.reuk.co.uk/LM741-Light-Dark-Sensor-Circuit.htm, but I will modifiy the out put voltage to serve 5volts using L7805. I have several questions to confirm before I damage the USB 6008!!!!.

 

1. Can I use the 5volt output signal from the LDR circuit to Digital input port of the USB 6008, let say P0,0 and than provide Digital output signal, let say at P0,1?

2. Is the USB 6008 can handle the current from the LDR unit? (Not much knowledge in electronic...).

3. Can I use multiple digital input port to activate 1 output, in my case, I am going to use rain sensor and light sensor to switch on a dc motor? If so how will be the connection for the output load (dc motor).

 

To committee, I need your help.....

Thanks in advance.

 

Kind regards

sufre

0 Kudos
Message 7 of 17
(7,704 Views)

> Thanks for the replied, now I decide to use a complete light sensor circuit available at http://www.reuk.co.uk/LM741-Light-Dark-Sensor-Circuit.htm, but I will modifiy the out put voltage to serve 5volts using L7805. I have several questions to confirm before I damage the USB 6008!!!!.

 

Congrats... I was thinking of suggesting  a comparator circuit to get proper signals from the LDR, you found  a suitable circuit.  I would suggest the following modifications: a) of course you do not need a relay (and the snubber diode), you can omit it and connect the collector of the output transistor to the digital input. b) the type of transistor is not critical, you can use virtually any low-power npn transistor. c)  if you use the "open collector" output (as suggested above), there is no urgent need for input protection since the circuit does not supply any voltage to the input, but to make sure you can connect a 5.1V zener diode between the collector of the transistor and GND. 

 

The comparator circuit does not provide any hysteresis . So if the value of the LDR reaches the switching point there might be random output changes with very minor changes of the LDR value. 

> 1. Can I use the 5volt output signal from the LDR circuit to Digital input port of the USB 6008, let say P0,0 and than provide Digital output signal, let say at P0,1?

 

You have to check whether you can configure the digital port bit-wise, i.e. set one line as input and  any other line as output. Sometimes the ports can be set in groups of 4 or 8 lines only, check the USB6008 manual. If this is possible, the procedure is just a matter of software. 

> 2. Is the USB 6008 can handle the current from the LDR unit? (Not much knowledge in electronic...).

 

As long as you connect the collector of the output transistor to the digital input there will be no excess current. 

> 3. Can I use multiple digital input port to activate 1 output, in my case, I am going to use rain sensor and light sensor to switch on a dc motor? If so how will be the connection for the output load (dc motor).

 

again, this is a matter of software only (see above). Digital output lines can drive light loads only, you will need a relay or some power device as interface to the motor. Whenever connecting relays to some circuitry, provide a snubber diode (as shown in the diagram you linked) to avoid excessive backlash voltage.

 

However, since you confessed that your knowledge of electronics is rather rudimentary I would strongly recommend asking someone with more experience, I am afraid discussing the basics of interfacing sensors and motors to an USB device would take much time and place in this forum.  

0 Kudos
Message 8 of 17
(7,700 Views)

> Thanks for the replied, now I decide to use a complete light sensor circuit available at http://www.reuk.co.uk/LM741-Light-Dark-Sensor-Circuit.htm, but I will modifiy the out put voltage to serve 5volts using L7805. I have several questions to confirm before I damage the USB 6008!!!!.

 

Congrats... I was thinking of suggesting  a comparator circuit to get proper signals from the LDR, you found  a suitable circuit.  I would suggest the following modifications: a) of course you do not need a relay (and the snubber diode), you can omit it and connect the collector of the output transistor to the digital input. b) the type of transistor is not critical, you can use virtually any low-power npn transistor. c)  if you use the "open collector" output (as suggested above), there is no urgent need for input protection since the circuit does not supply any voltage to the input, but to make sure you can connect a 5.1V zener diode between the collector of the transistor and GND. 

 

The comparator circuit does not provide any hysteresis . So if the value of the LDR reaches the switching point there might be random output changes with very minor changes of the LDR value. 

> 1. Can I use the 5volt output signal from the LDR circuit to Digital input port of the USB 6008, let say P0,0 and than provide Digital output signal, let say at P0,1?

 

You have to check whether you can configure the digital port bit-wise, i.e. set one line as input and  any other line as output. Sometimes the ports can be set in groups of 4 or 8 lines only, check the USB6008 manual. If this is possible, the procedure is just a matter of software. 

> 2. Is the USB 6008 can handle the current from the LDR unit? (Not much knowledge in electronic...).

 

As long as you connect the collector of the output transistor to the digital input there will be no excess current. 

> 3. Can I use multiple digital input port to activate 1 output, in my case, I am going to use rain sensor and light sensor to switch on a dc motor? If so how will be the connection for the output load (dc motor).

 

again, this is a matter of software only (see above). Digital output lines can drive light loads only, you will need a relay or some power device as interface to the motor. Whenever connecting relays to some circuitry, provide a snubber diode (as shown in the diagram you linked) to avoid excessive backlash voltage.

 

However, since you confessed that your knowledge of electronics is rather rudimentary I would strongly recommend asking someone with more experience, I am afraid discussing the basics of interfacing sensors and motors to an USB device would take much time and place in this forum.  

Message 9 of 17
(7,698 Views)

HI,Buechsenschuetz

 

Thanks again for the quick replied.

I have developed the circuit diagram as you recommended and tested it. It works well. As shown in the attachment.

However comes to interfacing with the LabVIEW, it doesn't communicate with the digital output. For the output I just use a LED as the output.

I used simple program by setting the digital input as PO.O and output as PO.1.  When I manually connected the PO.0 with gnd, the LED is ON. But when I used the LDR unit to switch on, there is no output voltage from the digital output P0.1. Please see attachment for wiring diagram.

If the program is not right or my connection is wrong, please help me to verify the problem...if you dont mind pleas do amenment to my program. 

 

Need help from community...

 

Regards

Sufre

Download All
0 Kudos
Message 10 of 17
(7,670 Views)