Arduino Mega based DIY Remote (XBee)

I agree, Jim.

I would also try a little bit of hot glue. Super glue would attack the light channelling properties of the fiber. I have done it in the past with a short bit of plastic channel holding the fibers over the LEDs.

So far this week I have not done much here. I did update the code to handle 3 sliders, and have it display all three of them on the display. I am starting to interface in the command buttons, so I can add some configuration screens. I then started to wonder about the speed of the code, when I am reading all of this stuff in. So I may start to add some timing code to see where I am at…

But this made me start to start to think about some different trade offs for speeds. The Arduino abstraction idea for IO pins is great, but it makes the access for the IO pins a lot slower than going direct to the hardware. There are alternatives. For example there is a library for doing fast reads/writes to fixed at compile time digital pins. I have read that they may be 10 times faster than using the functions (digitalWrite and digtalRead). But that would require me to unwind some code. Example:

// simply define Digital inputs 2-9 to this byte... diyp.bButtons2 = 0; // Extra buttons on new DIY... for (ch=2, bMask=0x1; ch < 10; ch++) { if (!digitalRead(ch)) diyp.bButtons2 |= bMask; // Need to abstract bMask <<= 1; }

Could be done instead something like:

    diyp.bButtons2 = 0;                                       // Extra buttons on new DIY...
    if (digitalReadFast(2)) diyp.bButtons2 |= 0x1;
    if (digitalReadFast(3)) diyp.bButtons2 |= 0x2;
    if (digitalReadFast(4)) diyp.bButtons2 |= 0x4;
    if (digitalReadFast(5)) diyp.bButtons2 |= 0x8;
    if (digitalReadFast(6)) diyp.bButtons2 |= 0x10;
    if (digitalReadFast(7)) diyp.bButtons2 |= 0x20;
    if (digitalReadFast(8)) diyp.bButtons2 |= 0x40;
    if (digitalReadFast(9)) diyp.bButtons2 |= 0x80;

Which is not too bad, I guess. If the IO pins happened to map to the same underlying IO port on the ATMEGA it would be faster if I simply accessed the pins directly, but in this case, they are not…

I will probably do the above for this input as well as for the command buttons. But I am still trying to decide if I want to unwind the ReadKeypad code…

[code]//=============================================================================
// ReadKeypad: Now lets read the keypad and see if any buttons are pressed
//=============================================================================
word ReadKeypad(char *pch) {
word wRet = 0;
byte bRow;
byte bCol;
byte bBit;

*pch = ' ';    // assume a blank
for (bRow = FIRST_KEYPAD_IOPIN; bRow < FIRST_KEYPAD_IOPIN+4; bRow++) {
    // Set the row to low
    pinMode(bRow, OUTPUT);
    digitalWrite(bRow, LOW);

    for (bCol = FIRST_KEYPAD_IOPIN+4; bCol <  FIRST_KEYPAD_IOPIN+8; bCol++) {
        if (digitalRead(bCol) == LOW) {
            bBit =  c_KeypadMapping(bRow-FIRST_KEYPAD_IOPIN)*4 + bCol-(FIRST_KEYPAD_IOPIN+4)];
            wRet |= 1 << bBit;
            if (bBit <= 9)
                *pch = '0'+ bBit;
            else
                *pch = 'A'+ bBit-10;
        }
    }
    // restore the IO pin to be an input...
    pinMode(bRow, INPUT);    // 
}

return wRet;

}
[/code]
Thoughts?

Kurt

Note to self:

This works:

digitalWrite(12, HIGH); pinMode(12, INPUT); ... if (digitalReadFast(12)) g_bCmdButtons |= 0x4;

But this does not…

digitalWrite(13, HIGH); pinMode(13, INPUT); ... if (digitalReadFast(13)) g_bCmdButtons |= 0x8;

Took me a bit to figure out why. I thought maybe my wire from the button was not working… Forgot that digital pin 13 has LED with resistor on it and the very week PU resistor is not sufficient. Couple of choices, add external PU, or use different IO pin… Will probably do the later…

Kurt

