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

    fwd values : 0, 1, 3, 7, 15, 31, 63, 62, 60, 56, 48, 32
    reverse values : 0, 32, 48, 60, 62, 63, 62, 60, 56, 48, 32

    I have 2 truth tables with switches to turn on/off for these values.
    Now i have a pot and a switch start/stop and a switch fwd/reverse..
    Now we should not be able to change the sequence commutation if the pot is not 0 so I did a little code like this :


    Code:
    Direction VAR bit
    direction = 0
    
    Main:
    
            encoderstate1 = PORTA
            
            GoSub GetADC
            
            If ADRESH = 0 Then 'value of the pot stored in ADRESH
                If ADRESL = 0 Then ''value of the pot stored in ADRESH
                    direction = PORTE.1 'switch for direction
                EndIf
            EndIf
    
    if encoderstate = 0  then
    'switches turn ON/OFF
    elseif encoderstate = 1 then 
    'switches turn on OFF
    elseif encoderstate = 3 then 
    ..... etc
    endif
    
    goto main
    I'm getting desesperate to put all this together with my switches
    and my reverse sequence with if then. ifelse isn't working properly (need to have oldstate stored like you told me, Olson no ?)

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    I'm sorry, I can't keep up with you here.

    Did the Select-case version not work? Is that the reason why you're now using IF and ELSEIF? And did keeping track of the previous state thru the OldState variable not work? Or why did you skip that.

    If I got the sequence wrong did you try to correct it and see if the aproach I took would work or not or did you just abandon that idea because I had the reverese sequence wrong?

    If the only thing controling the sequence of the commutation is the desired direction then there's no reason to keep track of the previous state because then it doesn't matter.

    /Henrik.

  3. #3
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    hello, no I did try your great ideas, the case work for the forward direction but as my elseif code the case code for the forward does not work because the second half of the commutation is the same as the previous one. So in that case I think I need to have the old case. I will keep trying experiments, thank you for your time and ideas

  4. #4
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Do you have a good software for schematics ??

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Hi,
    Personally I use EAGLE from CADSoft, other popular packages are DipTrace and KiCAD but there are many many other in various priceranges. TARGET, OrCAD, Protel, DesignSpark, EDWIN, AutoTrax are a couple that springs to mind.

  6. #6
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    thanks eagle seems pretty nice, we have orCAD at the university but I really don't like it...
    I'm gonna try this eagle thing

  7. #7
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    you're right lol... I'm sorry that you've waisted your time with me, I also figured this out yesterday :s I waisted my time too.
    My last problem is to be able to switch frequency only if my pot = 0 (duty cycle = 0) so that the motor won't stall..
    Any ideas ?

  8. #8
    Join Date
    Jul 2011
    Posts
    29


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    The only problem i'm now having is with my reverse sequence...
    I tried with select case and oldstate and it does not work I don't know why

    If the only thing controling the sequence of the commutation is the desired direction then there's no reason to keep track of the previous state because then it doesn't matter.
    Yep that's what I thought so for the reverse sequence I tried something like this :
    If encoderstate = 62 Then
    'switches ON/off
    endif
    IF encoderstate = 63 Then
    'switchesON/off
    endif
    IF encoderstate = 62 Then
    'switches on/off
    endif


    The probem is that the switches (for a same encoder state (62)) should not be the same. When I tried the above code, it is kind of like it's doing the both If..Endif at the same time which is not good.
    Any more ideas ?, there's gotta be a way...
    Thank you in advance..

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


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Hi,
    No, I'm sorry, I've misunderstood this. You need to keep track of the old state since 62 are on both sides of 63 there's no way for a simple IF-THEN to determine if the if next commutation "step" should be that equaling encoderstate 60 or 63.

    In the forward direction that is not a problem since the same value isn't on both sides of any other value but in reverse it is so you'll have to keep track of the previous state as well.

    I must admit though that I still don't understand how this thing work. Let's say the motor is turning forward and then stops at "step" 7, ie EncoderState is 7. It now reverses direction, what is the next expected encoderstate? I don't see 7 in the expected sequence when moving in reverse but it has to be there since, no?

    I can't see how the actual numbers can change depending on the direction of rotation. I would guess that if going forward gives you this sequence:

    0, 1, 3, 7, 15, 31, 63, 62, 60, 56, 48, 32

    the reverse sequence would be:

    32, 48, 56, 60, 62, 63, 31, 15, 7, 3, 1, 0

    But you're saying it's not. Can you explain, show a diagram or a photo of how this thing works. How can the sensors give out the value 7 in one direction but not in the other? I mean, at that specific rotation angle some sensors are activated and others are not giving the binary value of 7, I can't see how it can be different depending on in which direction the shaft got there.

    I'm clearly missing something here but untill I understand how this thing really works there's no use in trying to come up with a solution.

    /Henrik.
    Last edited by HenrikOlsson; - 25th July 2011 at 13:44.

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