Maker Pro
Maker Pro

Driving servos from a PC

P

Pete Verdon

Jan 1, 1970
0
As part of a construction project for a charitable event, I need to
build a number of big analogue dials (like an old-fashioned voltmeter)
controlled by a series of PCs (each computer drives two dials). Accuracy
isn't critical, but I do have a fairly strict budget restriction.

One possibility seems to be to use an RC servo to move a big cardboard
needle. I've not used servos before, but a little research suggests that
the required position is commanded by altering the pulse width of a ~5v
50Hz square-wave signal a little either side of 2ms.

As I said, I don't have much of a budget. I also have limited
electronics knowledge. But is it totally unrealistic to consider
controlling these servos via a soundcard output? I envisage putting one
dial on each of the left and right channels, and getting the card to
spit out an appropriate wave-form to each of them. I realise this won't
be a proper square-wave, but am I likely to get close enough?

What else have I missed? Do you have another (cheap) suggestion, whether
involving servos or not?

Thanks,

Pete
 
M

Michael Black

Jan 1, 1970
0
Pete said:
As part of a construction project for a charitable event, I need to
build a number of big analogue dials (like an old-fashioned voltmeter)
controlled by a series of PCs (each computer drives two dials). Accuracy
isn't critical, but I do have a fairly strict budget restriction.
Why not pull some stepping motors out of junked inkjet printers (or dot
matrix printers for that matter, though nowadays I find the former more
likely to be found as junk), and use those? They would obviously be
cheap and avaialble (you aren't likely to find RC servos lying in the
garbage), and the driving is easy. Use a parallel port. Or, if
this is from a dedicated computer, find an older one with an ISA bus,
and put two parallel ports in there for more control lines. Some counter
ICs would shift the needed control to hardware, and then it would only
need a direction line and step line from the parallel port for each stepping
motor. (They work by sending pulses to the windings of the motor, and each
pulse makes the motor step one step; the direction is determined by which
of the two windings you send the pulse to first.)


Michael
 
N

Nospam

Jan 1, 1970
0
The message <[email protected]>
As part of a construction project for a charitable event, I need to
build a number of big analogue dials (like an old-fashioned voltmeter)
controlled by a series of PCs (each computer drives two dials). Accuracy
isn't critical, but I do have a fairly strict budget restriction.
One possibility seems to be to use an RC servo to move a big cardboard
needle. I've not used servos before, but a little research suggests that
the required position is commanded by altering the pulse width of a ~5v
50Hz square-wave signal a little either side of 2ms.
As I said, I don't have much of a budget. I also have limited
electronics knowledge. But is it totally unrealistic to consider
controlling these servos via a soundcard output? I envisage putting one
dial on each of the left and right channels, and getting the card to
spit out an appropriate wave-form to each of them. I realise this won't
be a proper square-wave, but am I likely to get close enough?
What else have I missed? Do you have another (cheap) suggestion, whether
involving servos or not?

Pete

Hi Pete

I stand to be corrected but I don't know of any simple way that you can
interface a servo to a sound card, let alone two.

servos would be good but might be a little over kill, why only two to
each PC? Could you use one PC for upto eight?

if so some ideas to make your own servo controller at:

http://www.rentron.com/SerialServo.htm

or buy

http://www.britishrobotics.com/pictures/BRCandice/BR650290Desc.htm

I have the original SSC version two at http://www.seetron.com/ssc.htm

Cannot for the life of me remember where I bought it in the UK, and have
also built the first one, both are ideal for controlling multiple servos
and very easy to programs for the serial ones. Cannot comment on the usb
ones you may find.

I will try and remember where I bought the kit from, hope this helps

Pete
 
J

jasen

Jan 1, 1970
0
As part of a construction project for a charitable event, I need to
build a number of big analogue dials (like an old-fashioned voltmeter)
controlled by a series of PCs (each computer drives two dials). Accuracy
isn't critical, but I do have a fairly strict budget restriction.

One possibility seems to be to use an RC servo to move a big cardboard
needle. I've not used servos before, but a little research suggests that
the required position is commanded by altering the pulse width of a ~5v
50Hz square-wave signal a little either side of 2ms.

As I said, I don't have much of a budget. I also have limited
electronics knowledge. But is it totally unrealistic to consider
controlling these servos via a soundcard output?

not entirely, but unless you need PC control it'd be easier to just
use a 555 and a pot for each.

variable duty-cycle cicuit:

