Searching \ for 'PIC project - electronic speed controller.' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'PIC project - electronic speed controller.'.

Truncated match.
PICList Thread
'PIC project - electronic speed controller.'
1997\12\30@074340 by Peter Gee

picon face
Hi
I am thinking of designing an electronic speed controller for a remote control car using a PIC.  I have a number of ideas at the moment, but my favourite is to use the microchip application notes for creating a pwm (an654) with the 16f84, then convert the incoming pulse into a pwm stream.

I have read that the circuit cellar published an article a few years back on doing the very same thing, but I have been unable to get onto their web site.  I have been trying http://www.circuitcellar.com   is this the correct site ?

Any hints at all, from choice of mosfets, noise considerations, to programming tips would be greatly appreciated.

Regards,

Pete

1997\12\30@085557 by Andy Kunz

flavicon
face
At 11:42 PM 12/30/97 +1100, you wrote:
>Hi
>I am thinking of designing an electronic speed controller for a remote
control car using a PIC.  I have a number of ideas at the moment, but my
favourite is to use the microchip application notes for creating a pwm
(an654) with the 16f84, then convert the incoming pulse into a pwm stream.

That makes your entire program about 20 lines or so of C.

Andy


==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

1997\12\30@092029 by Alex Holden

picon face
Andy Kunz <spam_OUTmtdesignTakeThisOuTspamFAST.NET> wrote:
> At 11:42 PM 12/30/97 +1100, you wrote:
> >Hi
> >I am thinking of designing an electronic speed controller for a remote
> control car using a PIC.  I have a number of ideas at the moment, but my
> favourite is to use the microchip application notes for creating a pwm
> (an654) with the 16f84, then convert the incoming pulse into a pwm
stream.
>
> That makes your entire program about 20 lines or so of C.

I think you'll find it isn't quite as simple as that. Timing the length of
a 0.5 to 2 ms pulse occurring anywhere between 50 and 400 times a second
(more usually 50Hz, but depends how many channels the reciever has) is
pretty processor intensive. Trying to do that at the same time as
generating a PWM output on a PIC which doesn't have hardware PWM will
probably be tricky, and I doubt a C compiler would be intelligent enough to
get the two processes working together properly.

I think I would do it by connecting the output from the reciever to the INT
pin, and whenever an interrupt is generated, reset TMR0, wait till the
input goes low again, then read the timer. I would then generate the PWM
(which does not need to be as accurate as measuring the input) in the main
routine, using software delay counters (we are already using TMR 0 for
something else) to measure the PWM. Just ignore the errors introduced into
the PWM whenever an interrupt occurs, as it will never last longer than
about 2.5ms, which should not be too important as long as your PWM
frequency is very slow.

You then have to think about the problem of calibrating the device, the
maximum, minimum, and centre pulse lengths. I should store the calibration
values in EEPROM, and either incorporate intelligent 'self calibrating'
code, or allow a way for the user to program the EEPROM memory of the
device.

Remember to include a 'dead band' in the middle of the range where the
motor is turned off even if the input signal is not quite on centre.

-----------------------------------------------------------------------
: Alex Holden- Electronics student, Caver, and Land Rover enthusiast. :
:        http://www.geocities.com/CapeCanaveral/Lab/1532/             :
------------  Linux- The choice of a GNU generation.  -----------------

1997\12\30@104034 by Bob Blick

face
flavicon
face
>Andy Kunz <.....mtdesignKILLspamspam@spam@FAST.NET> wrote:
>> That makes your entire program about 20 lines or so of C.

At 02:17 PM 12/30/97 -0000, you wrote:
>I think you'll find it isn't quite as simple as that.

Oh, I like the way this is turning out....

Actually I think Andy is quite right, one input and one output at the same
time are easy to manage, especially if you are as smart and experienced as
he is. If you are willing to accept a few inconsistencies here and there,
even a regular mortal could do a decent job of it, either with interrupts
or not. Only recently have R/C car speed controls gotten really good, the
older ones were low frequency and synchronized with the incoming pulse
train. Certainly good enough as a starting place for someone getting their
feet wet with PICs.

Late for work, sorry I can't volunteer :-)

Cheers,

Bob

http://www.bobblick.com/

1997\12\30@123051 by Andy Kunz

flavicon
face
At 02:17 PM 12/30/97 -0000, you wrote:
>Andy Kunz <mtdesignspamKILLspamFAST.NET> wrote:
>> At 11:42 PM 12/30/97 +1100, you wrote:
>> >Hi
>> >I am thinking of designing an electronic speed controller for a remote
>> control car using a PIC.  I have a number of ideas at the moment, but my
>> favourite is to use the microchip application notes for creating a pwm
>> (an654) with the 16f84, then convert the incoming pulse into a pwm
>stream.
>>
>> That makes your entire program about 20 lines or so of C.
>
>I think you'll find it isn't quite as simple as that.