Been playing a bit, now have the code in place to use the 4 buttons (actually I am only using 3 right now…) I have 3 configure pages started:
Change My: simple one uses keypad to change the value. Use logical Enter button to save the value away.

Change Dest: Use simple keypad to enter any hex value, use right joystick Up/Down to scroll through list, right joystick top button, does a scan (ND) and saves away the list into EEPROM…

Calibrate Joysticks: Have not done much yet as my joysticks appear to have a full range as do the sliders…

Back to display XBee info. So far I have not added LEDS or light fibers or the like. May still later. What I have done is add in indicator character to the OLED display that if the last XBEE write succeeded and got an ACK back. It clears the indicator if the write did not get an ACK back. (This is from the XBEE TX transmit status packet…) May still be nice to see other information, like when the XBee is receiving data, but for now I will hold off.

In case anyone is following along, I included a code checkpoint…

Next will be to start testing it more with one of the robots and see how well it works… Will probably need to optimize the code paths in different areas to keep the packets as fast as possible.

Kurt
DIY_Remote-110907a.zip (25.5 KB)

Real nice Kurt… :wink:

I will have to re-assemble my TX to try that… !

Do you know if it’s real hard to get a PPM output out of the code ?

Kurte,
A friend gave me a Arduino UNO would this work with this code?

Thanks
Phil.

Thanks guys,

It has been awhile since I did any of the PPM type stuff and I have not done it on Arduinos… It should not be too hard, but obviously you will only have the single direction communications. Would probably have to take more care in making sure we are doing the right timings, such that we don’t starve the transmitter…

As for Arduino UNO. You could do a scaled back version of this. That is for example I am using 9 (10 if you count battery voltage) Analog pins. The UNO has 6 Analog pins. So you could scale back to our original remote which only had 2 2 function joysticks and 2 sliders.

You also start to run short on other IO pins as well. You have 14 digital IO pins, which is not enough for how I am doing things now, which include:
2 USB - debug input and output
2 XBEE - Note: XBee shields double this back on USB port which is hardware serial port on UNO. - I am using 2nd serial port on Mega
2 Display - I am using hardware serial port 1 for this on Mega
8 Keypad - 4 rows + 4 cols
4 Buttons - Could be 1 IO like old remote (add row or col to keypad)
2 Buttons on top of joysticks - I am actually setup to read up to 8 IO lines here to send…
1 sound - can live without as we did sacrifice this on DIY remote to get the extra knobs…

So we would need to scale this back to get things to get it to fit…

Kurt

Just to explain my need.

I do RC stuff too… so i would like to be able to have a mode that send PPM to a RC Transmitter module. (Like the Spektrum)

Ok, I ordered myself a Seeduino with a ATmega1280. I think its like the one in your earlier posts.
now to order a display. thanks

That’s what we did with the first radio. I have the transmitters in stock as well.
lynxmotion.com/p-676-dsm2-ai … r7000.aspx

viewtopic.php?f=21&t=4399

I have made the following changes to the faceplate for you.

Enlarged the size of the four push buttons to 0.266" (17/64").

Enlarged the LCD hole to 34mm wide by 35mm high.

Added four 0.125" PC board mounting holes.

Enlarged the circles for the joysticks from 1.5" to 1.6".

Moved the sliders so they are take up 0.125" less width.

Do you need me to drill the countersunk holes for the sliders, or do you have a drill press? :wink:

Thanks Jim,

Nope don’t have a drill press, unless you count the Dermal thingy… On the current plate I just used a larger drill bit and hand turned it. Not perfect but did get the job sort-of done… Some day I should probably set my self up with a few more tools :laughing:

Kurt

Tools I have… A workshop not so much… But that’s going to change. :smiley: I will drill them for ya buddy!

Thanks, I believe the new plate will arrive on Tuesday :smiley:

