Hello everyone,
I want to control a hardware synthesizer's knobs and faders using mountable electric servos controlled by my Ewolverine patch to breed sounds out of them.
How can I convert numbers into robotic movements? Anyone an idea?
Best
Elden
How to control an electric servo using pd?
Hello everyone,
I want to control a hardware synthesizer's knobs and faders using mountable electric servos controlled by my Ewolverine patch to breed sounds out of them.
How can I convert numbers into robotic movements? Anyone an idea?
Best
Elden
What do you mean exactly by "How can I convert numbers into robotic movements?". Servos take numbers (bytes). Can't understand your question.
Well, I just don't know, where to start! I have numbers that normally go to the MIDI output - now I want them to control servos.
How do you plan to do it? With an Arduino? If so, you'll need [comport]. Servos take bytes iirc, so you'll need to convert your number ranges to that of one byte (0-255) and send it to [comport] (make sure you convert them to ints with [i ] before you send them to [comport]).
If you have multiple servos you want to control, you'll need to separate them in your code. What I do in Arduino is use letters to separate the values. So the code is something like this:
if(Serial.available()){
static int temp_val;
byte in_byte = Serial.read();
if((in_byte >= '0') && (in_byte <= '9'))
temp_val = temp_val * 10 + in_byte - '0';
else if((in_byte >= 'a') && (in_byte <= 'z')){
int which_servo = in_byte - 'a';
analogWrite(servo_pins[which_servo], temp_val);
temp_val = 0;
}
}
Put the code above in your loop() function.
Of course you need to define an array with the pins of the servo motors (here it's called "servo_pins") for this code to work.
Then in Pd I send messages of the type "print $1a" for the first servo, "print $1b" for the second, etc.
Hope this helps.
Ok, so I'd have to have a kind of PC-to-servo interface first, right? (Arduino maybe)
And then I plug a servo into it und can then control it using your code and that's it?
Yes. You can use Pduino:
You can use Pduino if you want, but you can also use [comport] straight ahead. As I mentioned, the code I posted is supposed to be integrated into an Arduino sketch. Now the Arduino IDE includes the two main functions, setup() and loop(). All you need to do is place the code above in the loop() function and declare the servo_pins array with the pins of the servos. If that is done, the code will work.
And then I can do things like this, yes?
Yup, all you need to do is map the incoming MIDI values to the servo pins (using successive letters in the case of my example).
Perfect. Thanks!
One question again:
I need to adjust servos digitally by showing them their left and right limits-
Can I make pd learn servo positions if I turn the motor myself?
What do you mean "turn the motor yourself"? To manually turn its gear? I don't think that servos provide any feedback as to what position they are at?
I do think that servos always go to their center position when power initially goes on. Knowing this, plus bearing in mind that they take degrees from 0 to 360 iirc, then you know you should start from the value 180 and up to 360 and down to 0. But I might be missing something here.
The thing is, that I need to make pd learn where the limit left/right positions of synth knobs are, the servo shall adjust. To do that, the servo needs to provide feedback as to what positions they are at. Do you know of some servos that are able to send position data to pd?
@elden you can do that in Pd if you read the outputs from the potentiometers to which you have mechanically attached the servo motors.........
As @alexandros says..... the servos themselves just "know" exactly where they are...... but provide no feedback.
David.
OK, but the potentiometers of analogue synthesizers or modular units don't send output data or do they somehow?
@elden Do they send midi values? Maybe not, in which case you will just have to rely on the servos knowing exactly where they are and calibrate your patch accordingly...... trial and error!
Or use a small microcomputer (rpi, arduino etc.) to collect the analogue voltages.
I am assuming that the servos are in fact stepper motors?!? and so very position accurate...
David.
No, the synths are not sending back MIDI data to pd. I didn't buy the servos yet, so I'm actually wondering which servos would be best.
Maybe I can let pd know the servo limits via an option for the user to callibrate them from inside pd. Thanks a lot for advices and all to you guys!
not what you are doing but
https://duckduckgo.com/?q=midi+to+cv
@0123456789_9876543210 Yes, I thought of using something like this, but I guess that if I want to control really old synths from PC, I need to do this using servos that adjust their knobs and faders etc. . Thanks!
I think you worry for no reason, because as I told you, the servos go to their middle position when they are initially powered up. Plus, they don't work like stepper motors, meaning that they don't do more than one revolution. When they do a full revolution they reach their limit and stop.
What you probably want is to save the values you send to the servos inside Pd, so the next time you open your patch you can send these values and set your servos as you wish.
Well, the problem is that I need to scale the output values for each parameter of my pd-patch Ewolverine to the maximum rotation angle of each knob of the hardware synthesizers, so that the sound breeding process can function acurately. Therefor pd needs to know where the servo movements can stop without breaking the synth knobs or inacurately adjusting those, you know?
Oops! Looks like something went wrong!