PWM, H-Bridge and NCO - PIC16F18446


+ Reply to Thread
Results 1 to 27 of 27
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115

    Default PWM, H-Bridge and NCO - PIC16F18446

    The idea: Drive a MosFet H-Bridge with the upper transistors with a PWM output signal (freq of ~1KHz) and lower transistor with a low requency NCO output signal (0-50Hz).

    Requirement is to have two modes of operation. One in full bridge, so the load accepts changing polarity according to NCO and the power controlled by the PWM signal.

    The other mode drives the load with one polarity only, NCO drives the On/Off state of the load and again PWM the power.

    Have setup the NCO correctly on the 16F18446 chip, along with the PWM so then one polarity signal can be produced.

    But cannot thing how I can drive output for full bridge mode. It is not exactly as PWM driving fullbridge since I need also a low freq signal for the polarity change along with higher frequency PWM signal.

    If waveforms are needed to clarify things I may draw them on paper and scan then.

    Ioannis

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    why not use the CWG module, with appropriate steering all modes are possible
    Warning I'm not a teacher

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Thanks Richard.

    Have not used about that module yet. I will have a look at that to see what can do.

    Here is a small simulation on LTSpice to describe what I want to do. Please delete the .txt at the end of the file name and run it on LTSpice.

    The load is driven at 1Hz with a PWM signal of 1KHz.

    Ioannis
    Attached Files Attached Files

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    i can't see what you are trying to do. the spice sim does not help.

    its easy enough to modulate a 1khz pwm signal @50hz , it's easy to lock a h-bridge one way or another.
    i am having difficulty seeing how the top and bottom halves of a h-bridge can be different frequencies without shoot through destroying every thing
    Warning I'm not a teacher

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    The main task is to drive a load (this is a big coil of around 19mH of thick 2mm wire at 60cm diameter) with:

    1. Unipolar, 0-20 volts, pulsating power of 0-50Hz

    2. Bipolar 0-20 Volts, pulsating power of 0-50Hz

    Because of 2. a full bridge is needed.

    But because of the high currents at low frequency (below say 30Hz) the MosFets of the Bridge are not in the SOA and decided to use PWM to adjust the mean voltage driven to load along with the On/Off period just to cool the MosFets.

    That PWM signal will drive the one of the upper transistors of the bridge while the NCO low frequency of 0-50Hz will drive one of the lower transistor of the same bridge.

    In other words, say I want to drive with unipolar signal the load:

    1. Upper right MosFet is modulated with PWM 1KHz 30% DC signal
    2. Lower left Mosfet is modulated with NCO of say 10Hz


    If I want to drive bipolar signal to the load:

    1. Upper right MosFet is modulated with PWM 1KHz 30% DC signal
    2. Lower left Mosfet is ON for x msec.
    3. Lower left MosFet is OFF
    4. Upper right MosFet is OFF
    5. Upper left Mosfet is modulated with PWM 1KHz 30% DC signal
    6. Lower right MosFet is ON for x msec
    7. Lower right MosFet is OFF
    8. Upper left MosFet is OFF
    9. Loop from step 1

    Alternatively, as the simulator shows:

    1. Upper right MosFet and lower left MosFet is modulated with PWM 1KHz 30% DC signal for 1/2 of NCO signal
    2. Upper left Mosfet and lower right MosFet is modulated with PWM 1KHz 30% DC signal for 1/2 of NCO signal
    3. Loop from step 1

    Simple, right? Well no. Cannot figure how this can be done...

    On the Simulator file this is shown on two cycles of the 1Hz signal modulating the PWM of 1KHz signal.

    I do understand that there is great danger of shoot through current and have to be very carefull.

    Ioannis

    P.S. Maybe add a 5th MosFet on the lower side of the H-Bridge and modulate that one with the PWM signal? Then how will the pairs in the bridge change according to the NCO signal?
    Last edited by Ioannis; - 12th March 2025 at 12:49.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    I'm probably missing something...
    Why not simply turn on the lower MOSFET in question, apply your 1kHz PWM signal to the (correct) upper MOSFET and then modulate it using your 0-50Hz signal. In other words, turn the 1kHz carrier on/off at whatever rate you want.

    If that's possible or not at the hardware level, ie "route" the NCO output to the enable bit of the PWM carrier is beyond my knowledge at the moment but at such low frequency (0-50Hz) a software (perhaps interrupt driven) aproach sounds more than reasoanble.

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    or use the clc module to steer the low freq osc,
    should be shoot through proof if 1khz osc had adequate dead time
    Name:  Untitled.jpg
