Can i send live data from pc to arduino+servo?

I would like to connect an arduino (which I'll buy, probably "uno") to a 12V servo motor which has an encoder too,

basically I have 2 questions:

  1. is it possible to send live data to the arduino and get the live feedback to the PC and have a windows program to manage the motor movements and corrections upon a preprogramed movement plan?

  2. do i have to have a motor shield for me to run a 12V servo? what is the advantage of a motor shield besides the more convenient connections?

Thanks a lot! :)

  1. define live ?

  2. Shields are “condensed best practices” Not necessary but they can make life easier as they often are accompied with libraries, tested with examples etc.

Note Arduino has no 12V you need addition power supply.

  1. As Rob says "define live", but yes, in principle there's no problems doing this.

  2. The Arduino has servo libraries so all you really need is a connection to the servo's control wire.

Question, the servo may be 12v but does it need 12v on the control wire?

If so you need to level shift your Arduino output with a transistor, if not you may be able to drive it directly.


Rob

thanks for the help guys,

by "live" i mean real-time, and not by uploading code to the arduino for every plan and have it do whatever it has to and for another plan of movements I would have to upload again and so on..

and I don't mean by any primitive way of control from the PC, I mean a more sophisticated one, like i wouldn't want to have just a graphic potentiometer on the PC screen and move the motor's shaft around by moving my mouse, I would like to send an array of numbers to the arduino to move the motor's shaft by them and if there is something wrong with the position, to have the encoder send the data to the arduino that will send the data to the PC and display it and send correction command back in the chain to the motor..

does that make sense? is it possible?

as for the servo motor, i didn't buy it yet so i am not sure if i will need a 12V for the control wire, but i understand what you are saying, and i was assuming i will need an additional psu..

Thanks a lot!!

Roy.

and I don't mean by any primitive way of control from the PC, I mean a more sophisticated one,

does that make sense? is it possible?

I don't see any drama doing that, you'll have to come up with a protocol and implement some hysterisis in the control loop.

and i was assuming i will need an additional psu..

You will need something external to the Arduino to power the servo, however if you're running the Arduino from 12v then use the same PSU for the servo.


Rob

great! thanks for the help!

then I'll get myself an "uno"!

however if you're running the Arduino from 12v then use the same PSU for the servo.

even if it's running on higher current? what will happen if the motor will consume a lot of current in a peak? i assume the arduino has its protection but is it harmless for it in the long run?

you'll have to come up with a protocol and implement some hysteresis in the control loop.

does that mean like a protocol which i will program myself? or a premade, lower-level one? and if so could you recommend me of one? or just give me a direction..

Thanks again!

Roy. :)

even if it’s running on higher current? what will happen if the motor will consume a lot of current in a peak?

Peaks in current can be absorbed by capacitors near the servo. Apart from that just have a PSU large enough to do both Arduino and servo.

does that mean like a protocol which i will program myself?

Probably, I don’t know offhand of a simple protocol available although this problem pops up here about 5 times a week :slight_smile: so there may be.

It’s pretty simple though, something like PC sends <123>, Ard receives that and sets the servo to 123 degress or whatever. Ard responds with say for OK or for error. Or maybe returns the value from the encoder as a check (after a predetermined amount of time for the servo to get there).

The <> chars are just to delimit the frame so each end can know they are in sync with the other end and also provide a tiny amount of error detection.

If the application is important then maybe some error checking on the data, and failsafes like the Arduino centres the servo if no orders for x seconds etc.


Rob

does that mean like a protocol which i will program myself?
or a premade, lower-level one? and if so could you recommend me of one? or just give me a direction…

A protocol is a set of defined signals over a line. Between the PC and Arduino you could use a serial line (USB cable) as the carrier.
The defined signals can be a string like <servo 1 20> which could mean that servo 1 goes to position 20. Because Servo is such a long word you may abbreviate it to <S 1 20> . The Arduino can signal back or just

Note that I write the strings in <>. These are added to the commands to let the arduino know that all character of a command are received or that a new command is beginning.

There are many examples on this forum for similar protocols. There is also a message library that may be very useful for you.

@rob
You were faster!

Do I get a prize? :)


Rob

That's another thread, mail @ 12:00 PST to some shield manufacturer :)

Thanks a lot everybody!!! you rock!!!