EmbeddedRelated.com
Forums

Pic speed controller

Started by Lez July 30, 2005

Hi, I have not programmed a pic in years, since about 99 when the 16cf84 was
the most used around, and even then it was for simple slow things, ie
door / window open-close etc with limit switches so no great master
pieces. (oh and the usual light flashers for the kids)

I now need to build a motor speed control, the motor is to be controlled
by a servo(standard pwm as used in RC cars etc) driven speed controller,
with an inductive pickup to sense the speed, from about 100 to 4000 rpm.

I can easily get a nice square wave from the pickup.

I need to be able to control the motor with a series of switches:

1) Start control and maintain current rpm
2) go faster
3) slow down
4) STOP! (active high) stop pwm output
5) STOP! (active low) stop pwm output I would also like an output of current pwm value on 3 lines that can
drive a 3 to 8 line converter to run 8 led's to give a remote indication
of the servo position.

If the speed cant be maintained, ie pwm0% for say more than 30
seconds, it should bleep for a few seconds and power down.

If speed cant be decreased after trying for more than 60 seconds, it
should power down, and bleep a piezo for a few seconds then standby. Also I would like to be able to send a serial command to it to set a
certain rpm and to query the rpm

I think I can do most of this myself, except for the last bit, the
serial data, but I could live without it, problem is the pwm must be
maintained nearly all the time, although provided servo power is removed
before pwm, it should not move the servo (and hopefully not jump about
when power is re-applied). I think turning it off for a second should be
ok as the motor should not run away in 1 second, this would allow switch
polling to take place. (4 & 5, stop!, need to be polled much faster though)

I thought maybe a 16f88 ? (hope my old 84 programmer can do these)

I just ordered some of these to build a serial to relay board and a
serial input board, so any ideas about the serial would be welcome! Lez.


--- In piclist@picl..., Lez <lez.briddon@n...> wrote:
>
> Hi, > I have not programmed a pic in years, since about 99 when the 16cf84
was
> the most used around, and even then it was for simple slow things, ie
> door / window open-close etc with limit switches so no great master
> pieces. (oh and the usual light flashers for the kids)
>
> I now need to build a motor speed control, the motor is to be
controlled
> by a servo(standard pwm as used in RC cars etc) driven speed
controller,
> with an inductive pickup to sense the speed, from about 100 to 4000 rpm.
>
> I can easily get a nice square wave from the pickup.
>
> I need to be able to control the motor with a series of switches:
>
> 1) Start control and maintain current rpm
> 2) go faster
> 3) slow down
> 4) STOP! (active high) stop pwm output
> 5) STOP! (active low) stop pwm output > I would also like an output of current pwm value on 3 lines that can
> drive a 3 to 8 line converter to run 8 led's to give a remote
indication
> of the servo position.


Can you offer a little more details here ? I am familiar with DC
motors that have posistion feedback and run at high speed. For CNC
stuff, these are called servos.

I am also familair with small hobby devices that move some very
limited travle of less than one revolution. these are also called
servos and are used for things like steering in robots and such.

It appears you are talking about something similar by having a
posiston feedback but also a fully rotating unit that will be moving
over some minutes.

Dave


Dave,
I think it is safe to say that it is "dangerous" to start messing with feedback (closing the loop)...
May work ok if you'll accept very slow response and low precision.
In some cases one can get away with the simplest loop possible; measure speed, compare it
to desired speed, and drive the motor in the correct direction with the amplified difference.
But you won't get any real performance from such a simple scheme ...either the speedholding
capability is inadequate, or if you turn up the loop gain the system starts oscillating.

If you want feedback and both speed AND precision things get much much more complicated,
typically some PID algorithm is needed to stabilize the loop to get speed, precision and power at the same time.

My latest PIC project actually was such a (modified) PID motor control. And I must say it is impressive to
see a 200oz DC motor running at 1K RPM comming to a dead stop in less than 10mS, and with less than
20deg (200 counts) overshoot !

Just Google for something like "pic dc motor control", should turn up hundreds of interesting results.
 
 

Dave Mucha wrote:

 --- In p...@yahoogroups.com, Lez <lez.briddon@n...> wrote:
>
> Hi,
>
>
> I have not programmed a pic in years, since about 99 when the 16cf84
was
> the most used around, and even then it was for simple slow things, ie
> door / window open-close etc with limit switches so no great master
> pieces. (oh and the usual light flashers for the kids)
>
> I now need to build a motor speed control, the motor is to be
controlled
> by a servo(standard pwm as used in RC cars etc) driven speed
controller,
> with an inductive pickup to sense the speed, from about 100 to 4000 rpm.
>
> I can easily get a nice square wave from the pickup.
>
> I need to be able to control the motor with a series of switches:
>
> 1) Start control and maintain current rpm
> 2) go faster
> 3) slow down
> 4) STOP! (active high) stop pwm output
> 5) STOP! (active low)  stop pwm output
>
>
> I would also like an output of current pwm value on 3 lines that can
> drive a 3 to 8 line converter to run 8 led's to give a remote
indication
>   of the servo position.
 

Can you offer a little more details here ?  I am familiar with DC
motors that have posistion feedback and run at high speed.  For CNC
stuff, these are called servos.

I am also familair with small hobby devices that move some very
limited travle of less than one revolution.  these are also called
servos and are used for things like steering in robots and such.

It appears you are talking about something similar by having a
posiston feedback but also a fully rotating unit that will be moving
over some minutes.

Dave
 
 


--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
 

--- In piclist@picl..., Eirik Karlsen <eikarlse@o...> wrote:
> Dave,
> I think it is safe to say that it is "dangerous" to start messing with
> feedback (closing the loop)...
> May work ok if you'll accept very slow response and low precision.
> In some cases one can get away with the simplest loop possible; measure
> speed, compare it
> to desired speed, and drive the motor in the correct direction with the
> amplified difference.
> But you won't get any real performance from such a simple scheme
> ...either the speedholding
> capability is inadequate, or if you turn up the loop gain the system
> starts oscillating.


Not necessarialy. If you look at the treadmill SCR drives, or pretty
much any of the 1hp SCR drives, they have a sense resistor across the
motor output to help determine the motor operation. the output of the
controller is really noisy. it jumps around so much that measuring it
is almost useless. I think it might be like measuing the voltage of a
PWM signal. it is either 5v or 0v and has little relation of the average.

I agree 100% that once you start down the road of monitoring and
controlling, the complexity starts to expand. My applicatios in machine control use the feedback to maintain speed
to a percent or less. And when the rotatinal posistion is used, for
threading or some such, one can move the tool to cooresond to the
speed instead of trying to regulate speed more accuratly.

Dave





Dave Mucha wrote:
> Can you offer a little more details here ? I am familiar with DC
>


Ahh sorry did not know that other servo's where called servo's, if you
see what I mean.

In the design I will have to come up with I will be controling the
motors speed with an rc servo linked with a gear to the main speed
control ,these servos have a (I believe) a 10-90% pwm at 20ms.

Its the serial bit that worries me, I have found an old 16f84 so I will
hunt out the programmer and start to play soon, shame I will have to
start with picbasic, I knew all that time ago I should have learned pic
assembler.


--- In piclist@picl..., Lez <lez.briddon@n...> wrote:
>
>
> Dave Mucha wrote:
> >
> >
> >
> > Can you offer a little more details here ? I am familiar with DC
> > Ahh sorry did not know that other servo's where called servo's, if you
> see what I mean.
>
> In the design I will have to come up with I will be controling the
> motors speed with an rc servo linked with a gear to the main speed
> control ,these servos have a (I believe) a 10-90% pwm at 20ms.

So, it sounds like you want to use the servo to spin a pot or some such ? > Its the serial bit that worries me,

There are a couple serial ways to go, SPI and I2C being the most common.

What do you need the serial to do ?

>I have found an old 16f84 so I will
> hunt out the programmer and start to
> play soon, shame I will have to
> start with picbasic, I knew all
> that time ago I should have learned pic
> assembler.

PIC-basic might be a lot easier for the serial parts than you think.

Dave




Dave Mucha wrote:

>>>Can you offer a little more details here ? I am familiar with DC

>>Ahh sorry did not know that other servo's where called servo's, if you
>>see what I mean.
> > So, it sounds like you want to use the servo to spin a pot or some such ?
>
Pull a throttle arm.

Best way for me to control is to use a model RC servo, rebuilt so it can
pull with a bit more force, on to the original motors speedcontrol,
which is a mechanical throttle arrangement. >
>
>>Its the serial bit that worries me, > There are a couple serial ways to go, SPI and I2C being the most common.
>
> What do you need the serial to do ?
>

I want to be able to work the pic via serial, to perform like the manual
buttons on the pic, Ie send a command to mimic the'go faster' button or
the stop button. Thiswould allow me to be able to control it from a
remote location with a VB program or just a terminal.

Thats why I also needed a command to return a value that represents the
motors speed (rpm probably best form of result) >
> PIC-basic might be a lot easier for the serial parts than you think.
>

Well I have found 1 old 84' and a model car servo, now I just need to
find where I put the programmer.