I read "using a PWM chip."  In a PWM chip, it really is VERY simple.

My ESC (http://www.users.fast.net/~montana/products.html) is a 2.8KHz PWM
rate, with about 100 speeds betweeen "OFF" and "FULL" available.

The input is measured in 6uS increments, and has several safety features to
handle things such as loss of signal, invalid pulses, etc. as well as
power-on safety (it powers up in OFF mode, no matter where your stick is
set.  You must go to "OFF" with the stick to activate it).

And it's all in a '508 running at 4MHz (and could be run off the internal
oscillator, too).

Or you can go buy an Astro Flight controller, which uses essentially the
same firmware.

>a 0.5 to 2 ms pulse occurring anywhere between 50 and 400 times a second
>(more usually 50Hz, but depends how many channels the reciever has) is

No, actually, most of them are 45-60 Hz, and there is no bearing on the
refresh rate from any transmitter I've ever used (and I've seen a lot of
them, believe me).

Andy

==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

1997\12\30@164453 by Marc Heuler

flavicon
face
Hi Alex (Alex Holden), in <.....199712301418.GAA01170KILLspamspam.....geocities.com> on Dec 30 you
wrote:

> I think you'll find it isn't quite as simple as that. Timing the length of
> a 0.5 to 2 ms pulse occurring anywhere between 50 and 400 times a second
> (more usually 50Hz, but depends how many channels the reciever has) is
> pretty processor intensive. Trying to do that at the same time as
> generating a PWM output on a PIC which doesn't have hardware PWM will
> probably be tricky, and I doubt a C compiler would be intelligent enough to
> get the two processes working together properly.

?!?  Setup a timer int at the rate you wish to output PWM.  Then sample the
PWM-input during this int, too.  If it's low, increase the "low counter",
else increase the "high counter".

The relation of those two counters represent the duty cycle, no matter what
the PWM-in-frequency was.

Reset the counters whenever you begin a new PWN-out cycle.

1997\12\30@233711 by Michael S. Hagberg

flavicon
face
>I have read that the circuit cellar published an article a few years back
on doing the very same thing, but I have been unable to get onto their web
site.  I have been trying http://www.circuitcellar.com   is this the correct site ?


use http://www.circellar.com/

michael

1997\12\31@040830 by Charles Hoss

flavicon
face
Peter Gee wrote:
>
> Hi
> I am thinking of designing an electronic speed controller for a remote control
car using a PIC.  I have a number of ideas at the moment, but my favourite is
to use the microchip application notes for creating a pwm (an654) with the
16f84, then convert the incoming pulse into a pwm stream.
>> Any hints at all, from choice of mosfets, noise considerations, to
programming tips would be greatly appreciated.
>
> Regards,
>
> Pete

I work on the same project now , so maybe we can help each other

1 I plan to use a 12c508 because the pwm doesn't have to be too
accurate , it's cheap , I have a bunch of it in the box

2 the first step of the project is to measure the min/max
pulse width transmitted by the receiver

3 simulate it with a stamp - for easy testing

4 find the data sheets for the part IRL2203

(I opened a competition speed control and 6 of these makes the
drive)

the unit was rated at 40 amps (I don't think it's true , but who
cares - I want to make a unit just as tuff as the pro-one)

if I could know the exact data of the IRL I could seach for a
H bridge of the same rating :)

5 make the lookup table for the drive
       1 forward at the desired pwm rate
       2 neutral (free run - lever at neutral position)
       3 brakes  on (short circuit the motor inputs)
       4 reverse (just as the forward option)

that's all

bye
charley

1997\12\31@040830 by Charles Hoss

flavicon
face
Peter Gee wrote:
>
> Hi
> I am thinking of designing an electronic speed controller for a remote control
car using a PIC.  I have a number of ideas at the moment, but my favourite is
to use the microchip application notes for creating a pwm (an654) with the
16f84, then convert the incoming pulse into a pwm stream.
>> Any hints at all, from choice of mosfets, noise considerations, to
programming tips would be greatly appreciated.
>
> Regards,
>
> Pete

I work on the same project now , so maybe we can help each other

1 I plan to use a 12c508 because the pwm doesn't have to be too
accurate , it's cheap , I have a bunch of it in the box

2 the first step of the project is to measure the min/max
pulse width transmitted by the receiver

3 simulate it with a stamp - for easy testing

4 find the data sheets for the part IRL2203