Views: 424
Size:  47.0 KB
    Last edited by richard; - 12th March 2025 at 22:24.
    Warning I'm not a teacher

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Henrik, I like your idea if can be handled by hardware as I am afraid of software that may hang. Also it gets complicated when you want to control the output as bipolar and have to switch all transistors both at PWM and low freq. signal.

    Do not know if or how NCO can be steered PWM/CWG module.

    Richard, also nice idea about CLC module. I suppose the low freq signal is external of the PIC. Or may be the NCO signal too.

    Ioannis
    Last edited by Ioannis; - 13th March 2025 at 14:36.

  9. #9
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Ah, I didn't quite get you wanted locked antiphase PWM, ie the polarity of bridge is "reversed" every PWM cycle.
    I thought you wanted to run it "forward" for x ms and then "in reverse" for x ms while also modulating the 1kHz PWM frequency with 0-50Hz.

    I guess I still don't quite understand what you want...

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Henrik, for a while forget the PWM.

    Just think of an H-Bridge that drives a load in two modes:

    1. Unipolar voltage on the load with a rate of 0-50 Hz

    2. Bipolar voltage on the load with a rate of 0-50 Hz

    The mode 2 obviously doubles the power consumed by the load.

    Because of the low frequency, I ended to the NCO as Richard proposed. But have not found a way to drive this to an H-Bridge yet.

    The second problem is that at very low frequencies (0 to say 20 Hz) the power loss on the bridge transistors is high enough to destroy them because of violation of the SOA. I have to either put in parallel more devices or use a PWM signal to lower the losses and give time to the transistors to cool.

    So, the NCO signal needs to be modulated with PWM.

    Easy and complicated at the same time...

    Ioannis

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Sorry, mode 2 still isn't clear to me.... "2. Bipolar voltage on the load with a rate of 0-50 Hz"
    Do you mean...

    A) That polarity of the voltage across to the load is switched at 0-50Hz (and power is regulated by the dutycycle of the 1kHz PWM signal) or
    B) That polarity of the voltage across to the load is switched at 1kHz (the PWM frequency) and the 1kHz carrier is turned on/off at a rate of 0-50Hz or
    C) None of the above meaning I still don't get it :-)

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Do not know if or how NCO can be steered PWM/CWG module.


    Richard, also nice idea about CLC module. I suppose the low freq signal is external of the PIC. Or may be the NCO signal too.
    you need to have a good look at the data sheet
    valid cwg input's :-
    the nco
    a clc output
    any of the ccp /pwm modules
    the dsm output

    valid clc input's:-
    the nco
    any of the ccp /pwm modules
    the dsm output

    there are many possible methods of modulating a LF osc source with a HF pwm signal with the clc or dsm modules
    any of which can be turned into a full bridge signal source with the cwg module , try a few
    Warning I'm not a teacher

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Hope this draw clarifies a bit the problem.

    Ioannis

    Name:  bridge.JPG
Views: 358
Size:  555.4 KB

  14. #14
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    so where does the 1khz fit in ?


    i expected more like this
    Name:  Untitled.jpg
