Hi Folks, I am currently working on a thesis which i will need to demonstrate to my lecturers. I am currently using the previous version of the EZ kits. I need the technical specification of the kits which i will need to state but i cannot find it here. Can someone help by giving me the technical specs of the previous version of the EZ-robot kits? Thank you
Upgrade to ARC Pro
Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!
PDF EZ-B Technical Datasheet
Also available in my datasheet repositiry
If links don't work I'll post some Bit.ly shortened links.
The first thing you will want to do is work out the distance based on the ping reading. The GetPing() command will return a value from 0 to 255, the higher the value the further away the object is. I believe the sensor which come with the EZ-B Complete Kit (V3) was a 1:1 ratio if measuring in inches.
Once you have worked that out you need to have the script check each value in the correct order. It's no use checking for an object at 100cm or less away before checking if there is one at 20cm as it'll say yes and ignore the 20cm code.
So, with some calculations I figure that, if 255 on the ping sensor is 255 inches then;
70cm = 27.6 (or rounded to 28)
47cm = 18.5 (or rounded to 19)
20cm = 7.9 (or rounded to 8)
10cm = 3.9 (or rounded to 4)
A slight deviation from the topic but at this point (before I forget to mention it) I would suggest using a shorter range sensor to increase accuracy.
Now we have the values we need to script it to do something with those values. I like to make things easy to edit so I'll throw those distances in to variables;
This makes it easier to adjust in the future or if you share it with others who need different distances.
Next we need to make the script get the distance and store that as a variable also;
This assumes the sensor is on D6 and D7
Next we do the IFs so that it'll run the correct code under the specific conditions;
We then make that loop constantly by adding a label, a sleep and a goto;
And that's the main part of the script done. There is an alternative method where you could use Ping_Wait() however if you are using four different distances then this wouldn't work well (for one distance Ping_Wait() is ideal, as seen in my latest Ping Roam script in the intelligent turning scripting).
Now it's just a case of filling in the code for the specific conditions/distances.
There are various commands which can do this and they do depend on what is being used to move the robot. Since I like to make people work a little I'll leave it for you to find the script command to change the ServoSpeed() of a modified servo or PWM() of a H-Bridge. (Although if you get stuck again just ask and I'll jump back on it).
Servo(DigitalPort, Position) is probably the command you require but it depends on what you are doing.
$very_far = 28
$far = 19
$near = 8
$very_near = 0
# Looping label
# Get the distance
$distance = GetPing(D0,D1)
# Check the distance
IF($distance <= $very_far)
ELSEIF($distance <= $far)
ELSEIF($distance <= $near)
# Code for near
ELSEIF($distance <= $very_near)
ServoSpeed (D2, 4)
# Code for very near
# Code for no detection (if required)
# Sleep to reduce load on EZ-B and PC (adjust to suit, lower = more accurate, higher = less demand)
# Loop back to the begining
What position do you need it to move to?
The Servo() command should work, if it doesn't check the servo actually works and is connected correctly to the correct port. Also check your script to make sure it is processing the command. If you post your project I'll gladly check over the script.
Move (servoPort, forward/stop/reverse)... so Move (D1, forward) is one example on driving a constant rotation servo on D1 forward..... Otherwise use Rich's example to move a regular servo...