Brazil
Asked — Edited
Resolved Resolved by Dave Schulpius!

Soundservo Control

friends, I've been trying to use the SoundServo control to animate the mouth in one of my robots. I'm using the EZ-b4 soundservo. but.. it does not respond in sync to the sayezb command... sometimes it does not move at all. someone knows how to set it up correctly in order to sync sound and the servo movement ? thaks...


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

Brazil
#9  

Now I'm trying to power the servos from another source (with only 6V).. But still not good... It does not sync at all! stress

Brazil
#10  

Does anyone have a script that uses the $SoundValue to move the servo? I tryed to write one.. But I'm not the script guy yet... 4 positions (close, barely close, barely open, open) I think would work.. What do you think? confused confused confused confused

United Kingdom
#11  

I wrote a script similar to that a while back but it would probably take longer to find than it would to write...


# Variables, change to suit
$closed = 0
$halfclosed = 60
$halfopen = 120
$open = 180

# The script - assuming servo on D0. Adjust IF and ElseIf values to suit.
:begin
IF($SoundValue = 0)
  Servo(D0, $closed)
ElseIf($SoundValue < 5)
  Servo(D0, $halfclosed)
ElseIf($SoundValue < 10)
  Servo(D0, $halfopen)
Else
  Servo(D0, $open)
EndIf
Sleep(250)
Goto(begin)

Obviously modify to suit and be aware this was written without ARC and without much thought. There may be a better method but the basics are there for you.

#12  

Rich, wouldn't the halfclosed part always be on because of the 0 for closed(its less than 5)? I know this was a half-hearted write but just to make sure.

United Kingdom
#13  

Nope. And I am glad you asked the question as it leads on to how the script is run and read by ARC.

The IF nest checks the IFs in order so in the above we have

IF($SoundValue = 0)
ElseIf($SoundValue < 5)
ElseIf($SoundValue < 10)
Else

When the IF nest finds a statement which is true it will run the code after that statement but before the next. Once it has found a statement to be true and run the code after that statement it then jumps down to the EndIf.

The formatting of an IF nest helps explain it and helps write scripts.

So for instance, if the sound value variable was 7 I will explain the steps which will be run by ARC...

Code with line numbers and comments and settings removed to make it clearer and easier;

01 :begin
02 IF($SoundValue = 0)
03   Servo(D0, $closed)
04 ElseIf($SoundValue < 5)
05   Servo(D0, $halfclosed)
06 ElseIf($SoundValue < 10)
07   Servo(D0, $halfopen)
08 Else
09   Servo(D0, $open)
10 EndIf
11 Sleep(250)
12 Goto(begin)

So taking $SoundValue as being 7 the script would run the following lines in this order... 01, 02, 04, 06, 07, 10, 11, 12, 01, 02 etc...

Notice that when the IF or ElseIf isn't true it doesn't run the code between the IF or ElseIf, it jumps to the next ElseIf or Else.

When it is true it runs the code after it (line 07) then jumps to the EndIf since a statement has been satisfied.

The order in which the If and ElseIfs are put makes a big difference.

So another example, this time $SoundValue is 0 the script would run the following lines in this order... 01, 02, 03, 10, 11, 12, 01, 02 etc.

If $SoundValue was 4 he script would run the following lines in this order... 01, 02, 04, 05, 10, 11, 12, 01, 02 etc.

If the $SoundValue was 11 the script would run the following lines in this order... 01, 02, 04, 06, 08, 09, 10, 11, 12, 01, 02 etc.

So once a statement is found to be true it stops checking the other statements hence the command being ElseIf.

Think about it this way, you see a colour on a piece of paper, someone asks you what colour it is out of Black, Blue or Red...

If you think it's black
  Say Black
Else, if you think it's blue
  Say Blue
Else, if you think it's red
  Say Red
Else
  Say I don't know

If it was black you wouldn't keep thinking about if it was blue or red, neither does an IF nest.

Hopefully that's explained it clearly.

Brazil
#14  

No matter what I do.. I just can't put that to work.. The servo does not respond in sync to the sound.

When I power the EZB with 7.5 volts and plug the servo on (say.. D0) I always get the message "battery is low.." I tried do feed the servo from another source.. but it simply do no move at all!

I am sooo frustrated.. The soundServo was a big thing to me to wait for the V4... Thanks for ANY HELP!

#15  

By default the low voltage warning is set at 6.6v... Are you sure the battery you are using is at 7.5V? Maybe you need to recharge it...? What battery are you using? If you are using a wall adapter, make sure it can supply more than 2 amps... Servos need power, a 1 amp adapter cannot supply enough power to run the EZB4 board and even 1 servo.... Something like this (below) would give you lots of juice...

User-inserted image

United Kingdom
#16  

If it's 7.4v and stating it's low it needs charging.

Depending on the battery type and the voltage level you may need to replace the battery.

Check the voltage with a multimeter or connect it with no accessories connected to the EZ-B. Check the voltage then. It could be a faulty servo which, when attempting to move, creates a huge voltage drop, this may happen for many reasons so it's worth testing the servo and testing the battery.