DT-Ints latency and other interrupt conciderations


Closed Thread
Results 1 to 40 of 59

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    The protoype, on which I managed to get 60kHz+ yesterday, is still running on 20Mhz which makes me believe I should be able to reach my target of 100Khz even after adding the "front end" and some other features.

    But right now these serial routines is making me go nuts....

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Well, if you go from 20 to 40 MHz then your nice 60KHz is made with no pain 120KHz. That is more than 20% of your target, leaving you with a margin for the serial communication.

    Why not try this first, to ease the pain?

    Ioannis

  3. #3
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default one more question for Mr Henrik;

    once again, thanks for the wonderful pid filter. im still troubleshooting, and my main problem is this;
    Code:
     MAIN:                                             
         IF POSITION < SETPOINT THEN                  ;decreasing the setpoint                
         pid_Error = setpoint - position            ;calculate error
         ENDIF
         IF POSITION > SETPOINT THEN                  ;increasing the setpoint
         PID_ERROR = 65535-(POSITION - SETPOINT)    ;calculate error                                                              
         endif         
         gosub pid                                  ;take error to pid filter  
         DIRECTION = pid_out.15                     ;determine direction
         PID_TEMP = ABS PID_OUT
         DUTY = PID_TEMP                            ;load duty cycle from pid_out
         select case DIRECTION                      ;direction bit to control    
         case 0                                     ;  hpwm 1 for forward or hpwm2     
         GOSUB FORWARD                              ;  for reverse to corresponding
         case 1                                     ;  h-bridge circuit 
         GOSUB BACKWARD                             ;
         END SELECT
         LCDOUT $FE, $80, "POS=" ,DEC5 POSITION, " SP=" ,DEC5 SETPOINT; temporary
         LCDOUT $FE, $C0, "DT=" ,DEC5 DUTY, " ERR=" ,DEC5 PID_ERROR   ; temporary                 
         goto Main
    my calculated pid_error jumps from 65534 to 00001 , skipping two numbers; 65535, and 00000. i have the recommended position calculation,
    Code:
     position = 256*poscnth + poscntl
    this runs from a dt_interrupt (thanks Darrel Taylor). i tried to change setpoint and position variables to byte, instead of word, but pid filter works on word variables, and all calculations get messed up. any solutions? this has been my biggest headache on this project, for the last three weeks. and any help from anyone will be highly appreciated. thanks in advance.
    NAG CON WIFE!
    WIFE VAR MOOD

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


    Did you find this post helpful? Yes | No

    Default

    Hi,
    It "skips" 0 because when Position=Setpoint (ie. Error should be 0) neither of your < and > evaluations are true so it won't even calculate the error. Why it skips 65535 I haven't figured out though. Can you explain why you have those two comparison statements?

    All you really should need to do is pid_Error = Position - Setpoint or Setpoint - Position if you prefer it the other way around, it doesn't matter as far as the PID routine is concerned.

    Let's say pid_Error = Position - Setpoint (all three are 16bit variables):
    If Position is 10000 and setpoint is 9000 the error will be calculated to 1000
    If Position is 9000 and setpoint is 10000 the error will be calculated to 64536 (-1000)
    If Position is 1 and setpoint is 0 the error will be calculated to 1
    If Position is 0 and setpoint is 1 the error will be calculated to 65535 (-1)

    Just pass it to the PID-filter, it figures out the sign of the error.

    /Henrik.
    Last edited by HenrikOlsson; - 7th January 2010 at 19:52.

  5. #5
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    THAT FIXED IT!!

    man, thanks, and pardon my blindness. i did not know that the pid filter takes care of all the math! every little bit! the more reason of printing these pid filter code, framing it and hanging it on the wall next to the family portraits!!!

    i had it like that to fix a problem, when using two hpwm's the duty cycle would shift over to pwm2, from pwm1, and vice versa at position roll-over, no matter where setpoint was. that problem has dissapeared also.

    thats one hurdle over, and now over to implementing the power control on the same chip, to drive a h-bridge driver.

    this chip has 8 pwm outputs (4 complementary pairs) ill try as much as possible to implement full motor control from this same chip, as opposed to using a separate driver, like the lmd18200.

    thanks
    david m
    NAG CON WIFE!
    WIFE VAR MOOD

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


    Did you find this post helpful? Yes | No

    Default

    That's great!
    Yeah, the 18Fxx31 has some very cool features indeed. I intend to scale up as well once I get the basics going. My prototype uses the LMD18200 and I've abused it quite a bit, still haven't managed to let the smoke out of it though :-)

    Keep us posted on the progress!
    /Henrik.

  7. #7
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Cool Board design

    hi guys
    spent all weekend, maintaining the marriage, NFL playoffs and designing the board for the servo.
    attached is the board im trying to design. its nearly done, needs to be optimised, and copper flooded.
    im using eagle pcb pro.
    i decided to go the old school way; adjust pid variables using pots, and display them on a 20x2 lcd. later on, lcd will be replaced by serial communication, for serial lcd, or pc serial port.

    there are seven ports representing; i_term, output_clamp, integrator_clamp, minimum duty cycle, proportional, integral and derivative.

    i went to fire up my cnc pcb router, to make this board, and found out that my x-axis is completely dead. needs a new sla7078 unipolar driver. this is what im trying to replace with this servo project.

    ill probably order some 7078's, or use press and peel blue (thats how i was making boards before the router came along)

    im using the power control module on the 18f4431. its way much better than ccp pwm. its configured to use channels 0,1,2,3, in independent mode, so 0/1 produce same duty, and turn on at the same time, while 2/3 is off, and vice versa.
    the fet drivers are ncp5181, of which i could find at mouser.com, and has a bunch of application notes on the web.
    still optimising and trimming down the code, which is still undergoing extensive testing.
    have fun everyone....
    Attached Images Attached Images  
    NAG CON WIFE!
    WIFE VAR MOOD

Members who have read this thread : 2

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