Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

How To Make A Bumper Sensor?

I looked around and couldn't find the post, but how do you make a bumper switch that works off the analogue port of the ez-b?

United Kingdom
#1  
There are a few posts but I think they are in the project showcase topics. Rex's Questar and Josh's Jarvis I believe have mentioned them.

However, basically you need the bumper switches all connected in parallel (if you have more than one switch) and connected to the +5v and signal wire of the analogue port. So what basically happens is when the switch is pushed by the bumper the contacts close (or open but the script would be different) and allow the +5v to flow through the switch(es) and in to the signal.

In ARC you need to monitor the ADC port with a simple loop script that checks the ADC port, or use a WaitForChange command, if the switch is pushed and the contacts closed, the current flows and +5V is put to the signal, the ADC value would be reported as 255 and your script can use an IF to execute something else.

I'll knock up a quick schematic in a second (once ExpressPCB is installed on this PC) and script example.
United Kingdom
#2  
Schematic
User-inserted image


Rough sketch
User-inserted image


Basically a bumper (a strip of plastic, wood or whatever) fixed to a normally open switch. When the bumper is hit the switch is closed. When the switch is closed the current flows through the switch and applies +5v to the signal pin of the ADC port.

When +5V is applied to the signal pin of the ADC port the result of a GetADC() command will be 255. When the switch is closed the value should be 0 (or low, you may find there is some fluctuation around low numbers on the signal.

So with that in mind, you want to write a script that will detect a 255 and act accordingly.

Code:


:loop
$bump = GetADC(ADC0)
IF($bump = 255)
Goto(avoid)
EndIF
Sleep(100)
Goto(loop)
Halt()

:avoid
Stop()
Left(255,1500)
Forward()
Return()
Halt()


Alternately you could try the ADC_Wait() method.

Code:


:loop
ADC_Wait(ADC0, 255)
Goto(avoid)
Goto(loop)
Halt()

:avoid
Stop()
Left(255,1500)
Forward()
Return()
Halt()


Note: none of the scripts above have been tested and may require some minor alterations.
#3  
can you make one yourself? like say, take the positive charge and put it on one metal sheet, and put another one close behind with negative and space accordingly?
#4  
I just learned to get kinda close with the ADC port readings so if the bump switch closes and the port would read 255 then anything above 200 would be fine. If ($bump >= 200)
United Kingdom
#5  
Rich, to extend your idea, you could put a resistor in parallel with each of the switches then you would get a different ADC reading depending on which switches where made so the robot could know front, or side impacts etc. With no impact then you have 3 resistors in parallel - one switch impact then you have 2 resistors in Parallel - two switch impact then you have 1 resistance only, finally three switch impacts and you have no resistance at all. From this you will get a different voltage going to the ADC for all the various impact permutations. To make it even neater, if you use different value resistors on the outer (side) impact switches, then this would allow the robot to differentiate left and right impacts, and your script could act accordingly.

This does need to be a potential divider, so a forth (ratio arm resistor) needs to be wired into the GND rail.

Tony
United Kingdom
#6  
You know what, I thought the same thing last night as I was nodding off to sleep. I did a similar schematic a while back which would determine which switch was hit. I'll see if I can find it since I'm pretty sure I did a better job of the schematic there than I did above.
United Kingdom
#7  
Here we go

Multiple switches on one ADC port and a bit of a discussion to go along with it:)