Asked — Edited

Building A Slave System

Hello all. A few questions here. I'm building a POC. And i need a little info and some help.

Is it possible to add 8 pots to the ADC ports and control 8 servos?

I'd like to build a slave system to control something. The idea is I have a contraption that I use that has pots located at joints, as i move the pots the servos move with the input from the pots.

I've looked around and found several threads on how to connect the pots to the ADC ports, but I cant seem to find any code to help me use the pot data to directly control the servos.

Also is there a way to add more ADC ports short of adding another EZB?


ARC Pro

Upgrade to ARC Pro

Unlock the true power of automation and robotics by becoming a proud subscriber of Synthiam ARC Pro.

PRO
Synthiam
#1  

Take the pcb out of a Servo. Just like the other conversation thread you were involved in about linear actuator.

PRO
Canada
#2  

Hi Will,

Yes, you can definitely add 8 potentiometers to the 8 ADC ports to control 8 servos. You will need to attach one side of the potentiometer to GND and the other side to 3.3V and the wiper will go to the ADC port. Replicate this wiring for each potentiometer.

Here's some example code to control one servo with a potentiometer:


:loop

$a = GetADC(adc0) #signal between 0-3.3V represents 0-255 value

$b = Map($a, 0, 255, 1, 180) #scale 0-255 value to 1-180 degrees

Servo(D0, $b)

Sleep(300)

goto(loop)

If you want to add more ADC ports I believe there are I2C to ADC solutions out there but I haven't had any experience with them.

PRO
USA
#3  

That wont work as i have $1200 worth of servos to test with and will be sending some back to the store. I'd rather not dismantle them and void them from return.

By using the ADC I have the choice of using rotational pots, slider pots and flex pots, and or mix and match.

I just found this 6 year old thread. My project is similar to the video he posts #7, but way more involved.

https://synthiam.com/Community/Questions/285

PRO
USA
#4  

@jeremie Thank you. Exactly what i need.

PRO
Synthiam
#5  

Oh geez - I totally read that wrong. Yes, jeremie is correct and what i said is not valid at all. My suggestion would have been turning a motor into a servo, and you want to control servos with pot.

Use jeremie's suggestion...

You might find a bunch of jitter with the pot - in which, i can whip up a kalman filter plugin for you. It's something i've been meaning to do anyway...

PRO
USA
#6  

Ok cool! I'll let you know how it goes!

PRO
Synthiam
#7  

I edited jeremie's code.. and repasted it here below. Doing a variable comparison in the repeat would cause additional processing vs having a goto loop. So i added that. I also collapsed the code to one line so it's not assigning variables and using extra memory...


:loop

# ADC signal between 0-3.3V represents 0-255 value
# MAP converts the adc scale 0-255 value to 1-180 degrees

Servo(D0, Map(GetADC(adc0), 0, 255, 1, 180))

Sleep(300)

goto(loop)