Re: Need Advice on PWM and other stuff



On May 27, 12:09 am, Bob Smith <bsm...@xxxxxxxxxxxxx> wrote:
Joe wrote:
On May 26, 3:06 pm, Bob Smith <bsm...@xxxxxxxxxxxxx> wrote:
Since you have an AVR, you might want to replace the 555
with a pin(2) from the AVR. Depending on which AVR you have
you may already have a couple of PWM counters on board.
Even if you don't have the PWM counters you can build one
easily enough with a timer interrupt.

Hello Bob,

Yes, a very kind offer. Just one pin?

Sorry, the "(2)" was *supposed* to be "(s)" indicating more
than one pin. You'll probably want, per motor, one pin for
the PWM output and one pin for the direction.

I would love to use the avr, but
I don't know how, even after reading the dox. I am going to have one
micro whose sole function will be to control the motors and steering
(and, at first, will have to decode the signals from my RC and timeout
when it stops receiving the once every 18ms pulse that the transmitter
generates when it is on, just a safety precaution in case the thing's
running full tilt and my RC transmitter batteries go dead, or it goes
out of range). I will add micros later for sensors, navigation, etc.
as needed.

I sit at a Linux desktop and really like the AVR since you can
program it using gcc. The site that got me going on this was:http://www.linuxfocus.org/English/March2002/article231.shtml

Some AVR books to consider are: John Morton's "AVR, An Introductory
Course", and Dhananjav Gadre's "Programming and Customizing the AVR
Microcontroller".

I have in my possession the following:

ATTiny 2313 (I know that has 4 PWMs aboard), but limited memory
ATMega 8515, my favorite
ATMega8535, because of the A/D's. I haven't used this one yet.

Bascom full version programming language. 1.1.83
STK 500 programmer.

I cannot seem to wrap my head around how to use the timers for PWM and
get a timeout if needed also. Being more inclined to hardware, I
thought I would use a separate PWM (which probably sounds insane).

Anyway, suggestions on which micro would be the best to use

All of the above are good and have enough PWM channels that you
don't need to use a timer interrupt. I use the ATMega8 in the
28 pin DIP. It is easy work with since I wire-wrap most of my
projects. (See my hobby web site at:http://www.linuxtoys.org)

and, If
possible, I would like to control each motor with its own PWM so I can
slow down instead of stopping one of them to make a turn.

Now, if it so happens that you don't use Bascom, then a flow chart
(antiquated term, I know), or description of which pins I have to
use, details, details, and I can probly figure out how to code it
myself in Bascom.

The basic idea is the same for both a hardware and a software
implementation. You have a free running counter with the number
of bits of your desired resolution. For 8 bit resolution you
need an 8 bit counter. Set up a timer interrupt and increment
the counter on each interrupt. If the new count is zero, set
the PWM output high. The terminal count is the PWM width times
the resolution. So if you wanted a one-quarter width PWM output,
the terminal count would be 64. If the new count is equal the
terminal count, set the PWM output pin low. There are other
considerations but this is the basic idea.

hope this helps
Bob

Hello Bob,

I did some more reading in both the bascom user manual and the atmel
documentation for the 8515. They don't talk about rise times, which is
crucial for using power mosfets.

The bascom user manual has a sample program to output 2 PWM signals
(according to the 8515 dox, "phase and frequency correct outputs are
the preferred modes for electric motors), using timer 1, the 16 bit
timer. It divides it into 2 8 bit pwm signals. I don't know if they
are "phase and frequency correct", nor do I even know what that means,
but I am going to give it a go today.

You said above:
So if you wanted a one-quarter width PWM output,
the terminal count would be 64

I don't know what you mean by terminal count. Do you mean clock
scaling?.

I guess I will begin at the beginning. Program the chip using the
sample program in the user manual, and measure the OC1A and OC1B pins
and see what I get on the scope. Then, I will try and vary the width
of the pulses after I make sure the rise time is on the order of
about 35-40 nanoseconds (or less), although I doubt it. If not, maybe
there is some logic (LS series maybe ? that can take a slow rising
edge and make it fast.) Is there a such thing as a Schottky comparator
with the rise times I have mentioned?

Anyway, I am off to the races now, so to speak. I will repost here if
I have any questions, and I will check out your web site first. Maybe
I will get some ideas from there.

Thank you again,

Joe

.



Relevant Pages

  • Re: Need Advice on PWM and other stuff
    ... I decided that using the motor driven potentiometer was folly, ... the duty cycle) in my PWM control module. ... Since you have an AVR, you might want to replace the 555 ... you may already have a couple of PWM counters on board. ...
    (comp.robotics.misc)
  • Re: PWM the most efficient way
    ... They use hardware PWM and change the pulse width from the usual program ... As I see it now it would be probably easiest to setup one AVR ... supply without software involvement when the code crashes might be ...
    (sci.electronics.misc)
  • Re: Need Advice on PWM and other stuff
    ... Depending on which AVR you have ... Even if you don't have the PWM counters you can build one ... Just one pin? ... and Dhananjav Gadre's "Programming and Customizing the AVR ...
    (comp.robotics.misc)
  • Re: PWM the most efficient way
    ... searched the google for several hours and found some really ... useful assembler code for AVR, the page is catched by google: ... They use hardware PWM and change the pulse width from the usual program ... As I see it now it would be probably easiest to setup one AVR ...
    (sci.electronics.misc)
  • Re: SyncMaster 151s LCD monitor turns itself completely off after 20 minutes
    ... This IC has a built-in thermal shutdown latching circuit for when it is ... UC3842 PWM IC, there are a couple ... V or pull pin 1 below 1 V, ...
    (sci.electronics.repair)