Asked — Edited
Resolved Resolved by Rich!

Adc To Move Jaw New Software

Hello, I had a working JAW/mouth working with older software. I upgrade to the lastest software and can't figure out how to sync the jaw using a analog to digital from my PC to the power amp that goes to the ADC0. I can't figure out how to make it work using the new software.

This is what I had using the older software for the jaw sync...If (ADC(ADC0) > 1) servo(d4,48) sleep(10) release(d4) endif

Any help would be nice.

Thanks, Mike


ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

United Kingdom
#1  

The IF in line one is incorrect. ADC(ADC0) is incorrect, it should be GetADC(ADC0)


IF (GetADC(ADC0) > 1)
  servo(d4,48)
  sleep(10)
  release(d4)
ENDIF 

#2  

Thank you Rich, I will give it a try.

#4  

hi rich sorry it's taken so long to get back to you. I've been away from my project for quite a while. that program statement that you put in the thread did work however it only does it once I need it to be continuous. maybe using the wrong program but I'd like to have the jaw move every time the speech recognition says something. is this possible I'm using version 9 4 2013. I am still using the v3 board.

thank you in advance Mike

#5  

merne, you need to upgrade to the latest EZ-B release, is there some reason that you are still using 9.4.2013 ?

United Kingdom
#6  

Add a label to the top and a sleep and goto at the bottom to make it loop.

:loop
IF (GetADC(ADC0) > 1)
  servo(d4,48)
  sleep(10)
  release(d4)
ENDIF 
SLEEP(100)
GOTO(loop)

You may need to add in another servo() command to move the servo from position 48 since it's all moving very quickly it may all happen faster than it can physically move and release the servo.

Also, as Doc said, update your software.

#7  

Hi guys, as always, your all so quick for answers. Thanks! I will try Rich's program commans today. as for the new software version, i thought it's for the new v4 board only? Maybe i am wrong. Mike

#8  

Although the New EZB4 code is now included in the new releases there are still quite a few improvements in the code for the EZB3s.

United Kingdom
#9  

Improvements including a firmware update to the V3 which makes it a lot better. It's worth keeping the software up to date.

#10  

hi rich. I updated the software and I used your commands I need to tweak it a little and it seems to work. not quite as good as I'd like i need to figure that out. I did try PC servo sound but when you talk the mouth moves. so I am using your script now but like I said I need to tweak it. I may have more questions down the road but thank you both very much. Mike

United Kingdom
#11  

To be honest, when I read the code I didn't expect it to be how you wanted it. The principals of the code should remain though (i.e. the loop label and goto, the ADC part etc.). It's probably the actual movement that you aren't satisfied with but that's simply a case of adding in more steps in the code, possibly adding in more conditions for the If...

I wont re-write the code as I don't know the specifics and I'd like for you to try yourself, it'll be more rewarding. But if you do need more help just shout, that's what I'm here for:)

#12  

Hi Rich,

You're right about more rewarding. However, I've been working on the jaw sync for 8 hrs and it makes my head hurt. I just don't understand programming and the logic. Do you mind giving me more examples please? If you need more info please let me know. Thank you!

#13  

It would be great if I could get the jaw sync like the inmoov robot jaw does.

#14  

Hi again.

Here is what I have so far. :loop adc_wait(adc0, higher, 0) servo(d4,45) sleep(50) release(d4) if (getadc(adc0) < 1) servo(d4,80) endif goto(loop)

It works some what, but it moves when there is no sound out of the speaker

#15  

Sorry I posted before I was finished. The d4, 45 opens the jaw and the d4, 80 closes the jaw.

United Kingdom
#16  

When the sound is playing does the ADC value vary with the volume? I assume so however I'd like to know for sure as it could make the scripting quite different.

One method would be to write a script that just loops around the movement of the jaw, moving the servo from position 45 to 80 to 45 to 80 etc.

Then have another script which checks the ADC value with either an If(GetADC(ADC0) > 1) or with an ADC_Wait command. Once the ADC value change is detected then use a ControlCommand to start the movement script. When the ADC value is 0 (or below a small tolerance) use the ControlCommand to stop the movement script.

You may also be able to use the Auto Position control and set up a few different frames and actions which can be started and stopped with ControlCommand.

So have something like these;

Movement Script

:loop
Servo(D4, 45)
Sleep(200)
Servo(D4,80)
Sleep(200)
Goto(loop)

