Let's Make Robots!

See what Robot Sees

 

Your browser is not able to display this multimedia content.


(JKA is working on something more fancy than this, an applet for download)

 

If you are using Picaxe, I am sure you know, use, and appreciate the function called

 

Debug

 

if not, you should try it!

 

Debug, however, sends ALL variables to a window, and you get a lot of numbers. Another function is

 

Sertxd

 

This sends only what you want, and you can use the Terminal (Press F8) in the Picaxe editor. Please see the documentation for more.

 

However – you still only get ASCII and numbers.

 

I always hoped that somewhere hidden in the editor or extras that Picaxe is actually quite packed with – should be a program that had some sort of “plotting-ability”, sort of a lie-detector, or like Windows “task manager / performance-view”.

 

Taskmanager.jpg

 

It would be so great if I could just get a visual of all the analogue data, instead of having to decode and compare all these numbers..

 

This is just as much if I was making a line-follower, a scanner (like on the video), or perhaps something more strange. Also imagine a visual view of bits and pins, weather they are high or low, shown like a piano-roll, so you could easily follow if this went high when that was below 56 or something..

 

Well.. For now I just wanted to make part III of “How to make your first robot”, and I wanted to have some good navigation there, and I wanted the code to be as smooth as possible so that I could teach the best.

 

But it was so f***** hard to get a GOOD overview out of what my sensor actually saw.

 

It should be a well known fact that using Picaxe as both servo-controller and sending out pulses to something like an SRF05 can sometimes produce an extra pulse to the one part. Working with these little circuits is often as much tweaking them to do what they ought to be doing as just telling them to do it.

 

I often find myself adding extra little lines such as

 

pause 10

low 0

pause 10


- that really should not be there, but when the are in there, the robot does what it should be doing :)


 

OK.. The TRICK! (sorry, got carried away)

 

Let´s say you have a word-variable called “range”, it is something returned from your sensor, giving you lots of high and low numbers, and you would like it to make more sense.

 

Try this in the code, just before you read the variable “range” (before, because then it does not matter that we mess with it):

 


 

range = range / 3 max 150

for b1 = 1 to range

sertxd ("|")

next b1

sertxd (13, 10)

 


 

Press F5 to upload your code

Press F8 to view magic :D

 


 

Here is the code I use in the video, in the end, with object recognition.

 

It puts marks on the bars when it finds “a steady part”.

Here the program has recognized a plastic cup in front of it, and marked it with the (+) - signs in the end.

 

see_what_robot_sees.jpg

 

It turned out – just when I was making this walkthrough and I wanted to see if I could just quickly add some object recognition – that the easiest way to find “a cup” was simply to go for areas with almost same value. Apparently things in background is returning much more unsteady values, and a cup in the foreground gives very “smooth” curves, which is easy to detect; Just see if there is not too high a jump from the previous value to this current reading..

 

How smooth we are looking for is set in variable “differencebit”.

 

This code needs a Picaxe, a servo, and an SRF05.

 

Idea is that this "tracing" is used to set up the program, to get to know / see what your robot sees, and then to be omited. It is really stupid that you have to send 150 ASCII before moving on to next scan, but I have no way of just "plotting", though that would be better. Also, for this to be (almost) entertaining, I am moving the "head" with "step 10". This gives not as accurate results, but it makes better video ;)

 

Enjoy!

 


 

Symbol servopin = 0' Defines output pin to which the servo turning the head is connected

symbol trig = 4 ' Defines output pin for Trigger pulse of SRF05

symbol echo = 0 ' Defines input pin for Echo pulse of SRF05

symbol servohead = 0 'Defines outnput pin for servo to turn SRF05

 

symbol range = w1 ‘ 16 bit word variable for range

symbol oldrange = w2' 16 bit word variable for "Where were we last time?"

symbol calcrange = w3 ' 16 bit word variable for "The difference"

 

symbol differencebit = 50 ' sets how little difference we can tolerate to call this "an object"

symbol kopbit = b25 ' this is overkill and not really used in here, but if you get my way of coding, you may see that it can be used for further investigation to have this variable ;)

 

main:

for b0 = 75 to 205 step 10

servo servohead, b0

pause 20

 

gosub puls

range = range / 3

if range > 150 then

range = 150

end if

 

for b1 = 1 to range

sertxd ("|")

next b1

 

'''

if oldrange > range then

calcrange = oldrange - range

 

if calcrange > differencebit then

kopbit = 1

end if

 

end if

'''

if oldrange < range then

calcrange = range - oldrange

 

if calcrange > differencebit then