(I opened a competition speed control and 6 of these makes the
drive)

the unit was rated at 40 amps (I don't think it's true , but who
cares - I want to make a unit just as tuff as the pro-one)

if I could know the exact data of the IRL I could seach for a
H bridge of the same rating :)

5 make the lookup table for the drive
       1 forward at the desired pwm rate
       2 neutral (free run - lever at neutral position)
       3 brakes  on (short circuit the motor inputs)
       4 reverse (just as the forward option)

that's all

bye
charley

1997\12\31@045252 by Alex Holden
picon face
Marc Heuler <EraseMEmarcspam_OUTspamTakeThisOuTAARGH.MAYN.DE> wrote:
> ?!?  Setup a timer int at the rate you wish to output PWM.  Then sample
the
> PWM-input during this int, too.  If it's low, increase the "low counter",
> else increase the "high counter".
>
> The relation of those two counters represent the duty cycle, no matter
what
> the PWM-in-frequency was.
>
> Reset the counters whenever you begin a new PWN-out cycle.

I don't quite see how that would work. Do you mean: have a timer interrupt
which just simply resets your duty cycle counters, and have the main
routine both checking your counters against the timer and counting how long
the incoming pulses are at the same time?
Remember that the incoming pulses need to be timed pretty accurately.

But, Bob Blick suggested an idea which sounded interesting: sync the PWM to
the incoming pulse train. That way, you don't need to about the two
colliding, and wouldn't even need interrupts.
Just:
Wait for the incoming pulse.
Time how long the pulse is (most accurate way is to reset TMR0 and read it
again when the pulse ends).
Decide if you are going in forward, reverse, or stopped, and by what
magnitude.
Work out how long the pulse width needs to be (a lookup table could be used
here)
Set the direction output to the H-bridge.
Set the PWM output high.
Reset TMR0.
Wait for TMR0 to equal the PWM value.
Set the PWM output low.

Notes:
The TMR0 prescaler would have to be set high enough to be able to time the
maximum length of pulse width allowed. The longest pulse width should not
be so long that it over-runs into the next cycle.
This design will not quite allow 100% duty cycle- it would if the PWM was
set on before the timing and calculation, but then it would never quite go
down to 0% duty cycle, which would be worse. You could get around this by
having both sides of the H-bridge controlled by the PIC (ie. 0-0 = off; 0-1
= forward; 1-0 = reverse; 1-1 = a bunch of blown mosfets (disallowed)) and
switching both sides of the bridge off when in park position. Come to think
of it, that would probably be a better way of doing it.

-----------------------------------------------------------------------
: Alex Holden- Electronics student, Caver, and Land Rover enthusiast. :
:        http://www.geocities.com/CapeCanaveral/Lab/1532/             :
------------  Linux- The choice of a GNU generation.  -----------------

1997\12\31@053249 by Christopher E. Brown

picon face
On Wed, 31 Dec 1997, Alex Holden wrote:

> But, Bob Blick suggested an idea which sounded interesting: sync the PWM
> to the incoming pulse train. That way, you don't need to about the two
> colliding, and wouldn't even need interrupts.  Just:  Wait for the
> incoming pulse.  Time how long the pulse is (most accurate way is to
> reset TMR0 and read it again when the pulse ends).  Decide if you are
> going in forward, reverse, or stopped, and by what magnitude.  Work out
> how long the pulse width needs to be (a lookup table could be used here)
> Set the direction output to the H-bridge.  Set the PWM output high.
> Reset TMR0.  Wait for TMR0 to equal the PWM value.  Set the PWM output
> low.

       There may be a problem with this, it depend on the type of speed
control to be duplicated.  I have seen several mentions of the higher
quality rc car speed controls (as in the size of a box of matches, able to
handle 30-100 amps DC ~ 7-10v, switching rate of 2000hz+) used in the
racing cars.

       The older units (IIRC) did somthing similar, very low switching
rates, often based on the pulse rate from the radio.  The problem, watsed
power, arcing in the motor, not very fine control.

       Trying to remember the specs, I thing is was a several ms pulse
with a cycle time of 15 - 20 ms, with most units centering at about 2ms, +
20ms (20ms delay + 2ms pulse).  Basing the pulse rate for the motor
control on the control signal would give ~50hz, slow and causes bad arcing
when the motor is under load.

       I got out of rc racing several year ago, but even then the typical
units were switching at 2000hz+ and pwm the power to regulate motor speed.

I am just learning about PICs, but is there really a problem with a mere
2khz signal?

How does the pwm out on the pics operate?  Is it a set it and let it run
type, or do you set the width and trigger it each time?


