Log in

View Full Version : LED drivers on OI


Andrew Schuetze
12-04-2005, 23:17
Howdy,

I am the lead sponsor and just barely keep up with the programmers on principles of the code. We are researching options to add two LEDs to our control system so that a driver would get an indication of which drive state they are using. I.e. a linear mapping of the sticks verses a peicewise function. Our initial research finds that IFI has built in the ability to drive LEDs on ports 1 & 3 that are the same ones mapped on the OI.
As I understand it the default mapping of the OI LEDs can be customized for user defined values such as we propose. Please point out flaws in my understanding or highlight better options that you see.

A question that I have is if the joystick ports are the same why isn't there an option to drive LEDs in all four ports? Does this option already exist and I just don't realize it? Please explain as best you can to me who has a marginal understanding of the default code.

Thanks,


APS

ConKbot of Doom
12-04-2005, 23:28
Our initial research finds that IFI has built in the ability to drive LEDs on ports 1 & 3 that are the same ones mapped on the OI.
As I understand it the default mapping of the OI LEDs can be customized for user defined values such as we propose. Please point out flaws in my understanding or highlight better options that you see.

A question that I have is if the joystick ports are the same why isn't there an option to drive LEDs in all four ports? Does this option already exist and I just don't realize it? Please explain as best you can to me who has a marginal understanding of the default code.


The 4 ports aren't all the same, rather than LEDs, ports 2&4 have connections for the buttons on ports 1 and 3 respectively. That way you can access 8 buttons on one joystick port.

In User_routines.C there is a section called "robot feedback LEDs" I'm not sure which ones the LED drivers in the port use, but it is some of the ones in there.

Workaphobia
16-04-2005, 15:40
The 11 leds you see on your OI box can be controlled (in order) by the following variables from code:

Pwm1_red, Pwm1_green, Pwm2_red, Pwm2_green
Relay1_red, Relay1_green, Relay2_red, Relay2_green
Switch1_LED, Switch2_LED, Switch3_LED

Set any of these variables to true (that is, a non-zero integer, normally 1) to light them up, and false (0) to turn them off. I have in my code "Pwm1_green = (filter == PWMC_LINEAR);" for example, where filter is a variable and PWMC_LINEAR is a constant, but you could just as easily (and less cryptically) do "if(filter == PWMC_LINEAR) Pwm1_green = 1; else Pwm1_green = 0;".

Two of the joystick ports (1 and 3) have the so called "Led Drivers" that allow you to connect your own leds (I believe between the driver pin and +5, but check the OI pdf to make sure and also to check the proper current level). The other two (2 and 4) provide access to the same buttons that are on the two first two, in addition to their own buttons.

This hasn't proven very useful to my team, however. For some reason, the led drivers are controlled by the exact same variables that control the normal leds embedded on the OI, making them totally redundant. You're better off just using the OI leds and not worrying about making an adapter for the port.

By the way, the led data is sent to the OI on the same byte as the User_Mode_byte, so the leds will only display if your OI is not set in user mode (just toggle the button to battery power or something).

Hope this helped. :)

jdiwnab
16-04-2005, 16:33
This hasn't proven very useful to my team, however. For some reason, the led drivers are controlled by the exact same variables that control the normal leds embedded on the OI, making them totally redundant. You're better off just using the OI leds and not worrying about making an adapter for the port.


Sometimes you want to have the lights next to what you are controlling or in a particular order. We had lights next to some switches so people will know what mode the robot is in better. We also had LEDs set up as a main battery indicator and needed the LEDs in a virtical row with certain colors. This made it better to know at a glance what the battery was like. It isn't really necessary in the compitition, but is nice in demonstrations. And it looks cool to have LEDs sticking out of dimond plating with built in switches... :D

Andrew Schuetze
16-04-2005, 21:48
Sometimes you want to have the lights next to what you are controlling or in a particular order. We had lights next to some switches so people will know what mode the robot is in better. We also had LEDs set up as a main battery indicator and needed the LEDs in a virtical row with certain colors. This made it better to know at a glance what the battery was like. ... :D

May be a not so informed question but, is there a limit to the number of LEDs that one can control via the OI? Is it possible to map pins from any of the ports to control an LED? Like I mentioned in my original post, I am just barely up to speed with the user code.

Thanks a bunch so far,


APS :)

Andrew Schuetze
16-04-2005, 22:15
The 4 ports aren't all the same, rather than LEDs, ports 2&4 have connections for the buttons on ports 1 and 3 respectively. That way you can access 8 buttons on one joystick port.


Okay once again a not so informed question. Exactly how does this map to the hardware :confused: Does the pinout on 1 and 3 map to 8 buttons on one of the joysticks? top hat, trigger, thumb, 4-point rocker switch being those eight... Or does this allow one to build a custom switch box with some combination of rocker/toggle switches ... Or both ...

More likely ....
I have it completely wrong :yikes:


APS

jdiwnab
16-04-2005, 23:24
Andrew, look at the documentation available online for the pinout guides and the manual for the OI and RC. These will tell you more that you would ever want to know. As previously stated, there are 11 LED's available. The proper pins should be in the docs. To wire them, get a DB-15 hood or a "game" cable (they are the kind on the joysticks. You could use a joystick that you don't want anymore and cut the cable off). You will want a good pair of strippers because of all of the wires. Strip the wires and have them separated somewhat. following the pinout, use a multimeter to check which wire is on which pin (there are some standards, but this will nearly always work). Hook the LEDs to the pins you want and then place and hide the wires (if you want to look good, or you could display it for all of it's ugly glory). For the extra buttons, you can splice a cable into the joystick cable or into your new LED cable.
(I'm not completly sure about the rest of this): Switches are between ground and a wire. close it and it is on (logic 0) or open and it is off (logic 1). For multiple postion switches, wire the ground to the grounds and the multiple wires to the other side. For POTs, I think the input could be an analog value and you can deal with it in your program.

But read the documentation. They tell you what pins you need and what things do. Those documents are your friend.

Workaphobia
16-04-2005, 23:29
As far as the pin outs go: You have +5V and ground pins, analog inputs, and digital inputs on all four ports. The analog inputs are mapped on the kit's joysticks to the y axis, x axis, and the wheel on top (I think the last one is unused). The digital inputs are for the trigger, the hat (on the left side), and the two auxiliary switches on either side of the wheel.

After these standard pins, ports 1 and 3 have an additional four pins each that are used for the leds - between the two of them, those 8 leds mirror what I assume are Pwm1_red through Relay2_green. Ports 2 and 4 have, instead of led drivers, four pins that act exactly the same as ports 1 and 3's four standard digital inputs. That is, they are connected in the same way as any other digital input, but they are not unique, they overlap with the buttons connected to the other ports. If you already have a joystick plugged into every port then these pins are redundant. Activating one of these pins on joystick 2 would set one of the p1_sw_**** variables true, not any of the p2_sw_**** ones.

Kyle T
17-04-2005, 15:41
Depends how good your programmers are... I'd honesty suggest using a microcontroller to intervene before the joystick got to the OI, a 8052 should be good, those also run C and can be programed with MPLAB.

Astronouth7303
22-04-2005, 16:14
Depends how good your programmers are... I'd honesty suggest using a microcontroller to intervene before the joystick got to the OI, a 8052 should be good, those also run C and can be programed with MPLAB.

This has been discussed for use of mice or other seiral controllers (eg, modern game controllers). Some have said that it may be a non-IFI circuit controlling the robot.