R2R setups require the “inputs” to switch from 5vdc and ground. There is no way to do this with single throw switches. We’re only needing three switches to do a simple LCD menu navigation system.
I asked Beth to make me a quick excel sheet so I could quickly substitute resistor values.
If we go with 4 switches. Would allow up down enter exit.
R0 = 5k
R1 = 1.8k
R2 = 3.3k
R3 = 5.6k
R4 = 10k
When each switch is pressed you get.
S1 = 3.68vdc
S2 = 3.01vdc
S3 = 2.36vdc
S4 = 1.67vdc
These values are about 0.67 volts apart. If you only allow a narrow band for each switch and ignore all the rest you should be able to only respond to the 4 switches.
A to D in for 5vdc is 1023. So the values for these resistors would be.
S1 = 753
S2 = 616
S3 = 483
S4 = 342
So if you write the decision like this it should be good.
if S1 >748 and S1 < 758 then…
Of course the true values may be off a bit in the real world.
Sounds great. I was about to suggest from the previous version that we try changing R0 to something like 4.7 with the earlier ones of 1, 4.7 and 10 would get us voltages like: 4.1, 2.5, 1.5. But I do like your four switch one. So now I just need to dig into my pile of resistors and get ones that are close!
Kurt
P.S - We could also play around to see what all of the voltages are when multiple switches are pressed, but may not need it in this case…
Just need to make sure that no combination of switches would mimic a different switch press. But it shouldn’t be possible. I don;t think it’s possible anyway. lol
Currently I don’t have all of the exact resistors mentioned. I do have others.
For example if I use R0=5.6K R1-R4 = 1.5K, 3.3K, 5.6K, 10K and my Quick and dirty excel sheet is correct:
R0 r1 r2 r3 r4
Value 5600 1500 3300 5600 10000
Voltage 1 Sw 3.943661972 3.146067416 2.5 1.794871795
AToD value 807.6619718 644.3146067 512 367.5897436
The Below tries to calculate the resistence if two switches are pressed at the same time:
Some of them are pretty close, to single button presses, may wish to get the resistors you mentioned in your table. I hope some of this makes sense.
Kurt
Another option I think that would work pretty well is to add the four buttons as another column on the keypad. That is we could do something like:
Then all I need to do is to jumper off of the 4 IOs that we currently normally leave high and we one by one set low and check to see if our input went low and if so we know that switch was pressed. Then it would be simple to update the checkkeypad function to add these switches. Looking at my pretty poor diagram above I wonder if I should add resistors to each of the rows. IE what happens if you press S1 and S2 and P10 is high and P11 is low? I wonder what happens with the current keypad?
What do you think? should I go this way or using our resistor and analog method?
I’ve just skimmed over the last part of this thread. Using the resistor ladder was something similar I did on my Futaba RC transmitter. The ladder replaced the original potmeter for channel 6.
Your latest suggestion sounds like a good idea. (I’ve been thinking of something similar too). So far I’ve not activated two buttons at the same time… Maybe adding some resistor for preventing a shortcicuit/overload would be an idea?
I use a common CAD system for schematics, called graph paper. It’s a step up from the crayons and napkins I used to use. lol
I think adding to the keypad just makes sense. Took a few minutes this morning to refresh my memory on the original DIY radio. Looks like we installed pullups on pins 4 thru 7. If we call them the row, I would recommend we add a column for the additional 4 switches. This will not require adding any resistors. Just soldering wires to the existing keypad. I didn’t have time to find which I/O pin(s) are still available by looking at the code.
On the potential shorting issue (if you were to do a face roll on the keypad) I think the solution is easy. Change the high commands in the scanning routine to input commands. You still look for a low as normal, but there is no way to short anything because all pins are hi-z except the single low on one of the output pins 10 thru 13. It’s probably the way it should have been done from the beginning. lol
Graph Paper??? That is way too modern. I like my crayons They always said I should have been a doctor.
Yep that is the easiest solution. Adding it your way would not require another pullup which would be good. Will start adding it to mine. I will probably make a 4 wire y cable to hook it up to the keypad. I will also experiment with the making them input instead of high and see how that works.
I made the 4 wire Y cable, where one end was 4 female connections to plug into the keypad (the 4 wires with pullups). I wired one of the groups of 4 wires with male connections, such that I plugged in the wires coming from the BB2 and then the other set had a wire going to each of the four new switches. I then ran a common wire to the other lead of each of the 4 switches and this wire continued and was plugged into the P17 on the BAP.
I drilled 4 holes in the face plate of the DIY radio, under the LCD. I roughly lined them up with the row of switches 4,5,6,B of the keypad.
I then updated the source code for the CheckKeypad to change all of the places we said High row(0-3) to instead do input row(0-3), to take care of the possiblility of short cirucit if two buttons are pressed. I also then added the new buttons as RowB and processed it like the other 4 rows. FYI - I unnested all of the ifs in the code so it would now process multiple keys being pressed. To see if it was working I had the characters (W, X, Y, Z) display for these characters.
So far it looks like it is working at least for one key pressed. Now to update my code to use these for: Up/Down/Enter/Cncl.
Yah - I updated the Transmitter program to use two of the keys to rotate through pages. I thought I would updated the program up here for safe keeping…
Well I am making a little progress on the DIY XBee controller and having it run my Brat. Soon will be converting the MechBrat to XBee. I have the actual remote now back in one piece. It is not as shiny as when it was new, but I did hack up a piece of the same material as the top to cover the old hole where the transmitter was and then used some standoffs to attach the larger XBEE holder to it…DIY-Remote-Xbee.jpg
I have the code in place for a few different views/configuration pages. I can set the XBee My address of the controller, and select the destination by its MY address (XBee Destination low). I have not fully tested the changing of the MY. If this works OK, I may also add a new page that allows me to tell the Remote I am talking to to change It’s MY address. This should make it easier to have multiples of these in the same area. I have two ways to display the data. The way that the old DIY receiver had, which showed all of the joystick and slider values. The new one is shown in the above picture, that tries to show which item may be changing in the top row. So if you move the right joystick, it will change to display Right and the X, Y… Second line is for data from remote…
The current code is talking. I still need to get the beginning/ending handshake to work a little better, but I can get them to talk. I also have added code to the Brat/DIY that allows me to go into a mode that I only transmit data when it changes. I currently select that by hitting the E key on the remote. This is starting to work reasonably well, but I did find that if I had the brat walking and then turned off the remote, it continued to walk. So I need to put in a little more handshake here. Maybe have the brat ask every 1/2 second or so for data will be sufficient.
As I mentioned, the second display line is for data from the remote. I hacked in some code that when I press the D key on the remote, my brat uses the Sharp IR sensor and does a ping and converts the value into CM and then sends the data back to the DIY. So that 80 in the second display was the last value I displayed.
I thought I would checkpoint the code up here.
Whats next:
More debugging.
Maybe try to convert to hight XBEE baud rate
Maybe simple program to preconfigure the XBEEs. I can do using USB to computer but others may not…
Configure the remote MY
Move to using Mech Brat
Try Rover?
clean up code.
I know, I Know, but I don’t have a sand blaster I thought about using a sander, but…
As you probably know, I have been thinking about trying out the XBees for awhile. So I started buying different XBEEs to play with. I have some Series 1s and some Series 2.5s. The two different series can not talk to each other. I think I now have 4 of the series 1s that I will be using. Maybe I will pick up a few more. I would also like to play with a VB/VC type one on the PC that can be used as a controller or a reporting station. But we will see where my interests go…
I did not put on rubber caps, but maybe James did. You can see it in the pictures when they were building them. lynxmotion.net/viewtopic.php?f=21&t=4399&start=137. Mine is probably on the the bottom left.
How are your projects coming? If it is like here your summer is probably ending, which hopefully will give you some more time to work on them.
I guess you just have to try handsanding then. Try carefully at the backside to see the effect.
Oh I wasn’t aware of the different series. I’m a bit unsure of what XBEE holder to use. They won’t ship the selmaware board outside US . I probably have to search a bit more to find other distributors.
Ah! That picture explains it!
I’m waiting for some LM parts for starting building some new robots . I’ve not done much with the A-Pod or Felix code yet. Beside robotics I’ve been busy with several outdoor projects. But you are correct about the summer season. The indoor season are ahead (= robotic season !).
I used the DIGI X-CTU software on the PC to pre-setup some of the XBEE settings, like the baud rate. I could (and was) doing this on the fly each time with the BAP software, but there are some problems, like if the CPU resets, the XBEE will not have reset and still be at the high baud rate and may not be easy to talk to. So far there is no easy way to know if the CPU reset or was powered on. Could probably rig up something. Like a capacitor circuit hooked up to one of the analog pins, that you check at startup. If done fast enough you may be able to capture the fact the voltage has not built up yet…
I will probably build a simple program that allows you to preconfigure the XBEES from the BAP and maybe add more configuration stuff to the DIY that allows it to set more of the settings on the Robot side… Will see how far I go.
Cann’t wait to see what you come up with this year!
So, if I understand you correct I can use the smallest XBEE explorer board from Sparkfun on the DIY remote and use the code you posted without any problem? I think I go for the 1 series at first. Does the same code you made work for series 2,5 too?
Yes, the Sparkfun regulated explorer board appears to work just fine. Earlier some of us were trying to figure out how they did the voltage conversions, but so far works great.
As for code running on Series 2 (2.5) chips, I believe that I need to make some changes, to make it work. May try later as I do have two of the Series 2 Pros sitting here.
As for not any problems, it still is a work in progress…