Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

6 PWM, Serial Tx and Rx on ATmega8 or 16?

2004-05-24 by macmen_seattle

I am struggling (read: newbie) with code that will do the following, say on an ATmega 
running at 8MHz:

1. PWM for six motors (not servos) running in one direction. 6-8 bit duty cycle resolution 
is fine.
2. Sample a few sensors.
3. Receive motor speed commands via serial.
4. Send sensor readings via serial.
5. Kill all motors if no commands are received after X ms.

Seems simple but I can't determine what should be interrrupt-driven and what should be 
polled. Using timers alone for the PWM is out (I think) because I need to run six motors. 
Run the PWM frequency too high and I consume all of the cycles checking to see if a motor 
needs to be started or stopped.

Also need a serial packet protocol to frame the packets. Delay before packet? 8th bit set 
on packet header and limit it to 7-bit data? 0xAA as header and then escape it if it appears  
n the data?

Your recommendations are welcomed. Sample code would be greatly appreciated. Thank 
you in advance.

Greg Schumacher

And now we return you to your regularly scheduled thread....

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.