, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here
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,70) # look down
Servo(D0,88) #look down right
Servo(D1,35) #look up right
Servo(D0,12) #look up left
Servo(D1,70) #look down left
Servo(D0,50) #look down centre
Servo(D1,52) #look straight
I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.
Also, consider reviewing the Learn section for informative lessons and activities.
Check it out!
Humm, this script looks good and I tested it. In my EZ Builder that's not connected to a EZB it pauses at: Servo_Wait(D1,equals,70) so it appears to be working for me.
Try disconnecting from your EZB to see if the script pauses. Then unplug your servos from EZB and connect to EZ Builder. Will the script run normally? Reconnect D1 and then try to run the script again. Then D0.
Sounds like the issue is the servos. Are these the only servos you have? If not try other servos. Also I know you said you have plenty of power but if your powering the servos off EZB try powering them directly from their own power source. This way you can narrow things down and find out what is and is not working. Troubleshooting is a step by step process and best done if you start at the beginning, find out what is working, sectionalize and work back from there.
I have tested with other servos (HS-422), same problem... When I unplug the servos the script does not pause where it should... However, when I disconnect the ebz board, the script pauses where it should... Can anyone hook up two servos to D0 and D1 and see if this works for them?
I haven't connected two servos to D0 and D1 but I have learned to add a pause after the wait command to smooth out multiple servo movement commands.
Thanks Doc... I'll give it a whirl and see....
It is impossible for that script to work - I understand what you're concept of using ServoWait() is, but that's not how servos work. The EZ-B tells the servo what position to move into and therefore knows what position it is in. It does not know what position the servo is in by any other means.
So, if you do...
The Servo_Wait() will return right away because the previous command set the Servo Position - even if the servospeed() was set.
You will have to use a Sleep() command instead of Servo_Wait()
Ahhh... got it, thanks DJ.... makes perfect sense now. I'll go back to using the sleep. Appreciate the help...
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
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
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....