I have been playing around with the code and setup and I know for sure that these 4 function joysticks do not do as good of a job of going back to their center point, like the Hitec ones do. Maybe at some point I will have to do version 3 and get some of the new Hitec joysticks and try it out again! I will wait for the new plate, before I try to fit everything into the case. I still need to drill a hole into the outside of the case to hold the USB extension cable. I will probably also add an additional hole for a pushbutton for doing a reset. On the other remote, I did not need this as I would simply turn the power off, but with this Arduino Mega, it stays powered up when it is plugged into USB…

I have been playing around with the code for both the Arduino remote as well as the DIY T-Hex code running on Bap28. I believe I sped up response time for the Arduino remote code by checking to see if the robot as asked for data more often. Also I changed the OLED code to instead of waiting for a command like draw text/react to complete before continuing, I instead check to see if the previous command completed before I issue the next one. More like changes may be needed.

I changed the BAP code to not be so hard coded for the size of the DIY remote message coming in. In particular, it now can handle between a minimum size of packet and a maximum size of packet. I then exact to make changes in the UI depending on which remote control is being used. For example if I use the Original DIY remote with two extra knobs and both joysticks are self centering, than the current code uses one of the knobs for the height of the robot, but with the new remote, these are self centering, which does not work very well for this, so I case this in the code for the larger packets to use the middle slider instead. Now I just need to figure out the best use of the self centering knobs on the joysticks for… Zenta or Xan have any suggestion on how you would map these controls?

Kurt

Hi Kurt,

The self centering 3. axis on the joysticks is a nice feature for some applications. Using the extra slider for body height is a very good idea.

An example of control with three new modes:

Walk/Rot mode:
Left joystick: Gait and gait rotate (3.axis)
Right joystick: All 3 body rotations

Walk/Trans mode:
Left joystick: Gait and gait rotate (3.axis)
Right joystick: Body translation + body yaw rotation (3.axis)

Trans/Rot mode:
Left joystick: Body translation 2 axis, the 3. axis vacant? Maybe gait rotate or body height (not directly though).
Right joystick: All 3 body rotations

I like the ability to perform walking, rotation and translation at the same time. :smiley:

The 3. axis on left joystick could be used to control body height, not directly though but still possible. Similar to how Jeroen did on the single leg control (leg lift height).

Thanks Zenta,

I will try out these out and see how well it works. May do this more with the Arc32-phoenix.

Thanks again!

Kurt

I received the updated face plate :smiley:, which brings me to good news and not so good news…

Good news, it is looking better!

I used a palm sander this time to rough up the cover. I also did drill 1 extra hole for a reset button. Turns out I need another button as these pushbuttons turn out to be normally closed (push to open), which causes my jumper to go between reset/ground to be set… Need to see if I have a different button.

Also I need to switch around some of my wires or update the code such that when I pull the joystick down, the value is zero (not 255)… Not a big deal. Could simply swap the Red/Black wires in the 3 pin connectors to do this, or could simply have the code handle it…

The not so good news. There is a thin ribbon cable on the bottom of the OLED that connects to the controller board, which is now acting flaky. Not sure if it did not like being bent, where it is slightly going through the hole, or because I have moved it around several times. At best I have a few horizontal pixel lines not drawing… Which you may be able to pick up in the photo above. If I press on the back of the cable I can sometimes make it better, other times worse… Will contact 4Dsystems for advice. Probably good enough to play with for now, but may order a second one. May order a second one to make it better…

Kurt

Hey there. Looking nice. 8)

The thing on those switches is the red and the black work differently. Can’t remember for sure but I think it’s black is NO and red is NC?

If you need another panel for any reason it’s no trouble. Just let me know. :wink:

Thanks Jim,

If I need to get a new OLED, Sparkfun is out of them, but robotshop has them. Their prices for the
128x128 is about $50 and their 160x128 is about $60 versus about $80 at sparkfun… So for the extra $10 it might be nice to have the extra 32 bits per row… So I may take you up on it.

Kurt

Hi Kurt,

Can you tell me something about the overall quality of the 4 function joysticks you are using. I’m looking for a way to get the extra DOF on the joystick like you and Zenta got. Shipping to the netherlands add an additional $40 for 2 joysticks. So I want to make sure that the $120 are worth it.

Thanks, Xan