PDA

View Full Version : Digital Outputs on the Driver Station with C/C++


Bongle
01-23-2009, 08:28 AM
Last night we wired up a bank of LEDs so that we could do real-time debugging without relying on printfs or the debugger (both of which are slow). However, we couldn't get them to actually turn on and off.

If we plug them into the digital outputs with the positive wire to the center pin of the DS digital out and the signal wire to the signal (top) pin of the DS, they'll turn on. Likewise, if we put the signal wire to the ground pin of the DS, they'll turn on that way as well. However, we couldn't get them to turn off programmatically.

Inside our operator control loop, we tried:
ds->SetDigitalOut(8,false); // turn off digital output 8 (I may have got the function call wrong here, I'm going off memory)

We tried that just to see if we could turn them off, and nothing happened. We plugged the light into every single digital output to see if we got the number wrong, but they were all still on.

I'm guessing there is some jumper or code setting we have to flip in order for this to work. We read part 3 of the setup manual (which includes specs on the outputs) and couldn't find anything. Can anyone help us?

Mark McLeod
01-23-2009, 08:43 AM
If we plug them into the digital inputs...

Plug them into the Digital OUTPUTS :)

I'm sure you just called them "inputs" by mistake.

Bongle
01-23-2009, 08:46 AM
Plug them into the Digital OUTPUTS :)

I'm sure you just called them "inputs" by mistake.

Oops, we were definitely on the ouputs (the 8 sets of pins near the 'top' of the DS), I made a typo :)


I should also note that we hooked the LEDs to the robot's digital outputs and had great success with that. But since we want some driver feedback that isn't just a laptop on the dashboard port, we want to use the digital outputs.

Mark McLeod
01-23-2009, 10:15 AM
I believe you may have to update the dashboard to get this to take effect.
The set outputs have to be transmitted back to the DS as part of the periodic packet transmission and there might be some interdependency there.

P.S. I don't know though. I haven't played with this particular path yet.
I'll give it a try later if I can.

Alan Anderson
01-23-2009, 01:12 PM
If we plug them into the digital outputs with the positive wire to the center pin of the DS digital out and the signal wire to the signal (top) pin of the DS, they'll turn on. Likewise, if we put the signal wire to the ground pin of the DS, they'll turn on that way as well. However, we couldn't get them to turn off programmatically.

I think they all start out off, so turning them off won't make any difference. You've just wired it so that "off" lights the LED.

Put the positive wire on the signal pin and the negative wire on the ground pin instead, and you should see the LED light up when you turn the output on.

Kruuzr
01-26-2009, 09:19 AM
You should also wire something like a 150 ohm resistor inline to limit the current going through the LED!

Steve C.

Bryscus
01-26-2009, 03:45 PM
Here's how to quickly calculate what resistor you should use for your LED. You will need to know the current consumption of the LED and the forward voltage of the LED (when a diode turns on, it more or less maintains a constant voltage accross itself). The relationship between current, resistance and voltage is defined in Ohm's law, V = IR (where V is voltage, I is current and R is resistance).

Vf = forward voltage of the diode
Id = diode current

The voltage supplied by the digital I/O port is 5V.

Since the diode and resistor are in series, they will have the same current flowing through them.

This means that the voltage accross the diode added to the voltage accros the resistor must equal 5 volts. Thus, 5V = Vf + (Id * R).

or R = (5V - Vf ) / Id

Hope that's a help as well...