----------------------------------------------------------------------------
Christopher E. Brown (CB421)    <cbrownspamspam_OUTalaska.net>        +(907) 357-5680

We are Pentium of Borg.  Division is futile.  You will be approximated.
----------------------------------------------------------------------------

1997\12\31@124658 by Marc Heuler

flavicon
face
Hi Alex (Alex Holden), in <@spam@199712310951.BAA00577KILLspamspamgeocities.com> on Dec 31 you
wrote:

> Marc Heuler <KILLspammarcKILLspamspamAARGH.MAYN.DE> wrote:
> > ?!?  Setup a timer int at the rate you wish to output PWM.  Then sample
> the
> > PWM-input during this int, too.  If it's low, increase the "low counter",
> > else increase the "high counter".
> >
> > The relation of those two counters represent the duty cycle, no matter
> what
> > the PWM-in-frequency was.
> >
> > Reset the counters whenever you begin a new PWN-out cycle.
>
> I don't quite see how that would work. Do you mean: have a timer interrupt
> which just simply resets your duty cycle counters, and have the main
> routine both checking your counters against the timer and counting how long
> the incoming pulses are at the same time?

Let me elaborate..

I haven't read the original msg, so I don't know the exact problem.  But
from the replies it appears to me that there's an input PWM signal from an
unknown source, and an output PWM signal that is to be generated in the
PIC.  The PIC should be able to sync the duty cycle of the output to the
input, or change the duty cycle arbitrarily, whatever it thinks is
appropriate depending on other unknown events.

If that is right, you can measure the input PWM to a quite good accuracy by
sampling it in a regular time interval.  The sampling frequency should be
at least as high as the PWM-in granularity.

For ease of programming, one could lock the sampling frequency to the
output frequency.

Setup an int with 1khz.

During each int, sample the input PWM signal.  It's either hi or lo.
Increase one of two counters, CNT_LO or CNT_HI.

After 1 second, examine the CNT_LO and CNT_HI.  When the duty cycle was
100%, you'll find CNT_LO=0 and CNT_HI=1000.  For 50% you have CNT_LO=500
and CNT_HI=500.  For 0% you have CNT_LO=1000 and CNT_HI=0.

So the vars show the duty cycle.  You just have to be sure to read them

a) in lock with the PWM sender, or

b) after a long time, so many high/lo cycles have elapsed and the error
   is small, or

c) at the same frequency or multiple of the PWM sender, but phase-shifted.


You can also collect several input periods, while outputting the same duty
cycle over and over.  After 5 or so iterations, you can read the two vars
and adjust your output duty cycle accordingly.  This will maintain desired
PWM frequency but lower time resolution for the sake of simplicity.


The same interrupt will be used to generate the output pulses.


Remember we're not talking about the best solution, but the simplest one,
that could fit a few lines of C code..

1997\12\31@144928 by Alex Holden

picon face
Christopher E. Brown <RemoveMEcbrownTakeThisOuTspamALASKA.NET> wrote:
>         I got out of rc racing several year ago, but even then the
typical
> units were switching at 2000hz+ and pwm the power to regulate motor
speed.
>
> I am just learning about PICs, but is there really a problem with a mere
> 2khz signal?
>
> How does the pwm out on the pics operate?  Is it a set it and let it run
> type, or do you set the width and trigger it each time?

It depends on the PIC. Some of the high end ones have a couple of hardware
PWM generators, which are great. The smaller ones don't though. There's no
problem generating a 2Khz PWM, or reading a PCD(?) input from a radio
control reciever. It's just that the accuracy of measuring the incoming
pulse width is quite critical, and the pulse can last up to 2ms. At 2Khz
PWM output, you will be disrupting between about 1 and 4 PWM cycles 50
times a second (every time the PWM generator code is interrupted to go read
the input). If you wanted to use an expensive 16C62 or similar with
hardware PWM and CCP modules, there would be no problem, the C compiler
probably would produce suitable working code. If you want to use a 12CXX or
16X84 device though (which I believe they do), it will be a bit trickier.
I'm not saying its impossible, just that I don't think you will come up
with a satiscfactory solution with 10 lines of C code.

1997\12\31@155136 by Andy Kunz

flavicon
face
>problem generating a 2Khz PWM, or reading a PCD(?) input from a radio

We call it a PPM signal in the industry.  Pulse Position Modulation, as
compared to PCM Pulse Coded Modulation, which is binary data transfer.

>I'm not saying its impossible, just that I don't think you will come up
>with a satiscfactory solution with 10 lines of C code.

As I stated before, I mis-read "PWM h/w in the PIC"

Andy


==================================================================
Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA
==================================================================

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...