Let's Make Robots!

Grapher for IR-Distance sensor

AttachmentSize
GraphSerial.pde1.97 KB

Yesterday I mounted a Sharp GP2D12 on a servo and I thought of mapping the area in front of the sensor (at least at a certain height) to use them with a bot and I wanted to know how the bot "sees" his environment.

The software for the ATmega takes readings every 10 degrees and then sends these values to the computer via serial.

Now I have seen alot of cool things done with processing and I thought I'll try it out and what I came up with is basically a graph of the distance "bend" by 180 degrees. The graphed data reminds me of the graph you can find in the datasheet of many ultrasonic sensors like the SRF05.

The next step would be reading the serial data directly into processing and then graph it, but my skills in processing aren't good enough (yet) to do something like this altough I have already tried to do this (any suggestions appreciated!^^)

I dont know if this is relevant to anyone but I thought I'd post it because it does have to do with the often used Sharp IR distance sensors.

 

EDIT 11/15/11: I managed it to add serial support! Now the data received via serial is stored in an array and then plotted until the next data plot is received

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Will take a look at this. Getting a base setup where you can test sensors would be nice. This could include data from ping sensors as well.

It doesn't actually matter from wich sensor the data is coming, the trick is sending the data to the computer in the correct format. The format is:

Data + \n

Arduino Code:

println(distance, DEC);

AVR-GCC:

itoa(distance, buffer, 10);

sendUSART(buffer);

sendUSART("\n");

 

using printLN to send data to possessing you end up with CR = 13 & LF =12 at the end of every send and if your trying to visualize  data these numbers get mix in to you data stream confusing much well it was at the time

and you need to receive it in the right format as well

so just Print not Println unless printing to a terminal were you need to format your data in to a report ect

just so everyone's aware

hay what's   "  \n  "   ?

\n is the new line character, thats why you need something like println(); on the Arduino.

hay that's good to know ,,, but i don't think you would need a new line on this app

You need a new line character because the program reads the input string until it reaches \n and then it starts reading the next string until \n and so forth

your dealing with strings im think single Byte's never mind

I just posted a forum topic asking how this was done. Shoulda read this first, and straight asked you.

How did you do it?

I know how to read analog values into Serial with my Arduino, but sending them to processing?

There is a class called Processing.serial which can make contact with the input fron the arduino.

I once used it for a wii chuck adapter, and i used this link:

http://hacknmod.com/hack/how-to-graphically-visualize-data-real-time/

 

Yeah I know that it can be done, as I said I have tried it before but the problem I have is converting the received string to an integer and then store that value into an array to plot the graph afterwards.