Detection Script

:loop
# Wait for sound to be detected
ADC_Wait(ADC0, higher, 3)
# Start the movement script
ControlCommand(&quot;Movement Script&quot;, ScriptStart)

# Wait for sound to stop
ADC_Wait(ADC0, lower, 3)
# Stop the movement script
ControlCommand(&quot;Movement Script&quot;, ScriptStop)
# Close the mouth
Servo(D4,80)

# Loop back
Goto(loop)

If your ADC value varies with volume you could have a bunch of IFs in the movement script which check the ADC value and move the servo to a different position. You could use the random number command to adjust the sleeps for random gaps to make it look a bit more realistic. There are a number of things you could do to improve the motion which I'll cover if you need it once you get the actual detection and starting of the movement sorted.

Note: it's 3:40am here, I haven't been to sleep in almost 24 hours now, I apologies if my code has any errors but if it does just check the EZ-Script manual and correct them:)

#17  

Hi Rich. Yes, when the sound plays the ADC value does vary with the volume. When the sound does play through the speakers the ADC value goes up and down. What I am seeing is the ADC value sometimes goes to zero, even when there is sound playing through the speakers. I am not sure why? Maybe it's my wiring or it's my PC AMP to my speakers and the ADC0 port, I really don't know for sure.

I tried both of your scripts you wrote and I ended up using the movement script because of the ADC value not going above zero, even when the speakers have sound going through them. I tried many combinations last night and ended up just using the movement script(s). It still misses jaw/mouth movement sometimes but it's better then it was before. See Below,,, :loop If (GetADC(ADC0) > 0) Servo(D4, 45) Sleep(100) EndIF

If (GetADC(ADC0) > 0) Servo(D4, 55) Sleep(60) EndIF

If (GetADC(ADC0) > 0) Servo(D4, 45) Sleep(50) EndIF

If (GetADC(ADC0) > 0) Servo(D4, 55) Sleep(50) Servo(D4,80) Sleep(10) EndIF

I know it's very simple for you because you know programming so well. I want to thank you for the guidance and examples you write very fast. Even when getting no sleep in 24 hours. Wow!

I am hoping the new ez v4 board will be better for the jaw/mouth movement. Because it has the built in speaker and digital, I'm not really sure on that. I will see if I can figure out how to send you a video of the mouth moving, I am not sure when that will happen. I was having trouble setting up a Youtube account yesterday and will try later.

Again many thanks for always helping and getting back very fast!

One more thing, I will try and figure out how to use the Auto Position script when I have a little more time. PS I like your tattoo. Sincerely, Mike

United Kingdom
#18  

I am here to help:) And thanks, it's my latest ink, very pleased with it so kinda having it on display everywhere:)

If sometimes the ADC is 0 for a short moment you could always write in some delay and checking to avoid that.


ADC_Wait(ADC0, equals, 0)
Sleep(500)
If(GetADC(ADC0) &gt; 0)
  # Ignore the blip in quiteness
  Goto(mainloop)
EndIf

This isn't a complete script but rather an idea and a guide to how you can add in a sleep after the ADC_Wait then check the ADC value and either accept it as quiet or decline it and say "no, keep going, it was just a blip".

Or you could use the ADC value to set the servo position. You would need to do a few calculations but it may work. The louder the sound or the higher the ADC value the more the mouth opens. While it's not an exact simulation of a mouth the effects can be pretty good.

First you would need to work out how many servo positions you have between closed (80) and open (45)

80-45 = 35

Then see how high the ADC value goes with the loudest of sounds. Do this by watching the ADC value (use an ADC control temporarily). Let's say for example it hits 125 at it's loudest.

So we have 35 positions for 125 ADC values. 125/35 = 3.5. At this point I would round that down to 3, which would mean the mouth would vary in position between ADC values of 0 to 105, anything above 105 would be fully open and the positions would be in steps of an ADC change of 3. (Hopefully this is all making sense).

So next we make the script to convert the ADC value to servo position. It's pretty a simple script.


# Get the ADC value and assign it to a variable
$volume = GetADC(ADC0)

# Ensure the ADC value doesn't cause errors by being above the max mark (105)
IF($volume &gt; 105)
  $volume = 105
EndIf

# Convert the ADC value to a servo position
$servo_position = $volume/3
# Make it an integer
$servo_position = Round($servo_position, 0)
# Convert the ADC to position by subtracting the position from the closed position (80)
$servo_position = 80 - $servo_position