Views: 406
Size:  289.5 KB
    Warning I'm not a teacher

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    You are right, I just didn't want to clutter the draw.

    Ioannis

  16. #16
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Hi, Ioannis

    What drives your PWM ratio ??? Pot, control or ?

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  17. #17


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    looking at your diagrams, seems like you could ..... set up the PWM module for 1KHZ as normal, for the 20HZ part, set up a timer interrupt for the low freq maybe with a couple of roll overs for lower freq.... then on tmr int, only need to switch the Q's and add a little dead time on each switchover.

  18. #18
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Alain:
    The PWM is controlled by a Pot. I could also make a variable power supply and control directly the voltage on a SMPS circuit instead of PWM. More complicated.

    Amgen:
    It is easier on the unipolar mode. But gets difficult on bipolar drive having software to control both PWM, low freq signal and the control of the 4 MosFets transitors. Including deadtime.
    Better, most if not all of this be done on hardware using NCO, CWG, CLC etc.

    I believe that it is possible to do this as Richard is confident too. I just need more reading to understand how all these modules will work together.

    Ioannis

  19. #19


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    did you get someone for your h-bridge circuit ?? have a couple thoughts if not

  20. #20
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    The above seemed too complicated.

    I think I better use this design route:

    1. Use an PWM, NCO, CWG, CLC capable MCU like the ...K42 one. These chips may drive the PWM signal to the desired pin, so I can control the H-Bridge operation at will, according to the needs of the load.

    2. On the H-bridge use Gate the IRS2890 driver that has also current limiting capability.

    3. Use the MCU to control the upper Mosfets of the bridge as PWM to regulate the voltage required to the load

    4. Use the MCU to control the lower Mosfets of the bridge to control the On/Off of the 0-50 Hz signal

    On the above scheme, CLC may not be needed.

    On Monday I will order the required parts to assemble a prototype. Though it will be mostly on air I hope it will work good enough to verify the idea.

    Unfortunately the IRS2890 is available only in SMD but anyways...

    Have found MosFets that should cover the SOA that is needed.

    Any ideas welcome,
    Ioannis
    Last edited by Ioannis; - 31st March 2025 at 00:02. Reason: Instead of K22 I meant K42

  21. #21


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    what is the voltage and current you needed to supply the bridge??

  22. #22
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    It will be between 20-25 Volts.

    Load max 10-12Amps.

    At low pusling frequencies, obviously the 19mH coil will be more like a low ohm resistor, so the current will be limited.

    Ioannis

  23. #23


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    there are a bunch of these types of things with your I and V range. Thats why I was wondering if your voltage was like 200+ volts or 50-80 amps.
    .
    .
    Name:  h.JPG
Views: 57
Size:  171.1 KB

  24. #24
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    Wow!!! Amazing module! 40amps DC at 85 degrees? Can't believe it!

    Many thanks for this.

    Ioannis

  25. #25


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    just a thought too..... it is a lot of technology for the price, but sometimes these types of things, probably from China don't meet expectations.... but sometimes they are good!!!

  26. #26
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    You are right regarding the unknown chinese parts.

    I tried to find the specific chip but seems it is too old and stopped production by Infineon.

    Maybe they produce other, newer chips now. Have to search.

    Thanks anyway,
    Ioannis

  27. #27
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: PWM, H-Bridge and NCO - PIC16F18446

    The new one is the BTN8982 and is only produced at TO263-7 package.

    How do you solder this one on the PCB by hand?

    Anyway, have ordered the board that you showed. Hope it is an old stock and not any chinese fake chip. In a couple of days I will report. Either magic smoke or good news!

    Ioannis

Similar Threads

  1. Enhanced PWM Full-Bridge Mode
    By Zapman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th September 2022, 19:08
  2. Replies: 4
    Last Post: - 7th June 2011, 05:02
  3. Need guidance with DC motor controller - PWM & H-Bridge
    By rfetech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th November 2010, 03:33
  4. PWM with PIC16F88 controlling h-bridge
    By deimantas in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 20th May 2010, 22:03
  5. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18

Members who have read this thread : 16

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts