Current Updates

This blog is an informal, and sometimes intermittent, record of my MEng project.

Thursday, 2 February 2012

Making Things Work

Yesterday, I build a motor controller.  The primary aim today is to finish testing it with PWM, and to (hopefully) make the AVR do something useful.

Motor Testing
The test method was quite simple:
  • Apply command inputs for 'forward', 'reverse', and 'brake', at varying PWM levels, with various motor loads;
  • Check how the motors 'feel';
  • Check the current sensed using a 'scope;
  • Check the controller temperature.
The images below show the PWM connections, and the sense connections:
 
PWM input connections
Sense resistor connection











First, I rewired my workbench using a 4-way bar socket - I have loads of equipment and it all needs plugging in!  To illustrate the amount of equipment, consider the following awesome picture...

Benchtop Setup - there are also two monitors to the right of this!

I tried the PWM at about 1kHz - this is a reasonable figure.  It worked very well.  I noticed a few issues with the left motor - the commutation was a bit poor (the output current could be seen to momentarily drop to zero sometimes) - this is probably to do with the terminals that were destroyed.  The signal is, however, acceptable.  If it turns out to be an issue, it's going to cost quite a bit - an equivalent motor is about £90!

I tested the forward, reverse, and brake functions.  The results were very good - the proportional braking was the strangest thing, like stirring oil with variable viscosity.

Throughout the tests, the controller stayed cool to the touch.

The current sensing works during the braking mode as well as the powered modes, but it doesn't give any reading during the 'off' part of the cycle (which is normal really - no current is delivered!)  Here's a picture of the 'scope screen, showing the input pulse and the current sensed:

'scope trace showing PWM input and sensed current

AVR Development
I quickly found out that development using avr-gcc requires a little legwork.  The package is dependant on libc6-dev-i386, but doesn't list it.  That means that anyone running a 64-bit system needs to manually install libc6-dev-i386.  It'd be nice if they actually fixed that.
Breakout Unit

I wrote a simple program to make the LEDs on PORTB flash in a sequence.  Then I soldered up an ISP breakout on stripboard.  I was quite impressed with the result - it just pushes on over the IC into the breadboard, and provides a standard 6-pin ISP header, as used by the AVR ISP mk II.

I wired a set of LEDs up to verify the operation.  I noticed them flash during programming.  On that note, the command I used was:

sudo avrdude -c avrisp2 -p m1284p -P usb -U flash:w:AVRtest.elf.hex

This took a bit of playing about to make it work, but it's not too hard to work out if you look at the man entry for avrdude (man avrdude).

No pattern was seen on the LEDs - first, I realised that I hadn't set up the data direction latch for PORTB (DDRB), so it was configured as an input.  That was a simple fix.

Still no output - maybe the oscillator isn't working?  But then ISP wouldn't work... Maybe the fuses aren't set correctly... but the default is the internal oscillator...

I'll figure that one out tomorrow - at least I've got the programming hardware and method worked out now!

No comments:

Post a Comment

Comments are moderated. Sometimes it might take me a long time to get round to it, so please be patient.