Alright, so our team wired up the IR to digital ins, saw the lights flash on the board. But the outputs we got were very wierd. no matter what we did, it always said command 1,2, and 4 were 0 (being used), and 3 was 1 (not being used). We wired to IR to ground, a 12V supply, and each cmd line to a signal on the microprocessor. In bench testing, this worked fine. We used WPILib and used the default and such and saw the lights on the OI light up along with the board when we hit buttons. Any help with general setup/use using the first four digital inputs would be great.
I have no idea how WPILib does things, but did you make sure you’re DIO pins were declared as inputs?
Your comments in parentheses are precisely backwards. The IR board outputs are logic 0 when inactive, and logic 1 when active. Does that correction help you identify the problem?
In bench testing, this worked fine.
If you saw multiple signals high and a single one going low while testing, there was something wrong. It sounds like you might not have had a common ground between the IR board and the RC.
The first thing I would note, a high output is generated by the board for 100ms when it receives one of it’s programmed inputs, not a low. So what you describe indicates that “3” was “being used” and 1,2 and 4 were “not being used”. EDIT: Bummer, Alan beat me to it.
So, this brings up a couple of questions, which Dig. input ports/connectors were your signals attached to? Were those ports declared as inputs? How does your code “latch” in those signals?
According to the manual, and tests with microswitches, the input default high, aka backwards from normal
I’m not sure what you mean by this.
A digital input on the RC will be read as a high value, a logic 1, when there is nothing connected to it. An open switch gives a lack of continuity, which is electrically the same thing as nothing. A contact closure to ground will be read as a low value, a logic 0. That’s “normal” for the digital inputs.
The IR sensor board outputs are not like switches. They are actual logic levels. When an output’s associated LED is off, the output is at logic 0. When an output’s associated LED is on, the output is at logic 1. That’s “normal” for a TTL signal.
When you connect the IR board outputs to the RC digital inputs, the values do not somehow change to being “backwards”. An inactive signal is still 0, and an active signal is still 1.
Back to one of Alan’s original questions.
Describe to us the power source and how the power is wired up to your IR receiver.
Your description reflects what you’d see if the IR receiver were powered, say from a separate 9v battery or other source that isn’t the same source of power that the Robot Controller uses (12v battery).
or
If command 3 is always high that would probably just be a bad connection.
Alright, so we connected the power inputs to a 12v 20 amp supply, just like the RC. on the bench, it worked fine, and default code lit up the switch LEDs on the OI when each was pressed, along with the LED on the IR itself. Now, only the LEDs on the IR light up as they are supposed to. the problem is the RC regonizing the signal. On teh bench, we hooked up only the signal wire the the “white” pin on the RC, and it worked. We never got the chance to test it on the robot itself. We got the code upgrade first thing at comp, and then tested things, which is when we found out it wasn’t working.
So, the exact way we hooked up the signals is one pwm for the first three, (one signal per line, put across the three signal pins), and a single signal on another pwm, put in normally, without anything hooked up to the red and black wires. Once again, this setup had been tested on the bench. Maybe we connected to two unused wires, cleaning up the wiring, but even disconnecting these didn’t change anything.
I’m really confused about the output. I might expect the input wired differently to be different, but input three wass the loner, not four. Also, it doeesn’t matter which is which at this point, because they don’t change at all. At comp, we got a couple to flicker once and while, but three was always one, and it was always for a very short time before going back to 0,0,1,0
The way this little guy is supposed to be wired is one (IR board) output going to one (RC) input. That means that instead of connecting three wires to one “PWM” cable, you must use four PWM cables and connect each of the outputs to one yellow/white cable.
How is it being powered when it doesn’t work? We want to know what wires are connected to pins 1-4 of the ribbon cable, and where those wires go. Be specific. The answer will help us to either rule out or zero in on possible causes of your problem.
I think what he meant is that they used a PWM cable, since it has three wires and hooked up each of the wires to a different ribbon wire, then connected the PWM cable to all signals on the digital input. The same way we did it. And the fourth command ribbon wire was on a seperate PWM cable going to a fourth digital signal input.
We saw this kind of behavior when we didn’t have a common ground connected to both the IR board and the controller. I.e. we had the IR board powered by a separate battery than the controller, without a connection between the IR board’s ground connector and the controller’s ground.
[correction] It sounds like the RC and IR Receiver are grounded to the same battery, otherwise you wouldn’t see the zero (0,0,1,0) signals at rest, so to speak.
Just to be sure we’re discussing the same connections I’m going to repeat back how you described your wiring in slightly different terms…
Using pin 1 on the IR receiver as wire 1, as I understand it you have:
- 1 connected to the same 12v+ that the RC is connected to
- 3 connected to the same 12v- that the RC is connected to
- 5 combined with 6 & 7 in one pwm cable connecting to three signal pins, say digital input 1,2,3 (this wire really corresponds to the third IR button LED)
- 6 with 5 above (this wire corresponds to the second IR button LED)
- 7 with 5 & 6 above (this wire corresponds to the fourth IR button LED)
- 8 is the loner connection, say to digital input 4 (this wire corresponds to the first IR button LED)
No other wires are used.
I picked digital inputs arbitrarily just to discuss them.
You see digital input 3 above staying always at “1”?
The momentary change you described before sounds normal. The pins stay high for only 100ms when the IR Receiver passes the signal along. Because it’s so quick your code must catch and save the change. To get feedback try using the OI LEDs available to you to watch what the code sees (but be sure to turn off code elsewhere that may be changing the OI lights), e.g.,
static char command1=0, command2=0,command3=0;
if (rc_dig_in01 == 1) //Yes input 1 is really IR command 3
{
command3 = 1;
Switch3_LED = 1;
}
if (rc_dig_in02 == 1)//Yes input 2 is really coincidentally IR command 2
{
command2 = 1;
Switch2_LED = 1;
}
if (rc_dig_in04 == 1) //Yes input 4 is really IR command 1
{
command1 = 1;
Switch1_LED = 1;
}
The way this is written will turn the appropriate OI light on when the IR remote button is pushed, but will never turn it off. Ultimately, you might want to turn off the other lights when a new command is detected, but to get off the ground you wouldn’t want a bad connection turning off the other lights. Just to test that part of the system is working.
For now try ignoring the failing connection and get your code to work with the other three signals. You can go back to the bad connection after you understand the behavior of the other three. A bad connection will always read as “1.”
A good connection will normally read as “0”, with a 100ms pulse at “1” when the IR remote button is pushed. If the button is held down you’ll see it alternate between “1” and “0.”
You will also want to add a line of code surrounding all of this that states if you see multiple inputs from the board simultaneously, it should disregard all input from the board.
Since a disconnected wire results in a “1”, and a connected wire that sees a signal results in a “1”, the only way to tell the difference is to make sure you see only one signal wire sending a “1”. This will protect against a runaway or out of control condition where the IR board is left disconnected and ALL your values return as “1” - nasty things can happen if you don’t protect against this.
True statement.
I only suggest using something like what I posted to test and debug the inputs, not to actually process commands on the playing field.
To debug this problem you want a direct readout on your OI of what signals are working and you want the lights to latch on the brief 100ms signal, so you don’t have to hope to see a flicker. If you see one of the lights on without having pushed the corresponding IR remote button then it means your signal wire is disconnected. You can use a printf there as well to accomplish the same thing. The advantage of OI LEDs is you’ll immediately see a disconnected signal wire in the pits and on the field without having a laptop hooked up.
For competition you’d have to add what Tom suggested, as well as turn off previous commands and OI lights when a new selection is made.