A lot of that code can be combined in to a single line however, to make it easier to follow I did each step bit by bit. Extra lines of code, while unnecessary, sometimes make it easier to follow scripts.

Now we have our servo position, using either code above (I would use the first since it's easier to follow and change for future) we just need to move the servo to the correct position;

Servo(D4, $servo_position)

Then piece it all together, add in any sleeps to delay certain parts as necessary and you should have something like this;


:loop
# Get the ADC value and assign it to a variable
$volume = GetADC(ADC0)

# Ensure the ADC value doesn't cause errors by being above the max mark (105)
IF($volume &gt; 105)
  $volume = 105
EndIf

# Convert the ADC value to a servo position
$servo_position = $volume/3
# Make it an integer
$servo_position = Round($servo_position, 0)
# Convert the ADC to position by subtracting the position from the closed position (80)
$servo_position = 80 - $servo_position

# Move the servo
Servo(D4, $servo_position)

# Delay as necessary (if necessary)
Sleep(100)

# Loop back to the start
Goto(loop)

Now, what should happen is the ADC port will be read and the volume of the audio will be saved to the variable $volume.

The volume is then checked to make sure it isn't over 105, if it is it could move the servo to a position that shouldn't be available. So we check it with an IF and if the conditions are met we over ride the value to the maximum.

Then we take the volume and convert it to the correct position first by dividing it by 3 (as previously calculated), making it a round number (as you can't have decimals in servo positions) and then subtracting it from the closed position.

Then we tell the servo to move to that position.

A slight delay, if required, to stop the mouth going too mad.

The we go back and do it all over again.

I haven't checked the script. I haven't really checked if I worked it all out correctly so check it out on something which doesn't matter if the position goes to the wrong place (or above/below the max/min points) before you use it on the jaw.

#19  

Hi Rich. Now I am really confused, maybe I need to start over with Baby steps?
I need to step back to the really basics. FYI, The volume voice/jaw sync is working but could work better. I will work on that later.

I have a new question, what is the difference of the Modified servo versus Modified servo movement panel. I have 2 modified motors with gears and a worm shaft that moves. Using the arrow buttons and the stop buttons, I can move it back and forth.

I want to move both motors independently with a script I have tried the Movement script with the servo Movement control panel but it moves both motors. Is the a way to move them independently?

Please be very simple, as my brain does not seem to process this stuff very well. I dp understand most on the logic you have sent, I am just don't know all the commands? Not sure!

Also maybe I should start a new thread?

V/R Mike

PRO
Synthiam
#20  

I would recommend using the Auto Positioner for your animatronic stuff..

PRO
USA
#21  

Great video DJ. I miss these quick tuts like the ones from your basement. Just got in from Atlanta tonight to find my ezb4s waiting for me. Looking forward playing in the morning.

#22  

Thank you for the video DJ. I will play around with the Auto Position to see what happens.
Mike

#23  

while playing with the Auto Position, I noticed I can't delete a servo box. I have tired high lighting the servo box and hit my del key on my keyboard; it does not delete the servo box. I'm I doing something wrong?

Thanks

#24  

Also, when I go back into the Auto Position to add the Head UP, Neck twist no, and head tilt back and forth center and all that stuff. Then when I add a new frame the servo boxes are showing NA.

Do I need to add an Auto Position for ever movement/event. e.g. one for the eyes, one for the head, tilt, nod no, and one for the Jaw?

Thank you, Mike

PRO
Canada
#25  

Hi Mike,

I'm just wondering if you have upgraded to the most recent ARC?

Deleting a servo has now been fixed in the newest version, I just verified it.

To keep the servo positions you've initially generated you will have to select that pre-made frame and then click new frame, name it, and then select it the new frame on the list of frames. This will keep the servo positions you made in the last frame and allow you to change them as needed for your action.

Just in case you haven't come across it yet, in order to see all the port numbers use the "Port Edit Mode" check box.

For every event you'd like to execute you can either generate an new "Action" or you can execute a script with multiple frames or actions in it.

An alternate way would be to use a script inside an Action, just click on the "edit script" button near the top right of the action screen.

#26  

I download the newer ez_builder and it seems better. I want to thank everybody for your input and guildandce. I am gvoing to be away for my project for a couple of days.

Thanks everyone, as always v/r Mike