PDA

View Full Version : Need guidance with DC motor controller - PWM & H-Bridge



rfetech
- 10th November 2010, 23:39
Hello all,

I'm wanting to continue advancing my PIC programming knowledge by taking my recent train controller project to another level. If you have read my postings, and/or assisted me, on my recent project, then you know that I'm a novice in the true meaning.

I've done quite a bit of reading the past couple days but just haven't found the right starting code for what I'm wanting to do. Maybe one of you can point me to some code that will help jump-start my project.

I'm wanting to control the speed and direction of the small dc motor in a HO gauge train. The current requirement is less than 1 amp. The max voltage would be ~12 VDC. I would like to use a pot to control the speed and I would use my existing reed switches to control the direction, via the PIC input pins.

In addition to some pointers to code samples, do you think that I can use a 12F683 or should I go to the 16F684. Of course, any other PIC that is you feel more suitable. What H-bridge IC would you recommend and do you know of any schematic diagrams that you could point me to that might show a PIC interfacing to the h-bridge?

Thanks,
Mitch

mackrackit
- 11th November 2010, 02:01
The attachment might help.

rfetech
- 11th November 2010, 02:37
Thanks Dave,

I read that one yesterday and, while I'm not opposed to building with discrete components, the cost is somewhat higher. Also, more components to mount and solder into the pcb. :rolleyes:

The L298HN is an IC that seems to be popular and I have found some circuitry and code to control direction but just need to add the PWM speed control.

Anyway, the code in Scott Edwards article seemed pretty simple so I wasn't sure if it offered a good smooth speed control. Guess I could breadboard it and see...

Regards,
Mitch

rfetech
- 11th November 2010, 03:52
After re-reading some of my search results, I believe that I can modify the code that I found from HankMcSpank...

http://www.picbasic.co.uk/forum/showthread.php?t=13487&highlight=HPWM

This will allow me to read a POT and convert that into a PWM output. I should be able to do this with a 12F683 as I only need one channel. If so, then I now need to decide on a IC or discrete components. I am favoring an IC, forgot the part number without re-searching, that only requires one pin for directional control.

Still would appreciate any input.

Mitch

aratti
- 11th November 2010, 15:14
You could use one BD6220 3 to 36 volts @ 2 Amps with PWM capability.

See the attached Pdf.

Cheers

Al.

rmteo
- 11th November 2010, 17:57
Per your data sheet, the BD6220 is good to 18V @ 0.5A.

aratti
- 11th November 2010, 18:08
I was referring to the BD62xx series. BD6232 is 36 Volts Max 2 Amps. But you have a choice from 0.5 to 2 Amps


Al.

rfetech
- 12th November 2010, 03:33
If I understand the data sheet correctly, the BD622x and BD623x series have a minimum frequency requirement of 20kHz. That would rule out using the PIC internal oscillator, would it not? It also appears that the IC's require 2 channels of PWM for control. If that is true, then the PIC12F683 would not qualify, I suppose.

The LMD18200 would be great, and it only requires 1 PWM input, except that the cost is more than I want to put into this project - ~$12.00. The BD6232 is less than half the cost of the LMD18200 at ~$5.00.

So far, I'm leaning towards the popular L298N. It cost about $2.50 and requires just the 1 PWM input and no limitations on the frequency so I could use the 12F683 with internal osc.

Of course, I may be missing some things so please let me know if that is true.

Mitch