[chbot] Motor controller

Robin Gilks robin at gilks.org
Sat Jan 24 02:54:52 GMT 2015


Thought I'd report on a couple of problems that have arisen since I
demo'ed the motor controller for my walnut washer.

1. Looking at the waveform with a 'scope showed a one clock 0.5uS glitch
when zero was set in the PWM compare register in Fast PWN mode. Its a
silicon bug!! Rather than add an errata for the AVR Mega, Atmel have
incorporated the behaviour in the main body of the specification that
indicates that for a no pulse output the register should be set to the
'TOP' value. The problem with that is that the signal is now up-side-down.
Good job I'm a hacker when it comes to coding :)
I noticed that the 328 as used in the Arduino Uno and even the ATMega8 and
ATMega169 (Butterfly board) have the same problem. One to watch out for
especially if using a slower clock to the PWM timer.

2. As Mark questioned, what do the H-bridges do when there is no input.
That is actually 2 conditions - setting a PWN ratio of all off or all on
and then flicking to the opposite state (eg. hitting the stop button)
keeps the output MOSFETs engaged and the commutating diodes clamping any
back emf off the motor at it screeches to a halt.
The second condition is nothing like as severe.  In the case of a switch
off, the enable lines of the H-bridge are de-activated, so the output
stages float, so the motor just coasts to a halt in a 1/2 to 1 second.
Another coding change for the former condition now takes a running average
of the value required so that step changes are 'smoothed'. The motors no
longer fall over when started or stopped :)



-- 
Robin Gilks
Internet: robin at gilks.org    http://www.gilks.org
Tel:      (+64) (3) 347 4370





More information about the Chchrobotics mailing list