kopbit = 2

end if

 

end if

'''

if kopbit = 0 then

sertxd ("(+)")

end if

kopbit = 0

sertxd (13, 10)

 

next b0

sertxd (13, 10)

servo servohead, 75

wait 1

 

goto main

 

 

 

 

''''''''''PULS''''''''''''

{

puls:

pause 10 ' this should not be nesecary, but it was of some reason in my setup

low 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,1 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

return

}

Comment viewing options

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

Sorry, bad joke :)

I cannot make sence of your describtion of the problem.

Best is always make one thing work first. Really basic, rewind, make sure every thing is working, step by step. Then make the next thing work with that etc :)

no it is ok , well i will try to explain the problem
I coppyed and passed the code  on this page http://letsmakerobots.com/node/66 and the srf005 worked perfectly but when i coppy and paste the code on this page the servo turns , a bit more to one side than the other but that doesnt mater that much for now, the main problem is the SRF, just cant understan why it doesnt wotk. screen
From Desktop" mce_src="
24-10-08_2031.jpg
From Desktop
" alt="" border="" hspace="" vspace="" width="" height="" align="" />

Still hard to understand you, however I think the problem is the code:

Do you realize how you cannot use b1 when you are using w0 etc? I suspect that is our problem.

Post the code, perhaps :)

This is the code i use, what do you meen by " you cannot use b1 when you are using w0 etc " ? I am new to this so i am slowly learning.

Symbol servopin = 0' Defines output pin to which the servo turning the head is connected symbol trig = 4 ' Defines output pin for Trigger pulse of SRF05 symbol echo = 0 ' Defines input pin for Echo pulse of SRF05 symbol servohead = 0 'Defines outnput pin for servo to turn SRF05 symbol range = w1 ‘ 16 bit word variable for range symbol oldrange = w2' 16 bit word variable for "Where were we last time?" symbol calcrange = w3 ' 16 bit word variable for "The difference" symbol differencebit = 50 ' sets how little difference we can tolerate to call this "an object" symbol kopbit = b25 ' this is overkill and not really used in here, but if you get my way of coding, you may see that it can be used for further investigation to have this variable ;) main: for b0 = 75 to 205 step 10 servo servohead, b0 pause 20 gosub puls range = range / 3 if range > 150 then range = 150 end if for b1 = 1 to range sertxd ("|") next b1 ''' if oldrange > range then calcrange = oldrange - range if calcrange > differencebit then kopbit = 1 end if end if ''' if oldrange < range then calcrange = range - oldrange if calcrange > differencebit then kopbit = 2 end if end if ''' if kopbit = 0 then sertxd ("(+)") end if kopbit = 0 sertxd (13, 10) next b0 sertxd (13, 10) servo servohead, 75 wait 1 goto main ''''''''''PULS'''''''''''' { puls: pause 10 ' this should not be nesecary, but it was of some reason in my setup low 0 ' this should not be nesecary, but if not, strange things hapened pause 10 'this should not be nesecary, but that is what makes it all fun pulsout trig,1 ‘ produce 20uS trigger pulse (must be minimum of 10uS) pulsin echo,1,range ‘ measures the range in 10uS steps pause 10 return } }

wow!  this is really cool...i will definitely try this out as soon as i finish 'my first robot'

 

would this work with the GP2D120 ?

GP2D120 - or any input, of course :)

You may have to alter the code :) 

I finally manged to get this working with the GP2D120...the change in code was actually pretty simple.  I just included the following lines of code:

         readadc 1,range
        range=200-range

since the value of the GP2D120 is inversely proportional to the range we're after, so we need to invert it.

 

I managed to get my robot to recognise some objects... although it doesn't seem as accurate as the SRF..I guess that's the limitation of the GP2D120.

 

I have an ultrasonic range-finding circuit (similar to the SRF)which i had built as a university project lying around somewhere...it would be interesting to see what results i can get with that.  It might be a bit cumbersome to mount onto the servo tho, since it's all on veroboard :/

Hello,

 I understand it is kind of late but I just wondered where in the script did you include these two lines of code and did you alter anything else?

I built a first version of the robot, you can see it here (http://kovachev.net/programming/robot/index.html) and would like to implement the code

from the second version (http://letsmakerobots.com/node/254) but with GP2D120 sensor.

Thanks,

Cedomir 

hi i need help of how to program an SRF05 using picF16-877A and all necessary components needed ,my gaol is to avoid walls i have only one SRF05 ... please any help is important to me thanks...
Please post a new forum topic for assistance. Also please post specific questions and pictures of your robot.