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

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

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)

PRO
Canada
#9  

Thanks @DJ, we all know that I'm more of a hardware guy lol

PRO
USA
#10  

oOo weee. Them thar are some chunky moves. I would definitely be grateful for a kalman filter plugin, if it cleared up the pulsing.

Would the type of pot make any difference? I have here a 10k and 1k ohm rotating pots both produce about the same results.

Also I'm using a HDD servo and the IO tiny

Lastly in this script would I be able to replace a digital port with support for a virtual port for Dynamixels?

PRO
Canada
#11  

The value of the potentiometer won't matter but the physical size will. The larger the size the better (finer) resolution you will get. A multi turn pot would likely be more ideal.

Yes, you can do the same with Dynamixels.

PRO
Synthiam
#12  

Try removing or lowering the sleep() value in the script loop. I don't know what "chunky moves" means - but if chunky means "jerky", then you'd want a faster refresh.

PRO
USA
#13  

Ok I’ll play with the values a bit. Video is worth a thousand words, if I can’t get it to smooth out the moves I’ll shoot a little video so you can see chunky moves, I know not a very good adjective. :)

PRO
USA
#14  

Thanks on the info Jeremie. Good to hear about the dynamixels and I do have thoose larger pot, I'll look into a mutiturn pot!

PRO
USA
#15  

@DJ, removing the sleep completely, fixed the problem, smooth as butter. As always thanks fellas!

edit: On second observation, maybe not. It could be this pot. Seems to be several a dead zones, where its moving, then it stops then it tries to quickly move and catch up. Hard to do fine motion. Maybe there needs to be some kinda sleep in there.

PRO
Canada
#16  

Yeah Will, I think you'll need a bit of a sleep in there maybe try Sleep(25) and move up from there if needed.

PRO
USA
#18  

Awesome! Thanks will give it a go this morning.

PRO
USA
#20  

Amazing as always! I’m concentrating on trying to find a better series of pots. I’ve ordered several from amazon.

I favor the mean filter, on 8 with a 25 sleep. Very smooth on the micro servo I tested with. I have like 2 dead zones that I think are related to the pot I bought. Just a cheap $1 pot.

PRO
Synthiam
#21  

Have you tried the complimentary filter as well? The dampening value is a percentage, and you might find it's quite flexible as well.

PRO
USA
#22  

Yes I tried both. Can these be stacked or use one or the other?

PRO
Synthiam
#23  

I sure wouldn't stack - if you think about what they do... You can, because they're commands. And as you learn programming, commands can be used anyway you wish. You can learn more about programming using the robot program found in the learn section - Professor E has a great video on variables, loops and logic.

There's an update to the complimentary filter which allows custom dampening to be applied as an optional parameter. It's documented in the help displayed of the plugin.

#25  

I sure wish DJ would include the source code for the Amazing plugins he creates!

Please? :D:D:D

#26  

Quote:

I sure wish DJ would include the source code for the Amazing plugins he creates!

Many of the EZ-Robot plugins do have source code available on the plugin page.

Here is the list of what I found. I thought the Bing speech Recognition one was as well, but I don't see the link. It was in a discussion thread a few weeks ago.

SMTP https://synthiam.com/redirect/legacy?table=plugin&id=128 Dynamixel https://synthiam.com/redirect/legacy?table=plugin&id=39 Display Popup https://synthiam.com/redirect/legacy?table=plugin&id=17 TicTacToe https://synthiam.com/redirect/legacy?table=plugin&id=6 Screen Recorder https://synthiam.com/redirect/legacy?table=plugin&id=38 Command Duplicator https://synthiam.com/redirect/legacy?table=plugin&id=165 User Defined Function https://synthiam.com/redirect/legacy?table=plugin&id=162 Remote Mouse https://synthiam.com/redirect/legacy?table=plugin&id=37 TCP Client https://synthiam.com/redirect/legacy?table=plugin&id=48 Augmented Reality https://synthiam.com/redirect/legacy?table=plugin&id=50 Oculus Rift Camera https://synthiam.com/redirect/legacy?table=plugin&id=59 Connectoin Diagnostic https://synthiam.com/redirect/legacy?table=plugin&id=64 Camera Click Servo https://synthiam.com/redirect/legacy?table=plugin&id=58 Camera Overlay https://synthiam.com/redirect/legacy?table=plugin&id=47 Target Overlay https://synthiam.com/redirect/legacy?table=plugin&id=51

Alan