----+--- vcc
|
.----------------------|--------+
| | |
| +--------+ |
V | | |
.--[POT]-->|--. | . . . .|. . . . |
| | | . VCC(8) . |
| | | . . |
`---------|<--+ +--RES(4) OUT(3)--+--> out
| . 555 .
+-------TH(6) DIS(7)----
| . .
+-------TR(2) CV(5)--
C1 | . .
===== . GND(1) .
| . . . .|. . . .
| |
+-------------+
|
---+-- gnd
 
S

Si Ballenger

Jan 1, 1970
0
As part of a construction project for a charitable event, I need to
build a number of big analogue dials (like an old-fashioned voltmeter)
controlled by a series of PCs (each computer drives two dials). Accuracy
isn't critical, but I do have a fairly strict budget restriction.

One possibility seems to be to use an RC servo to move a big cardboard
needle. I've not used servos before, but a little research suggests that
the required position is commanded by altering the pulse width of a ~5v
50Hz square-wave signal a little either side of 2ms.

As I said, I don't have much of a budget. I also have limited
electronics knowledge. But is it totally unrealistic to consider
controlling these servos via a soundcard output? I envisage putting one
dial on each of the left and right channels, and getting the card to
spit out an appropriate wave-form to each of them. I realise this won't
be a proper square-wave, but am I likely to get close enough?

What else have I missed? Do you have another (cheap) suggestion, whether
involving servos or not?

A servo controller like below is your best bet.

http://www.pololu.com/products/pololu/0207/index.html
 
C

Chris

Jan 1, 1970
0
Pete said:
As part of a construction project for a charitable event, I need to
build a number of big analogue dials (like an old-fashioned voltmeter)
controlled by a series of PCs (each computer drives two dials). Accuracy
isn't critical, but I do have a fairly strict budget restriction.

One possibility seems to be to use an RC servo to move a big cardboard
needle. I've not used servos before, but a little research suggests that
the required position is commanded by altering the pulse width of a ~5v
50Hz square-wave signal a little either side of 2ms.

As I said, I don't have much of a budget. I also have limited
electronics knowledge. But is it totally unrealistic to consider
controlling these servos via a soundcard output? I envisage putting one
dial on each of the left and right channels, and getting the card to
spit out an appropriate wave-form to each of them. I realise this won't
be a proper square-wave, but am I likely to get close enough?

What else have I missed? Do you have another (cheap) suggestion, whether
involving servos or not?

Thanks,

Pete

Hi, Pete. You already have the capability in your parallel printer
port -- output logic level signals. You can also use the PC to supply
5V power for the servo. But the devil is in the details.

You didn't mention the other jobs you're having the computer do, or
even what operating system you're using or what programming language.
If you're using DOS and your PC isn't doing anything else, you can just
set your printer port for SPP in the BIOS and then use QBASIC or
anything else that provides direct control of the PC's ports to program
a timing loop to output the pulses (which are supposed to be 5V logic
level, positive-going pulses, 1-2ms. pulse width every 20ms). Voilla
-- done. Additional cost = zero.

If you've got other things to do with your program, or if you're using
Windows, it gets a little stickier. That's because the servo turns off
unless it gets at least one pulse every 30ms. or so. Using Windows,
you'll need help with DLLs and drivers.

You might want to try going to the Jan Axelson/Lakeview Research
website for more information. Chances are you'll find what you need
there (and you might want to get a copy of the book "Parallel Port
Complete", provided with a CD that has the support software for various
languages).

http://www.lvr.com/parport.htm

Good luck
Chris
 
P

Pete Verdon

Jan 1, 1970
0
Michael said:
Pete Verdon ([email protected]) writes:
Why not pull some stepping motors out of junked inkjet printers (or dot
matrix printers for that matter, though nowadays I find the former more
likely to be found as junk), and use those?

It seems unlikely that I would find six of them. However, I can buy
packs of servos remarkably cheaply from some outfit advertising on eBay.


Pete
 
P

Pete Verdon

Jan 1, 1970
0
Nospam said:
I stand to be corrected but I don't know of any simple way that you can
interface a servo to a sound card, let alone two.

I don't see that two is any harder than one, given that I have a stereo
channel to play with. Exactly how hard *one* is, of course, is something
I came here to find out :)
servos would be good but might be a little over kill, why only two to
each PC? Could you use one PC for upto eight?

The event is actually three identical events running at the same time,
each with two dials. It's not inconceivable that I might drive all three
pairs of dials from a single computer and have the machines running the
other two events talk to it over a network, but I'd much prefer to have
them independent. They may in fact be running in different rooms.
if so some ideas to make your own servo controller at:

http://www.rentron.com/SerialServo.htm

Thanks. I don't know why I didn't think of using the serial port before
- clearly much more sensible than the soundcard!

Pete
 
P

Pete Verdon

Jan 1, 1970
0
not entirely, but unless you need PC control it'd be easier to just
use a 555 and a pot for each.

I do need PC control. These dials will be part of the output for a
simulation program running on a PC.

Pete
 
P

Pete Verdon

Jan 1, 1970
0
Not a square wave. They need a pulse between 1 to 2mS long (depending on the
position) repeated about 50 times a second.

That's effectively what I wrote, isn't it? I suppose it's not quite a
square wave because it's cut off at zero rather than going below, but
presumably that just calls for a suitable diode.
I believe most people use a PIC micro to interface servos to a PC - possibly
because a PC running Windows doesn't have the real time capability to do it?

True; I hadn't considered the "real time" aspect of the problem, which
would presumably frustrate any attempts to drive them directly from a
serial port as well. But I don't think I have a) the knowledge and b)
the budget to start programming embedded chips.

Pete
 
P

Pete Verdon

Jan 1, 1970
0
Chris said:
Hi, Pete. You already have the capability in your parallel printer
port -- output logic level signals. You can also use the PC to supply
5V power for the servo. But the devil is in the details.

Yes, I'm not sure why I didn't immediately think of serial/parallel
ports. I suppose the idea of frequencies and waves put the idea of the
soundcard into my head.
You didn't mention the other jobs you're having the computer do, or
even what operating system you're using or what programming language.

The OS and language are flexible to some degree. The core of the system
will almost certainly be in Java (the servos are just an output device)
but we're prepared to call out to C for talking to hardware. I don't
know whether we're looking at Linux or Windows as an OS; nothing we've
yet decided on has mandated either.
If you're using DOS and your PC isn't doing anything else, you can just
set your printer port for SPP in the BIOS and then use QBASIC or
anything else that provides direct control of the PC's ports to program
a timing loop to output the pulses (which are supposed to be 5V logic
level, positive-going pulses, 1-2ms. pulse width every 20ms). Voilla
-- done. Additional cost = zero.

Unfortunately we're not going to be at a low enough level that we have
total control of the processor. The machine's display is also going to
be used for graphical output, which effectively means Windows or X.
If you've got other things to do with your program, or if you're using
Windows, it gets a little stickier. That's because the servo turns off
unless it gets at least one pulse every 30ms. or so. Using Windows,
you'll need help with DLLs and drivers.

I'm a software engineer in my day job, and working with another on this
project. I don't normally get all that close to the hardware, but it's
not inconceivable that we might be able to knock something up.
You might want to try going to the Jan Axelson/Lakeview Research
website for more information. Chances are you'll find what you need
there (and you might want to get a copy of the book "Parallel Port
Complete", provided with a CD that has the support software for various
languages).

Thanks.

Pete
 
J

jasen

Jan 1, 1970
0
Yes, I'm not sure why I didn't immediately think of serial/parallel
ports. I suppose the idea of frequencies and waves put the idea of the
soundcard into my head.


The OS and language are flexible to some degree. The core of the system
will almost certainly be in Java (the servos are just an output device)
but we're prepared to call out to C for talking to hardware. I don't
know whether we're looking at Linux or Windows as an OS; nothing we've
yet decided on has mandated either.

if you can set baud rate divisor directly that'll give provide acurate
control of pulse widths without being worried by multitasking operating
systems.

attempting software PWM will be succeptable to losing multitasking,
but may be accurate enough,

linux has usleep() and nanosleep() for making delays measured in
microseconds or nanoseconds, accuracy is probably closer to +/- 10
microseconds most of the time (depecding on what else the computer is
doing and how fast the processor is)

windows has Sleep(), which delays for a number of miliseconds, but there
may be something more precise.

with a little hardware you could drive any number of 8-bit DACs from a
parallel port (or a single DAC and a number of sample-and-hold circuits)
this wouldn't have the tight timing requirements of the software PWM.

these analogue voltages could then be used to either generate a PWM signal
(by comparing them to a triangle wave) or to directly drive a moving-coil
meter.

as has been said, two output pins (and a few transistors) are suffucuent
to control a stepper motor another option you should consider.

you can easily control five from a single printer port,
Unfortunately we're not going to be at a low enough level that we have
total control of the processor. The machine's display is also going to
be used for graphical output, which effectively means Windows or X.

you'll be hit by multitasking in that case, this could cause late, or
stretched pulses on with software PWM - something you probably don't want.
I'm a software engineer in my day job, and working with another on this
project. I don't normally get all that close to the hardware, but it's
not inconceivable that we might be able to knock something up.

the sound card is still looking good, if you can load your PWM waveform into
the wavetable and play it continuously it'll only need a little filtering to
undo the 10Hz high-pass typical of most soundcard outputs and recover the DC
component of the pwm
 
Top