Asked — Edited
Resolved Resolved by DJ Sures!

Why Does This Script Not Work?

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


ARC Pro

Upgrade to ARC Pro

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.

#1  

Humm, this script looks good and I tested it. In my ARC 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 ARC. 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.

Good luck!

#2  

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?

#3  

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.

PRO
Synthiam
#5  

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...


ServoSpeed(d0, 5)
Servo(d0, 1)
Servo(d0, 100)
Servo_Wait(d0, 100)

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()

#6  

Ahhh... got it, thanks DJ.... makes perfect sense now. I'll go back to using the sleep. Appreciate the help...

Richard

South Africa
#7  

just to make it clear ARC 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

PRO
Synthiam
#8  

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 ARC 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:)

#9  

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 ARC can do circles around arduino in it's capabilities... Simply put, I can do things with ARC 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....

South Africa
#10  

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