Need some help reading bump sensors for a robot

Discussion in 'The Projects Forum' started by CorruptDB, Dec 15, 2007.

  1. CorruptDB

    Thread Starter New Member

    Dec 15, 2007
    6
    0
    Greetings. I am working on a robotics project and I am a little stuck on reading some bump sensors (mostly because of my lack of knowledge in electronics). I have the ability to read 0-5 volts to 8-bit precision so with a little searching I figured I could use a simple R-2R network as shown here or here to read the switches. However, there are a few problems which I don't know how to overcome. #1 is that my bump switches are either open or at ground so I need a way to have them generate a high signal to feed to the network. Also, it appears that the circuits shown (at least the AAC one) output negative voltages, I need the output to be positive in the range of 0-5 volts (i.e. 2.5 volts for 8 (128), 1.25 volts for 4 (64), etc. Is there a way to change the output so it is in the range I can use?


    Bonus question: I have 5 A/D channels as described above and would like to implement some sort of "bank-switching" system where I can switch between 2 different devices for each A/D channel, so I can pull a digital line high and have all channels switch to their second input. Is the best way to implement something like this simply a relay (5PDT?) or is there a better way to accomplish it?

    TIA for any answers. Sorry for my cluelessness, we all have to start somewhere!
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    The R2R ladder shown in the Ebook will output a positive voltage if the voltage fed into the op amp is negative (it's an inverting amp).

    If you could post up a schematic of your bump switches and circuitry, it would be very helpful.

    Bonus: Look up "analog switch". You can switch up to 8 inputs inexpensively.
     
  3. CorruptDB

    Thread Starter New Member

    Dec 15, 2007
    6
    0
    I don't have a way to generate a schematic (anyone have a recommendation for software that can do this for Linux?) but the bump sensors are really basic, they are microswitches with the common connected to ground and the NO (currently) connected to air. I am controlling the robot with a Pontech SV203 controller which provides 8 RC style PWM outputs and five 8 bit AD channels and connects to a serial port. I am attempting to read which bump switches are closed by converting their state to a voltage the SV203 can read on one if its AD channels. Although I only need 4 bits now for the bumpers, I would like to have up to 8 bits (although I don't know how accurate the SV203 will be at the lower order bits) so I can have additional switches in the future, for example to sense if the gripper is closed or the arm is in its home position.

    I am very much an electronics noob, I understand basic schematics and very basic theory but quickly get lost when discussing even slightly complex circuits. How do I convert my logical on (connected to ground) and off (open) for my bump sensors into a voltage that the R-2R network can use?

    Thanks for the pointer, that was exactly what I was thinking of. My normal supplier does not appear to have a part that would do as I envision, would it be possible to use 2 3245 CMOS quickswitches with the B0-B7 of each switch tied together and the analog inputs going into A0-A7 of each chip? Is there a way to connect the Output Enable pins so that when I pull one high it will pull the other one low?
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Check the Analog Devices and Maxim websites for analog switch info.

    What supplier do you use? Have you looked at the. Mouser and Digi-Key sites? They have everything. Except for the stuff at Newark and Allied, of course.

    Your microprocessor should be able to read your bump switches directly. Even if most of your I/O pins are used, there may be a way. that may sound ignorant, but I am entirely unfamiliar with the Pontech SV203. Do you have uncommitted pins left?
     
  5. CorruptDB

    Thread Starter New Member

    Dec 15, 2007
    6
    0
    I usually use Jameco as they seem to have better prices than Digikey. The SV203 has 5 pins that can read 0-5v but currently I am using all of them for IR sensors and battery monitoring. That is why I was looking into combining the bump sensors into a single input, it would be much more efficient (and would have much less latency) if I only have to read 1 channel rather than 4 to get the bump sensor status. If I ran 5v to all the switches then ran each of the outputs into four of the SV203's AD ports I could then read each of switches but that is not the way it is currently set up. It seems like it would be a fairly common and simple problem (if x pin is at ground pull output pin high, if x pin is open pull output pin low) but I have not had enough education in electronics to know the simple answer.
     
  6. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Don't know how many bump switches you have, but you can make up a voltage divider and arrange it so each switch sends a unique voltage to an A to D input. You can group them into right/left or ahead/behind with multiple divider strings.

    Jameco has good prices, but very limited selection.

    Look at the Ebook on this site. You can't do much electronics work without some theory.
     
  7. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    I gather that you have 4 bump sensors, and only one can be active at a time. Is that accurate?
    If so, you can create a 4 bit DAC as below.
    If I were you, I would look for voltages (with your A/D) that are about halfway between the nominal levels.
     
  8. mrmeval

    Distinguished Member

    Jun 30, 2006
    833
    2
    Which bump sensor? If you can read 0-5 you can use a switch

    http://cs.gmu.edu/~eclab/projects/robots/flockbots/pmwiki.php?n=Main.Construction2

    You can easily expand a single AD to many you just tell another chip which device needs to talk to the AD input and then do your reading. There may be a chip that can do the monitoring for you based on a threshold and then trigger an interrupt but I've only seen one that handles digitals signals that can do that. An atmega chip could do it, trigger an interrupt and tell you which sensor was tripped.

    http://octopart.com/search?q=MC14067
    http://pdfserv.maxim-ic.com/en/ds/HI-508A-MAX359.pdf
     
  9. CorruptDB

    Thread Starter New Member

    Dec 15, 2007
    6
    0
    Yes, I do have four bump sensors (one at each corner of a square robot), but I was hoping I would be able to sense more than one at a time (if the front or back hits head-on both switches will close, if I add more switches to the network they may be closed at the same time as the bumpers, etc.). The reason that I was thinking about using a R-2R network rather than a circuit like in the diagram which you supplied (THANK YOU!!!!!!! You actually read my posts, understand what I am trying to do and supplied a viable answer!) is that I can easily expand it to 8 bits to read other microswitches that the robot may need in the future.

    There are some pictures of the robot at http://www.corruptdb.com/, you can see a close-up of one of the bump sensors in question here.

    Gleaning my original questions from my previous posts:
    Partially answered! If I use a negative voltage to my inputs I will get a positive voltage from the inverting op-amp. So my new questions are:
    a) what negative voltage should I be using for my logical high to get my desired 0-+5v output? -2.5v???
    b) how do I create a negative voltage in respect to my ground???

    Bonus Questions:
    Partially answered! The nebulous pointer to "analog switches" spawned 2 more questions:
     
  10. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Just a quick note - you can't use the circuit I posted when more than one sensor is closed.
     
  11. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Another note: You will never be able to accurately read an 8 bit D/A with an 8 bit A/D. Component tolerances and noise will make it impossible. You probably need an A/D with at least 2 more bits of resolution than your D/A, which means that 6 switches is probably your limit without going to channel switching, and that might be stretching it.
     
  12. CorruptDB

    Thread Starter New Member

    Dec 15, 2007
    6
    0
    Yeah, that's what I was thinking when I wrote this:

     
  13. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Yeah, and that does not consider the R-2R ladder errors. You should use 0.1% resistors for a discrete 8 bit ladder, and then the ON resistance of the analog switches (or CMOS buffers/inverters) still causes an error. You can buy R-2R ladders in SIP or DIP or SMT packages, which pretty much eliminates the resistor matching problem.
     
  14. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    How about setting up a matrix? For 4 switches, use a 2x2 matrix: a pair of vertical wires (columns) crossing a pair of horizontal wires (rows). Where the wires cross, you put a NO switch. The software would activate one row at a time, and read and debounce both the columns. This would allow you to sense any combination of switch closures you want. Once you have the concept, you can move the switches to any place you want. Also, if your micro is very limited in I/O, look into multiplexers and de-multiplexers.

    HTH,
    --Rich
     
Loading...