• AVR Freaks

Hot!dsPIC33EV

Author
Soli8592
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2019/09/16 12:22:47
  • Location: 0
  • Status: offline
2019/10/10 11:56:07 (permalink)
0

dsPIC33EV

Hi there, I need to implement a pwm with a variable duty cycle. Is there any code available with header files? I am using MPLAB. 
 
Also, what is the best way to implement a look up table for a sine wave?
 
Thanks. 
#1

6 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 17958
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: dsPIC33EV 2019/10/10 12:56:21 (permalink)
    0
    1. What PIC?
    2. MPLab what?  MPLab X? MPLab  8?
    3. The "best" way for Project depends on your Project.
     
    There is some information in the "FRM" Documents that can be found on the Web page with you DataSHeet.
    MCC is an option if You unnamed Chip supports it.  AND would Require MPLabX.
    #2
    Soli8592
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/09/16 12:22:47
    • Location: 0
    • Status: offline
    Re: dsPIC33EV 2019/10/10 13:30:34 (permalink)
    0
    I'm using dsPIC33EV256GM106, and MPLAB X IDE.
    #3
    JPortici
    Super Member
    • Total Posts : 822
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: online
    Re: dsPIC33EV 2019/10/10 14:09:25 (permalink)
    0
    writing to a specific register will let you change the duty cycle. Which one? Look in the datasheet. It's pretty straightforward.
     
    For a sine lookup table search for "sine lookup table" in google. There are websites that do it for you. Otherwise if you want to do it on the fly well.. just do it as you would do it by hand.
    #4
    NorthGuy
    Super Member
    • Total Posts : 5761
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: dsPIC33EV 2019/10/10 14:16:48 (permalink)
    5 (1)
    Just use a timer interrupt (for the same timer which runs the PWM) and change the duty cycle with the value from an array (which is the best implementation of the lookup table).
    #5
    Soli8592
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/09/16 12:22:47
    • Location: 0
    • Status: offline
    Re: dsPIC33EV 2019/10/10 14:43:18 (permalink)
    0
    Sounds Good. Thanks for all the recommendations. 
     
    As of now, I am using a timer interrupt to change the duty cycle. Now the plan is to manipulate the memory to store the sine wave look up values and use a pointer to access those values. 
     
    Thanks all. 
    #6
    mpgmike
    Super Member
    • Total Posts : 326
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: dsPIC33EV 2019/10/10 19:23:09 (permalink)
    0
    Quick side note, you can produce a PWM signal with the PWM Module as well as Output Compare.  With the PWM Module you are locked into specific PORT Pins (PWM1H, PWM1L, PWM2H...).  With Output Compare, you can use PPS to assign the output to any RPx pin.  I found for a simple PWM the OCx Function is easier to work with than the PWM Function.  You still get >16-bit resolution using the OCxR and OCxRS registers.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5