Picaxe optical radar for robots.
Here’s the idea: A sharp GP2D12 IR Range Sensor on a mini servo, with positional feedback and a scanning routine. The scanning routine must sidestep the conflict problem with SERVO commands and serial TX commands. The positional feedback must be accurate and repeatable, and hopefully easy to implement without requiring addition sensors/encoders. The Picaxe, hopefully an 08M ultimately, though I’m prototyping with a 14M, will operate independently of the main robot ‘brain’ and send object detection and ranging data serially.
This is what I have so far: The scanning routine simply lets the servo go as fast as it can on each sweep. So it’s a single SERVO command to one extreme, then another to the other extreme, then repeat. But after the command has been issued, and the servo is moving (approx half second for one sweep left-to-right), the analogue output from the range sensor is being read by ADC0 in a loop, placing each reading into consecutive RAM locations using POKE.
Without a delay in the loop, the available ram will be full with readings before the sensor head has panned more than a few degrees. So a balance has to be struck with the number of samples you want and how long you wait between samples, bearing in mind that the sweep will finish in about half a second. For my test rig I’m using 20 samples for one left-to-right sweep, though I plan on doubling that eventually.
This works upto a point, but the problem is that no two servos are exactly alike, and even a single servo will vary it’s sweep time according to battery conditions etc. So while you now have a nice record of distance information from the sweep, you don’t have a good record of directional information. Enter positional feedback.
If you dismantle the servo, you can access the centre terminal (wiper) of the integrated feedback pot. It’s fairly easy to solder a connecting wire and feed it out of the servo to your circuit.
For the mini servo I’m using at the moment, this output (referenced to zero volts, common with the servo and Picaxe), carries a voltage which varies from about 1 volt at the left extreme, to about 2.2v at the right extreme. The extremes I’m using are SERVO 5,80 and SERVO 5,220. Not quite 180 degrees, but plenty good enough for the robot application.
Now during a sweep, I have two analogue signals. One from the positional feedback, the other from the distance reading. If you rescale the positional ADC reading, you can use that number as the memory address into which you POKE the distance information. You can also use it to determine exactly when the sweep has reached it’s end.
Once you have the data in RAM, it can be passed serially to the main ‘brain’ of your robot at the end of each sweep. A single burst containing all the range data for one complete sweep.
So far it’s working out pretty well. I’ll update this thread when I get the software sorted. I just have a few proof-of-principle routines and a GP2D12 Blu-Tacked onto a mini servo ATM. I’ve also ordered a small RC tank from ebay (sold as faulty) that I’m going to gut and use as an experimental robot base.
Ultimately I hope to have a free roving autonomous robot that can continue moving while scanning and object avoiding.
Here’s the idea: A sharp GP2D12 IR Range Sensor on a mini servo, with positional feedback and a scanning routine. The scanning routine must sidestep the conflict problem with SERVO commands and serial TX commands. The positional feedback must be accurate and repeatable, and hopefully easy to implement without requiring addition sensors/encoders. The Picaxe, hopefully an 08M ultimately, though I’m prototyping with a 14M, will operate independently of the main robot ‘brain’ and send object detection and ranging data serially.
This is what I have so far: The scanning routine simply lets the servo go as fast as it can on each sweep. So it’s a single SERVO command to one extreme, then another to the other extreme, then repeat. But after the command has been issued, and the servo is moving (approx half second for one sweep left-to-right), the analogue output from the range sensor is being read by ADC0 in a loop, placing each reading into consecutive RAM locations using POKE.
Without a delay in the loop, the available ram will be full with readings before the sensor head has panned more than a few degrees. So a balance has to be struck with the number of samples you want and how long you wait between samples, bearing in mind that the sweep will finish in about half a second. For my test rig I’m using 20 samples for one left-to-right sweep, though I plan on doubling that eventually.
This works upto a point, but the problem is that no two servos are exactly alike, and even a single servo will vary it’s sweep time according to battery conditions etc. So while you now have a nice record of distance information from the sweep, you don’t have a good record of directional information. Enter positional feedback.
If you dismantle the servo, you can access the centre terminal (wiper) of the integrated feedback pot. It’s fairly easy to solder a connecting wire and feed it out of the servo to your circuit.
For the mini servo I’m using at the moment, this output (referenced to zero volts, common with the servo and Picaxe), carries a voltage which varies from about 1 volt at the left extreme, to about 2.2v at the right extreme. The extremes I’m using are SERVO 5,80 and SERVO 5,220. Not quite 180 degrees, but plenty good enough for the robot application.
Now during a sweep, I have two analogue signals. One from the positional feedback, the other from the distance reading. If you rescale the positional ADC reading, you can use that number as the memory address into which you POKE the distance information. You can also use it to determine exactly when the sweep has reached it’s end.
Once you have the data in RAM, it can be passed serially to the main ‘brain’ of your robot at the end of each sweep. A single burst containing all the range data for one complete sweep.
So far it’s working out pretty well. I’ll update this thread when I get the software sorted. I just have a few proof-of-principle routines and a GP2D12 Blu-Tacked onto a mini servo ATM. I’ve also ordered a small RC tank from ebay (sold as faulty) that I’m going to gut and use as an experimental robot base.
Ultimately I hope to have a free roving autonomous robot that can continue moving while scanning and object avoiding.