HCS12 PWM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HCS12 PWM

3,406 Views
prog_ram
Contributor III
Hello,
I am using the PWM. the problem is that sometimes I get a capacitive (charging/discharging) effects on the edges of the PWM signal.
 
Can anyone please help me in that?
what would be the reason from not having a regular PWM signal generated from the PWM module?
thanks.
here is the code.
void PWM1_16bit_freq(float freq,float duty)
 {
  unsigned int total;
  int_val x,y;
  if (!((freq==0.0f)||(duty==0.0f)))
  {
  PWME.b.b1=1;// disable the channel  
  total=24000/freq;
  x.val=total;
  PWMPER0.byte=x.byteval[0];
  PWMPER1.byte=x.byteval[1];
  y.val=(total * duty)/100;
  PWMDTY0.byte=y.byteval[0];
  PWMDTY1.byte=y.byteval[1];
    }
   else
   {
  PWMPER0.byte=0;
  PWMPER1.byte=0;
  PWMDTY0.byte=0;
  PWMDTY1.byte=0;
  PWME.b.b1=0;
 
   }
 }
Labels (1)
0 Kudos
6 Replies

568 Views
allawtterb
Contributor IV
The only way I could see a slow changing signal damage the motors is if the input was changing slowly enough and the input signal was noisy.  This might cause the output of the H-Bridge to oscillate as the signal rises.  I'm not sure what effects this oscillation could have on the motor but it wouldn't be desireable.  Some H-bridges have a built in hysteresis, as yours does, to prevent this situation.
0 Kudos

568 Views
JimDon
Senior Contributor III
I will tell you this - it has nothing to do with the code you are showing.

- Did you turn on pull ups ? (Look in the PIM document for this)

- Good chance it's the scope probes. There should be a little screw that tweaks this.

- Could also be the bandwidth of the scope. Even if you are far below the rated bandwidth, squares wave can get a little curvy. Since square wave are rich in 3rd 5th & 7th ( all odd) harmonics, even at 1/10 the rated bandwidth, what you see may be a bit off. Seeing is not always believing.

- Is it driving a circuit ? Is it loading the output?

And last but not least - so what? Is it causing a malfunction in the output circuit?





0 Kudos

568 Views
prog_ram
Contributor III
well Sir, it's the probe..
 
the pull up resistors are all disabled in the Port P
I am driving a motor through an H-bridge.. and the motor guy told me that this "may" burn his motor.. may it?
 
thanks a lot..
 
bye.
0 Kudos

568 Views
JimDon
Senior Contributor III
For one thing, it's the H Bridge driving the motor, not the HCS12 pins.
Do you have external pull ups? The rise/fall time depends on the pull ups.
Too weak of a pull up, and slow rise time too strong slow fall time.

What is the part number of the H-Bridge?
Does it have built in fly back diodes?

Did the "guy" say exactly why it would burn it?
What drive voltage are you using vs the rating for the motor?
Does the motor heat up - beyond the specification?
(it's pretty normal for a motor to get warm/hot)

You see, it is hard to answer such a question with out all the data.

0 Kudos

568 Views
prog_ram
Contributor III
Hello Jim,
I am using TC4424 H-bridge, and it's said in the manual that it has some Capacitive effect. However, the square wave distortion was (as you said) from the scope probe itself..
as for the pull up, I am not using any pull ups along with the H-bridge, I fully control the channels with the Hcs12 ( I may add a pull up later, 10K on the input channel of the H-bridge).
It doesn't have built-in flyback diodes, but I added them externally. So yes there are flyback diodes.
the voltages are all within the ranges..
 
actually I know nothing about the motor other than the voltage/current needed.. (it's the company policy of that guy!!), all he said that it may BURN!!
 
but since we solved the problem (thanks to you) and there is no distortion in the wave, I assume that there should be no problem...
 
thank you,
 
 
0 Kudos

568 Views
bigmac
Specialist III
Hello,
 
If a prolonged switching ramp exists, it is more likely to "burn" the H-bridge - there would be increased dissipation during the switching interval.  Check the temperature of the device, if you suspect there is a problem.
 
The switching period should have no detrimental effect on the motor itself.  Consider that the motor winding will have considerable inductance, and this will effectively smooth the motor current anyway.  The motor current waveform will be triangular, unless the PWM frequency is too low.
 
With fast switching, the control of voltage spikes is likely to be more of an issue (for the H-bridge).  The flyback diodes may need to be fast  recovery or Schottky types.
 
Regards,
Mac
 
0 Kudos