Tuesday, August 29, 2006


An ungrateful Plaas casts Cerberus back into the pit...

Cracked the problem! We can have our cake and eat it, too!

Once I had the 16F877A running at 4 MHz, it was obvious that I was still getting a ragged motor output. Something else had to be wrong.

At that point I started wondering what was different about the 877A board and the 628A board, because at 4 MHz the 628A board worked fine. I noticed two things different. First, on the 877A board I was feeding the 754410 H-bridge chip 12.4v instead of 5.4v. I had already adjusted the settings downward on the duty cycle to keep the GM4 gear motor within its 0-6v range.

The second thing was that I hadn't bothered to install a 100 nF ceramic disk capacitor across the power leads coming from the 754410 into the GM4. In theory, that little capacitor is supposed to keep backpropagated voltage spikes from coming back from the motor into the 754410. There has never been a lot of that sort of thing coming out of the GM4 so I hadn't got round to putting it in yet.

Just to be sure I slapped one across the power leads and... LO AND BEHOLD... the GM4 ran smoother, not perfectly, but smoother... a LOT smoother. It also ran a lot faster, indeed, it ran at speeds one might expect from it at the duty cycle I'd set for a change.

I've taught electrical installations for buildings at university but my feel for electronics work is pretty much pure thumb suck. I do know enough about capacitors to know that when you feed a variable signal into one they tend to smooth it out. Indeed, if you send a variable signal into a big enough capacitor when it finishes charging up you get an output that looks like the average of the incoming signal integrated over time.

Keeping that in mind, I remembered that back when I was building copies of Simon's stepper board he had had a fondness for polyester (green plastic) capacitors that were much bigger than the little ceramic disk capacitors that I had shifted over to when I went over to the GM4 a month or so ago. I still had several lying about.

I reasoned that the big polyester capacitor had a bigger time constant on it than the little ceramic disks so it should so a better job of turning the output from the 754410 into something the GM4 understood. The polyester capacitor had the same rating, 100 nF, as the ceramic disk so I figured that it couldn't hurt to try.

I slapped that green bad boy across the power output leads and cranked up the board and the GM4 ran as smooth as silk for Mode 7 at 977 Hz.

Never one to leave well enough alone, I went fishing for different PWM frequencies again. At 4 MHz for an 8 bit duty cycle resolution I had two other options, Mode 8 at 3906 Hz and Mode 9 at 15625 Hz. As Microchip had said in their literature the higher frequencies don't make as annoying a whine as the lower ones do. The GM4 ran just the same, save a little quieter, at those frequencies as well.

Just now I decided to REALLY push my luck and swapped out the 4 MHz resonator for a 20 MHz resonator and kept the same Mode 9 in the firmware, which was now going to be 15625 Hz x 5 = ~78 KHz.


All of the preconceptions I'd picked up over the past few days about the frequency response of the H-bridges were WRONG! :-)

Campers, running 2 motors for the x/y axes off of one 16F877A chip is back on the table! :-D

LOL, well that's excellent! I'm glad the MCU is back at 20mhz.

The crazy thing is, now that you spell all this out, a little bell starts to ring far back in my mind about this very issue! That's often how it is (for me anyway) when you are not an expert, you may actually "know" the information but it is not really connected to the web of knowledge you can tap at will.

Sort of like when you take an exam, and you start realizing you haven't reviewed quite enough!
I'm trying to integrate serial comms back with the PWM now like it was on the 16F628A board. It's not being particularly nice to me.

I get the feeling that there is a glitch somewhere in the compiler when it tries to make two PWM channels work with the higher level instructions. It feels like Vladimir got them running for one channel and then didn't get around to doing the sort of thorough tests you'd need to make sure both were working together.

I've been measuring the frequency response of both channels and getting different numbers when I'd programmed them to be the same. It's very odd.

I think that I will go back and set the PWM's using the lower level instructions like Adrian did. That might be a lot more reliable for now.
That's great! I was actually thinking of asking if you'd tried adding a capacitor to the circuit to smooth everything out.

I guess I should have. :)
You might consider updating your original post ( http://builders.reprap.org/2006/08/fishing-stories.html ) with a pointer to this one correcting your data. Google web search results directed me to your original post, which had me freaking out and double-checking the 754410 datasheet before I found this one largely by accident and realized the mistake.
Post a Comment

Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to
Posts [Atom]