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.

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