1 Continuous MCPWM at a time


Closed Thread
Results 1 to 40 of 47

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    yes, that would work, thank you, I will try that first thing in the morning tomorrow I will, of course, let you know.
    Thanks again for the help, really appreciate !

  2. #2
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    I have tried this, and it is still at 68% duty cycle maximum... I also tried with a 4MHz oscillator and PTCON0 = 0, and it gives also 68%.
    What are we missing ?
    Getting desesperate as I thought this would work but it seems it's not really the problem.. is it ?

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Have you checked the output of your potentiometer? It works just as expected for me from 0 to 100% duty-cycle on an 18F4431 @ 20MHz.

    Try the attached without making any changes.

    PCPWM_AD.txt
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Thanks it is working now, I made a huge mistake that I am so ashamed to make you waste your time with me. I am testing everything on a breadboard and my potentiometer was still connected to a resistance somewhere... I feel silly. Well at least it is working.

    I am grateful for your time and your patience.

    I am now getting started with my commutation sequence. Thank you again !
    Even if this pic is complicated, I'm starting to see how powerful it is.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    I made a huge mistake
    Been there - done that - just spank yourself, take notes & move on...
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Quote Originally Posted by Bruce View Post
    Been there - done that - just spank yourself, take notes & move on...
    I did

    Hi again !

    I would like your opinions guys in terms of "state of the art" way to write a picbasic pro program
    I am getting inputs from an encoder, I have 12 positions possible, therefore 12 values. here is an example of my code for 2 values. I was wondering if the use of "Case" would be a better idea, that way if I decide to turn off my "switch" my program stops immediatly and is not finishing its loop before seeing that the switch's value changed.

    Code:
    encoderstate1 var Byte 
    duty var Word
    
    Main:
    encoderstate1 = PORTA
    If switch = 1 Then
     
    
            If encoderstate = 0 Then
                GoSub GetADC
                GoSub SetPWM           
                OVDCOND = %00100010 'Q4 (PWM5) and Q10 (PWM1)
                PORTC = %00000011   'Q1 and Q7 ON
            EndIf        
            If encoderstate1 = 1 Then
                GoSub GetADC
                GoSub SetPWM
                OVDCOND = %00000110
                PORTC = %00001100
                
            EndIf
    
    GoTo Main
    Getadc is my subroutine for my pot and pwm to adjust the duty cycle regarding the value of the pot.

    Suggestions ?

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Hi,
    Sure, Select-Case is an option. It's "cleaner" but does result in slightly larger code than multiple IF-THEN statements. But if you're not short on space go ahead.

    Another option might be to use BRANCH.

    Also, perhaps you can move the GOSUB GetADC and GOSUB SetPWM to right after the If Switch=1 Then statement? That will save you a couple of bytes of program space and since, if I'm not mistaken, all twelve different encoder states calls both those routines you might as well do before evaluting the encoder value.

    /Henrik.

Members who have read this thread : 1

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