Question
Asked May 3 2014

Community Question

Below is a script I wrote to have my robot smoothly look around the room (relatively that is)... I want each servo move to execute one right after the previous one finishes... However, when I run the script it blazes through the script in about a 10th of a second.. The servos don't move(except for a quick jitter)... Do I need to use sleep() instead of servo_wait? Am I not using the servo_wait command properly? I am also having trouble getting my servos to move to their proper positions... They only do about 75% of the time... Sometimes they don't move at all or move too far or too little... I am using 2 Hitec HS-645mg servos and my EZB3 board is using a 7.2 amp nimh battery (so no brown outs battery wise anyway)


servo(D0,50) #centre servos
servo(D1,50)
sleep(2000)
ServoSpeed(d0,2)
ServoSpeed(D1,2)
Servo(D1,70) # look down
Servo_Wait(D1,equals,70)
Servo(D0,88) #look down right
Servo_Wait(D0,equals,88)
Servo(D1,35) #look up right
Servo_Wait(D1,equals,35)
Servo(D0,12) #look up left
Servo_Wait(D0,equals,12)
Servo(D1,70) #look down left
Servo_Wait(D1,equals,70)
Servo(D0,50) #look down centre
Servo_Wait(D0,equals,50)
Servo(D1,52) #look straight
May 3 2014
Ahhh... got it, thanks DJ.... makes perfect sense now. I'll go back to using the sleep. Appreciate the help...

Richard
May 3 2014
just to make it clear ez builder does not require propper coding like how you code with an arduino because i have seen arduino codes and they are way more complicated then the codes that you guys are showing about the servo
DJ Sures
Synthiam
May 3 2014
Mohamed, Just to make it clear: of course the EZ-B requires proper coding. Please explain what you mean by your comment so I can educate your understanding of what "coding" means.

The Arduino uses the programming language C++, which is very old, complicated and outdated. C++ is used for low level programming and requires a lot of effort to make small things happen. C++ and C is what the EZ-B v4 and EZ-B v3 firmware is built with - because it is low level. Also, much of the backend of EZ-Builder and the EZ-SDK is written in C++.

The point to EZ-Robot is you should not ever touch C++. Our product focuses on making robots very easily and quickly to perform tasks without any complicated efforts.

Put it this way... Why would you want to spend 1,000 lines of code in Arduino to do what you can with 10 lines of code in EZ-Robot? You'd have to be bonkers to use Arduino - or have traveled from 2005 - because that's where Arduino belongs:)
May 3 2014
DJ beat me to it... If you assume Arduino represents "proper coding"... Who determines what is and what is not proper coding anyway? EZ Robot's software on the surface may seem more simplistic than Arduino... However, EZb and EZ Builder can do circles around arduino in it's capabilities... Simply put, I can do things with EZ Builder I could never dream of with Arduino... The one drawback is that we still need smart guys like DJ to make stuff simple enough for the average Joe like me to use... No matter how much I appreciate what DJ has created here, I would still like to learn more and be less of just a complacent user....
May 4 2014
I saw a robot that could only avoid obsticles but it had 4 pages of coding and I did not understand any of it but in the way you guys answer my question I now know that ez robot will not require 4 pages of coding for just a simple obsticles avoider