PDA

View Full Version : RC H-bridge control



RFsolution
- 10th March 2006, 10:01
Hi All,

I'm about to give some help to a student in order to control a H-bridge motor control with a standard remote control for models

Here is what my student wants to do:


Hi all,


For my project, I have build an electronic speed controller. It is an H-bridge design, based around the HIP4081A chip whichcaters for the MOSFET driving- both high side and low side- and provides shoot through protection which is very useful, as I'm the kind of person who would accidentally program the PIC to create a short through the bridge!

The input will be a standard hobby Futaba radio receiver, i.e. a pulse of between 1ms and 2ms, the pulse width between the two extremes proportional to the position of the stick on the transmitter (1,5ms being the stick in the central position, 2ms being full 'forward', 1ms being full 'backward'). My initial thought was to set the PWM output as the main program, and use interrupts to time the pulse form the Receiver.. However, having read the manual and looked around the forum, I think I have been put of interrupts for life- I didn¡'t understand half of the solution, and as for writing things in ASM, well, I'd faint at the thought of it- I really need to learn more about PICs (something I'm looking forward to doing!) before I start even contemplatinglearning to use ASM :-).

So my dilemma was having a constant PWM signal to the bridge driver (there are 2 PWM outputs needed, for each for the high side MOSFETs, depending on which is being used (i.e.. which direction the motor is turning), but also monitoring the input from the Receiver, and extras such as failsafes and possibly mixing with another controller (to allow the tank style skid steering to be controlled with a throttle and direction stick on the transmitter, as opposed to 2 x throttle sticks).

So, I had another look through the manual, and started reading more into HPWM, and noticed that it can run the background. This sounds perfect, in that the main program can concentrate on the incoming signal from the receiver, and then have the PWM output constantly running in the background. But here is my question (finally!):

I would program the pulse timing routine to generate and 8 bit variable at the end, so that a 2ms pulse would generate '255', a 1,5mspulse would generate ¡¥127¡¦ and 1ms would generate '0' and all the various degrees in between. Having got this variable (for the sake of argument we'll call it 'rxin') can I then insert it into the duty cycle part of the HPWM code? So I would end up with something like:

HPWM 1,rxin,1000

Would this work? The HPWM code would be inserted at the start of the program, and I would assume it would just run in the background. The 'rxin' variable would be constantly changing- does the HPWM code automatically update every time the variable changes? Also, can both HPWM ports run simultaneously?- when one of the MOSFETS is having the pulse applied to it, the other would need to be closed, so I assume I would apply a 0% duty cycle to it, or is there an easier way?

So, to put all the questions in as concise a way as possible:

1) Would inserting the variable in the duty cycle part of the HPWM code work?
2) When the rxin variable changes, will the HPWM code (at thestart of the program) automatically update?
3) When I want one of the MOSFETs off, should I apply a 0% pwm, or is there a way to simple turn it off?
4) Have I made any gaping obvious novice mistakes?

I have also just realised that I have made a mistake in that I didn't make it clear that if the pulsing from the receiver is greater than 1,5ms, the motor will be running forwards and I will be applying the PWM signal to one side of the h-bridge, if its less that 1,5ms, then the motor should be running backwards, meaning that I should apply the PWM signal to the MOSFET on the other side of the bridge. A 1,0ms pulse would be full reverse, a 2,0ms pulse being full forward, so 1,0ms requires a 100% duty cycle output to one side of the bridge, a 2,0ms input requires 100% duty cycle to the other side of the bridge. In otherwords, if I were to moving the stick from the bottom end to the top, the rxin variable would begin at 255, move to 0 when the stick was in the centre, and then riseagain to 255 once the stick is at the other end (obviously I would put a section in the code that sends the signal to one side of the bridge in the pulse was above 1,5ms, the other side if the pulse was less than 1,5ms). So, it would be easy enough to convert a pulse between 1,5 and 2,0ms to a number between 0 and 255, but how would I write the code so that between 1,0ms and 1,5ms, I generate a number between 255 and 0 respectivelly?

Phew, I think that's it. Apologies for the long post, but its very difficult for me when I have very little idea what I¡¦m doing! Any help would be hugely appreciated.

Many thanks,

(original description from ED Moore thanks it was what I want to do)



--

Acetronics2
- 10th March 2006, 12:30
Hi, RF

I understand you want to use the Hip Chip ....

BUT, looking to new born PICs ( 16F684 i.e. ) you could discover the Enhanced CCPM module itself is able to drive half and full bridges ... with already built in dead time control ...

May be you just have to boost current to drive your e.motor

Worth it, no ?

Alain

RFsolution
- 10th March 2006, 14:10
Hi, RF

I understand you want to use the Hip Chip ....

BUT, looking to new born PICs ( 16F684 i.e. ) you could discover the Enhanced CCPM module itself is able to drive half and full bridges ... with already built in dead time control ...

May be you just have to boost current to drive your e.motor

Worth it, no ?

Alain

Hi Alain,

Well to be complete, I dont use the H-bridge IC but I use a 4 mosfet H-bridge
Problem is we already have build the hardware with a 16F84 pin compatible
device

So ideal should be a pin compatible device using CCPM HPWM on 2 pins
1 for left, 1 for right

So if anyone has a suggestion me and our student will be verry happy