• AVR Freaks

Hot!dsPIC33EP : Constant Current Closed Loop System [High Voltage]

Page: 12 > Showing page 1 of 2
Author
TS9
Super Member
  • Total Posts : 841
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
2019/12/30 10:32:39 (permalink)
0

dsPIC33EP : Constant Current Closed Loop System [High Voltage]

Hi, 


Constant Current is very much popular and used in UPS ,AC Drives etc.  In One of the application like below links:
https://www.google.com/ur...mp;cshid=1577730308680

https://pdfs.semanticscho...1f615089a8ced8c07e.pdf 


I have three parameters:
Set Current[From Keypad] , Read  Current  with ADC[from CT] ,varies Duty Cycle of PWM [Push Pull H-bridge] . 

What is the best way to achieve constant current with dsPIC33EP for High Voltage and High Current Application by changes its duty cycle ?

Is there any Application Note or Demo code available on Microchip web for dsPIC with CC  ? I have seen below link. 

https://www.digikey.in/en...load-using-pwm-and-adc


 --TS9
post edited by TS9 - 2019/12/30 11:28:21
#1

20 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3315
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 12:53:29 (permalink)
    0
    OK - the paper from Turkey looks somewhat more reasonable than the one from Cina, although both have their qualities...
     
    When talking about "high power" (> 1 A load current), only PWM is feasible to implement "constant" current. (From the E/E engineer's view the current won't be too constant - a ripple of maybe 1 % (give or take) is to be expected. Maybe even more...)
    To achieve some approximation of constant current, you'll need some inductance - at least in the load circuit.
     
    I don't know about any CC App Note, but I do not know all and everything. So just go to the AN overview
    ( https://www.microchip.com/wwwcategory/taxonomysearch/ ) and dig into these materials.
    - Power Conversion & Conversion  might be a good sub-topic to start with.
     
    P.S.: Do you have some reasonable knowledge about the E/E field? A Current Transformer won't do for DC currents (where the term constant current is applicable) !
    Otherwise I'd suggest not to fry yourself.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    Mysil
    Super Member
    • Total Posts : 3578
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: online
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 13:23:58 (permalink)
    0
    Hi,
    Constant Current, or current regulation is not much different  from any other regulation parameter,
    in a closed loop regulation system, aka. a PID regulator.
     
    Constant current regulation without any other limitations,
    may be dangerous, it may cause components to overheat, or batteries to explode, or voltage limitations to be exceeded.
     
    So current regulation is often just one of the parameters in a regulation system,
    Voltage may be another regulation parameter in the same system,
    together with Temperature if relevant.
     
    Current regulation is no different from other regulation parameters,
    in that you measure the current, compare it with the target value,
    and feed the difference to a PI or PID regulation algorithm that change PWM duty cycle,
    or activate whatever linear actuator that is controlling output.
     
    Many battery chargers work with current regulation in some parts of a charging sequence,
    but within limitation of other regulation parameters.
     
    If you are feeding a power system where other sources determine voltage or frequency,
    then you may want to regulate for Current or Power  contributed from your generator,
    whether it may be a windmill, a solar panel, or a diesel generating set.
     
    If there is high voltage, or othervise high energy involved, there may be more attention to
    emergency shutdown and other protection procedures, in case any parameter get out of range.
     
        Mysil
    #3
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 17:28:10 (permalink)
    0
    Hi Mysil,

    Yes, There are two values one is target and other is current or measured value.
    Is there any application note about PI or PID Implementation that explain how to change PWM Duty Cycle?

    Thanks for alert..
    -
    TS9
    post edited by TS9 - 2019/12/30 17:34:25
    #4
    Bob White
    Super Member
    • Total Posts : 277
    • Reward points : 0
    • Joined: 2010/11/06 19:52:38
    • Location: Denver, Colorado
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 17:43:54 (permalink)
    0
    TS9

    Yes, There are two values one is target and other is current or measured value.
    Is there any application note about PI or PID Implementation that explain how to change PWM Duty Cycle?




    Quite frankly, if you are asking that question you have a lot of work and studying to do before attempting to create a "high power" inverter of any type.

    Safety must be your highest priority at every moment of design and lab work.  Utility level voltages and currents can easily destroy equipment, cause fires, cause injury, and even kill you.  If you have not worked with utility level voltages and currents you need to find an experienced local mentor who can teach you how to work safely.
     
    Second, you need to study some basic power electronics/switch mode power conversion topologies, components/power devices, and basic controls.  The way you ask you questions leads me to believe you have no experience with any of these.
    #5
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 17:46:02 (permalink)
    0
    Hi,

    I have checked below links. https://www.microchip.com.orums/m/tm.aspx?m=420088


    https://www.google.com/ur...1ekHpnx_jRN3pm2MDXIqdl

    For some motor control application,
    but How Kp, Ki, Kd values come from?

    --
    TS9
    #6
    ric
    Super Member
    • Total Posts : 25244
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 17:46:36 (permalink)
    0
    TS9
    Is there any application note about PI or PID Implementation that explain how to change PWM Duty Cycle?

    The PIC datasheet tells you how to change the duty cycle.
    I suspect your real question is how to calculate what duty cycle value to change it to.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 17:48:46 (permalink)
    0
    robertvwhite
    TS9

    Yes, There are two values one is target and other is current or measured value.
    Is there any application note about PI or PID Implementation that explain how to change PWM Duty Cycle?



    Quite frankly, if you are asking that question you have a lot of work and studying to do before attempting to create a "high power" inverter of any type.

    Safety must be your highest priority at every moment of design and lab work.  Utility level voltages and currents can easily destroy equipment, cause fires, cause injury, and even kill you.  If you have not worked with utility level voltages and currents you need to find an experienced local mentor who can teach you how to work safely. Second, you need to study some basic power electronics/switch mode power conversion topologies, components/power devices, and basic controls.  The way you ask you questions leads me to believe you have no experience with any of these.

    Thanks for update.. And Alert
    I do have experience of Power Electronics.
    But I don't know how to implement PI or PID for my application?

    I am working in a team..
    --
    TS9
    #8
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 17:51:55 (permalink)
    0
    ric
    TS9
    Is there any application note about PI or PID Implementation that explain how to change PWM Duty Cycle?

    The PIC datasheet tells you how to change the duty cycle.I suspect your real question is how to calculate what duty cycle value to change it to. 


    Yes, I am able to change PWM with different duty cycles from Device datasheet/FRM

    PI or PID implementation for Duty Cycle,
    I don't know. So only this is real question.

    Never used/implmented PI or PID before in any application

    Edited:

    https://www.microchip.com....aspx?m=420088&p=1

    Do I need to do like above thread Msg#8?


    --
    TS9
    post edited by TS9 - 2019/12/30 20:00:03
    #9
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 20:47:34 (permalink)
    0
    robertvwhite
    TS9

    Yes, There are two values one is target and other is current or measured value.
    Is there any application note about PI or PID Implementation that explain how to change PWM Duty Cycle?



    Quite frankly, if you are asking that question you have a lot of work and studying to do before attempting to create a "high power" inverter of any type.

    Safety must be your highest priority at every moment of design and lab work.  Utility level voltages and currents can easily destroy equipment, cause fires, cause injury, and even kill you.  If you have not worked with utility level voltages and currents you need to find an experienced local mentor who can teach you how to work safely. Second, you need to study some basic power electronics/switch mode power conversion topologies, components/power devices, and basic controls.  The way you ask you questions leads me to believe you have no experience with any of these.


    I am work in team. Also for precaution, Firstly I will test algorithm with keyboard Set Duty Cycle , DSO for PWM and 10K potentiometer at ADC.
    post edited by TS9 - 2019/12/30 21:53:02
    #10
    Bob White
    Super Member
    • Total Posts : 277
    • Reward points : 0
    • Joined: 2010/11/06 19:52:38
    • Location: Denver, Colorado
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 22:02:27 (permalink)
    0
    A little study of control theory seems in order...
     
    PI (proportional-integral) is a form of a lead-lag compensator that combines an integrator pole at the origin (with some crossover frequency Wp) and a fixed gain (Kp, proportional gain).  The PI formula in the s-domain is:
     
    Hpi(s) = Kp + Ki/s
     
    If you plot that you see that gain starts high at low frequency, decreases at 20dB/decade, and then levels out at the fixed proportional gain Kp.
     
    You can, if you wish, apply the bilinear/Tustin transform to Hpi(s) to create Hpi[z] and then a linear difference equation.  The problem is that you don't have a ready way of using the plant characteristics to determine the compensator coefficients.
     
    To solve this problem the Hpi(s) can be re-written as a more typical lead-lag form as:
     
    Hpi(s) = Kp + Ki/s = (s*Kp/s) + Ki/s = (Ki + s*Kp)/s = Ki * (1 + (Kp/Ki)*s)/s = Ki * (1 + 1/(s/(Ki/Kp)))/s
     
    which gives the integrator pole at the origin and a zero at s = - Ki/Kp.  Now you can use the usual s-domain techniques to determine the gain Ki and the zero frequency (Ki/Kp).
     
    From there use the usual techniques to convert from the s-domain to the z-domain (discrete time) to generate the linear difference equation for the compensator that is implemented digitally.
     
    PID (proportional-integral-derivative) is also a form of lead-lag compensator which adds a differentiator to a PI compensator.

    Hpid(s) = Kp + s*Kd + Ki/s
     
    In the pole-zero from this becomes:
     
    Hpid(s) = (s*Kp/s) + (s²*Kd/s) + (Ki/s) = (Ki + s*Kp + s²*Kd)/s = Ki * (1 + (Kp/Ki) * s + (Kd/Ki) * s²)/s
     
    The problem here is that the differentiator term is a high pass filter that passes noise into the control signal. This is sometimes countered by adding a high frequency pole to attenuate the noise.  This high frequency pole (Whf) can be in just the differential path or to the combined output:
     
    Hpid_hfp(s) = (1 + (Kp/Ki) * s + (Kd/Ki) * s²)/(s * (1 + s/Whf))
     
    But you still have the double zero which could be complex (and can have its own problems).
     
    For me, it is easier to just go right to one of the standard lead-lag compensators.  If you need no more than 90° of phase lead in your compensator, then a standard Type II compensator is all that is needed.  If you need more than 90° of phase lead (and less than 180° of phase lead) then a Type III compensator is needed.


    #11
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2019/12/30 22:48:03 (permalink)
    0
    Hi,
     
    Thankyou very much for detail explanation . Control System  (lead-lag compensator )
    I have studied 10-15 Years back .. I will also on refresh now .
     
    After studying , Will below example in Msg#8 similar that i required? 
    https://www.microchip.com....aspx?m=420088&p=1
     
    And In Video...
    https://www.youtube.com/watch?v=q3DY9THM6lU
     
    Also , what will be the duration in micro seconds of PID algorithm in dsPIC33EP running at 120MHz in xc16 free mode compiler?
    --
    TS9
    post edited by TS9 - 2019/12/31 02:14:52
    #12
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 04:38:02 (permalink)
    0
    Hi,
     
    Any body  have some idea PID to Duty
    I have not found and dsPIC33EP library for PID in XC16 Compiler v1.31 under
    C:\Program Files (x86)\Microchip\xc16\v1.31\docs\dsp_lib
    ?
     
    --
    TS9
    #13
    du00000001
    Just Some Member
    • Total Posts : 3315
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 07:58:04 (permalink)
    0
    A well-designed control loop (including some PID) is easily capable of running at 50 kHz on a 60 MIPS (120 MHz) dsPIC. And the 50 kHz "limit" is less influenced from some performance limit but from design considerations regarding the power semiconductors (switching losses etc.)
     
    PID to duty? Why don't you read the respective application notes?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #14
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 08:39:07 (permalink)
    0
    du00000001
    PID to duty? Why don't you read the respective application notes?


    Is below link make sense for PID

    https://www.teachmemicro....-pid-control-tutorial/


    Please send me link of respective AN..
    PID to Duty Cycle.


    Thank you
    post edited by TS9 - 2020/01/01 08:42:30
    #15
    du00000001
    Just Some Member
    • Total Posts : 3315
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 14:19:14 (permalink)
    0

    Please send me link of the respective ...

     
    I don't know anything about your application other than that you intend to implement CC and/or CV on "high voltage" and/or "high current". Thus I provided you with the root to the Microchip ANs to serve yourself. Time to do "real work" instead of trying to ask a plethora of fancy questions showing that you have hardly more than no idea.
    We won't do your job, and we do not have unlimited time to fill-in what your eduation has left unfilled.
    If you're an engineer: continue your education! If you are no engineer: consider to employ one.
     
    BTW: The PID tutorial does make sense. For me.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #16
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 14:26:54 (permalink)
    0
    du00000001
    Please send me link of the respective ...
     I don't know anything about your application other than that you intend to implement CC and/or CV on "high voltage" and/or "high current"

    Thanks ..
    Did you check Msg#1?

    --
    TS9
    #17
    du00000001
    Just Some Member
    • Total Posts : 3315
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 14:44:28 (permalink)
    0
    Did you see Msg #2 ?
    If so: why do you ask?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #18
    TS9
    Super Member
    • Total Posts : 841
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 14:50:35 (permalink)
    0
    du00000001
    Did you see Msg #2 ?If so: why do you ask?


    Yes, I did not find relevant information in that link.


    --TS9
    #19
    du00000001
    Just Some Member
    • Total Posts : 3315
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: dsPIC33EP : Constant Current Closed Loop System [High Voltage] 2020/01/01 15:00:35 (permalink)
    0

    ... did not find any relevant information ...

     
    Oh. Seems to be time to uncover you project in detail (instead of cursory).

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5