Rover bot analog input testing

Analog input testing.

Now that all the digital outputs are working as planned it is time to move on to the inputs. The primary inputs are from some range finders, two infrared and one ultrasonic.

These are really great little devices as they do a great deal of the computing before the signal gets to the Arduino. They are three wire devices that supply a 4-20 ma signal to the controller. The 4-20 ma signal is not linear, but it is calculable to the measured distance. Now the trick is that the computer only uses numbers, not variable voltage or current. But it copes by converting the 4-20ma into a number automatically. The range for 4-20ma returns a number from 0-1024. I divide that number by 4 to get a nice round 0 – 255 input signal.

The difficulty with measuring and verifying an analog signal is that, while a digital output can easily be observed, an analog input doesn’t give a visual feedback, unless I program something to show me what it is doing. Fortunately the Arduino software comes with a serial monitor, so all I had to do was set up the baud rate and serial print the sensor values. I put in a delay of 100ms to keep the data from scrolling too fast off the screen. Viola, a stream of numbers from 0-255 zipping up on my serial monitor window.

I took advantage of this stream of numbers to record the distance it senses to use as limits in an obstacle avoidance program. The infrared range finders have a very short maximum range, I could only get accurate reading between 1″ and 12″ from the sensor. The ultrasonic range finder has a much larger range, from 3″ to about 72″! These should work out just great to complement each other.

One interesting thing however, the US-rf gives an inverted signal compared to the IR-rf. The US-rf returns a larger number the further away the object is, and the IR-rf returns a smaller number. I may mathematically invert one to make the programing simpler. Lots of copy and paste happens in programing.

In the future I plan on taking advantage of the serial data function to send info to and from my robot using x-bee radios, but first I want to get this thing roving around.

Next up, roving around with out whacking into walls and furniture, or the cats. The later is optional.

PF

Advertisements
Tagged , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: