DT-Ints latency and other interrupt conciderations - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 59 of 59
  1. #41
    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

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


    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.

  3. #43
    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

  4. #44
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    cant figure out how to get a clearer image; wish we could post in .tiff format.
    Last edited by DDDvvv; - 10th January 2010 at 19:20. Reason: repeated

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


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Cool! The picture is fine!
    Personally I've been fighting with the serial buffer routines all weekend. I've got everything working in a separate program but when I tried to integrate it with the rest it started to act up.

    After to much trying this, trying that I decided to start over, deleted the current version and went back to an older one. Turns out it was older than I thought so now I have to redo a lot of stuff I thought I had backed up - stupid....

  6. #46
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik,

    Discussion on the servo driver has been quiet for a while. I hope you haven't lost too much of your work!

    As far as the comm, are you just using it to adjust the PID or is the intent to feed data out frequently?

    Bo

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


    Did you find this post helpful? Yes | No

    Default

    Hi Bo,
    I managed to redo what I had lost fairly easily and have been working on it since then. I moved the serial send rountines to the main routine, sending one char each pass thru the routine - if there's nothing more important to do. The serial comms are mostly for setting the various parameters but also for sending internal variables out to help tuning. Currently I have a mode where it spits ot the current error at 50Hz.

    I've added velocity feed-forward to the PID routine and I'm now working on acceleration feed-forward. Code size is my biggest concern at the moment, I'm up to 7400 words so it's starting to get tight - and I have many more features I'd like to add.

    Have been adding and changing a lot of stuff withot retesting what kind of step-rates I can get so I may need to take a step back again - we'll see how it goes.

    /Henrik.

    EDIT: Duh....make that 7400BYTES - not words, plenty of space left in other words :-)
    Last edited by HenrikOlsson; - 30th January 2010 at 15:10. Reason: Temporarily lost track of the difference between bytes and words....

  8. #48
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default

    Cool!
    UHU, watch out!
    I have been trying to piece together a servo driver on a much smaller scale and attempting to glean from you and others the best way to do it. Speed, error, and mass are of minimal concern due to the application. I am going to drive an LMD18200 and 18F2431.
    Looking forward to seeing your progress
    Bo

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


    Did you find this post helpful? Yes | No

    Default

    Still got a long way to go before it can compare with the UHU-chip, it's quite impressive how much Uli has been able to get that little AVR to do - without hardware encoder counter. But yeah, the long term plan is to be able to replace the UHU chip on my HP-UHU boards with this one - but that's still a long way to go.

    My "developing platform" is exactly what you have, a 18F2431 and a LMD18200. I can't believe that the LMD18200 still lives after all the abuse I've put it thru.... Still using CCP1 for the PWM here but will change over to PCPWM module after re-designing the board.

    So, how's your project going? What type of control, position, velocity? Command source, ananlog, step- and direction, high level serial commands?

    /Henrik.

  10. #50
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default

    HI Henrik,

    The project is an extension of a prior post regarding electronic gearing. I have been using a Gecko 320 and it is way overkill for this app. The most that it will see is 500 Hz from the encoder at x4. It has very little mass and that makes the error handling easier. Like everyone else, I have way too many projects going on simultaneously, so this one is not getting the concentration that it needs. So far, I have been just following this and 3 or 4 other related threads and trying piece everything together to learn.

    I hope to get back on it by the weekend.
    Thanks for all your work, it is encouraging.

    Bo

  11. #51
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default serial comm to eeprom issues

    hi everyone,
    i burned my 18f4431 after reversing the 5v power supply (warning!!!>if using power on the icsp cable on the ql200 dev board, black cable is +5v and red cable is gnd!! thanks to the hongkong designers for defying convention!!!!

    now im stuck using the 2431 until my mouser order arrives on thursday. this means that all parameters are to be adjusted through hserin to eeprom. i managed to get this working:
    Code:
         DATA @0, WORD $0140          ;P EEPROM
         DATA @2, WORD $0020          ;I EEPROM
         DATA @4, WORD $0025          ;D EEPROM
         DATA @6, WORD $0000          ;INTEGRATOR CLAMP value in eeprom
         DATA @8, WORD $01FF          ;OUTPUT CLAMP value in eeprom
         DATA @10, 8                  ;I TERM value in eeprom
         DATA @12, 5                  ;MINIMUM DUTY value in eeprom
         
         READ 0, pid_Kp.LOWBYTE      
         READ 1, PID_KP.HIGHBYTE                    
         READ 2, pid_Ki.LOWBYTE
         READ 3, PID_KI.HIGHBYTE                                          
         READ 4, pid_Kd.LOWBYTE
         READ 5, PID_KD.HIGHBYTE                                                                      
         READ 6, pid_I_Clamp.LOWBYTE
         READ 7, PID_I_CLAMP.HIGHBYTE                                          
         READ 8, pid_Out_Clamp.LOWBYTE
         READ 9, PID_OUT_CLAMP.HIGHBYTE               
         READ 10, pid_Ti                  
         READ 12, MIN_DUTY
    i can display all these variables using a hserout, with no sweat. the problem starts when i try to adjust the values using hserin, from a terminal program on my pc (realterm) i tried using a serial dt-interrupt routine and it shows that pc and pic are communicating, but i cannot figure out how to grab the word variables from the receive buffer and load them onto eeprom. how are you guys doing it? im just playing around with this, until i get my 4431's of which ill be using adcin to change all variables.
    here's what im trying:
    Code:
    on serial receive interrupt, read RCREG, TO RX_TEMP1
    if rx_temp1 = "P" then read RCREG to rx_temp2, then read rcreg to rx_temp3
    write value of rx_temp2 and rx_temp3 onto "p" in eeprom
    thats the idea in pseudocode. i know im doing it all wrong, and please be gentle with a beginner. thanks for reading.
    NAG CON WIFE!
    WIFE VAR MOOD

  12. #52
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    The way I do it is (basically) having an interrupt triggered by the USART when a character is received. The ISR takes the char and puts into an array that acts as a buffer, then it increments a "pointer" so it knows where in the array to put the next byte when it comes in. Finally it checks if the recieved char is a LF or CR - if it is it sets a flag, telling the main rountine that there's data to take care of.

    The main routine sees the flag and looks at the first character in the array, if it's a "P" it knows it's supposed to set the proportional gain. Next it uses the "pointer" to determine how many charcters there are in the buffer and finally it uses ArrayRead to "convert" the correct number of ASCII characters in the buffer to a value.

    In reallity it does a bit more than that but that's pretty much how I did it.

    /Henrik.

  13. #53
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    thanks for the prompt reply. it will probably take me 2 days to figure out some working code for just that, but i dont mind. i found out this is the best way to learn programming. meanwhile, im trying to design a h-bridge test board for a 2431. ill keep you updated on results.

    thanks
    NAG CON WIFE!
    WIFE VAR MOOD

  14. #54
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default pid tuning problems

    long time no see, henrik... hows your project going?
    i managed to get my h-bridge working. im having trouble tuning the values. i spent all weekend trying to tune a motor at no load, and i kept getting overshoot, undershoot, oscillations, runaway, e.t.c.
    im aware that tuning values are unique for every different model of motor, and i've tried all the tuning methods out there. im spoilt by those you-tube videos of pid motor position control.

    how do you do it? ive tried the zieger-nichols, and every other tuning idea online, but to no avail. what kind of values do you use for your motors? ill take any parameters, no matter what motor you use, after spending a whole weekend tuning.

    thanks
    NAG CON WIFE!
    WIFE VAR MOOD

  15. #55
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I usually (well always) do it "by feel"....

    Leave I at 0 to begin with it, add P until you're starting to see severe overshoot or it starts to oscillate. When that happens start adding D to dampen it out. Once you dampened it you should be able to add some more P and then follow with even more D. Finally add I to get rid of any steady state error and increase the "stiffness".

    On my "developmemnt system" with a smalish (30W) DC-motor, 500 line encoder (2000cpr) and LMD18200 H-bridge I have P:1500, I:100, D:2000, Ti:1

    Remember that with very high gains there is a risk of overflowing the internal calculations (there's are no checks for that in PID routines). That would make the loop highly unstable and might cause the servo to run away. I'm not saying that is what is happening in your case, just that it's a possibility. It's also very imortant to set the output clamp to a proper value so you're not overflowing the PWM duty cylcle register.

    What's the resolution of your encoder?

    /Henrik.

  16. #56
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    thanks for the reply. ill try your values. my encoder is only 100cpr on a yamamoto 24v motor, ripped off a photocopier machine. i have a bunch of other motors and encoders, upto 1500 cpr. does the cpr make a difference, other than more precision?
    NAG CON WIFE!
    WIFE VAR MOOD

  17. #57
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Yes, it makes a hugh difference. Think about it...what if you only had four counts/revolution, then the motor could move 90 degrees without the system even knowing it. Same motor same settings but now with a 2000 counts/rev (500 lines) encoder, the 90 degree displacements now results in an error of 500 counts. This give the servo-loop a lot more "information" to work with which helps in stabalising the loop.

    If that is a 25 line encoder (100cpr) then that may be a big part of your problem. Trying 'my' values with that motor/encoder probably isn't going tp help you one bit. If possible try with a higher resolution encoder.

    /Henrik.

  18. #58
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    oh no.. the encoder is 100 lines per revolution, giving a quadrature resolution of 400 cpr.

    ill try the 1500 lines per revolution, thats 6000cpr! anyway, ill experiment with all the encoded motors that i have. thanks
    NAG CON WIFE!
    WIFE VAR MOOD

  19. #59
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Smile Finally, success!!!

    after much troubleshooting, i finally found my mistake. i forgot that the pwm module has always been running at 20khz.

    i changed that to minimum allowed for 40mhz operation, which is 2.5khz, and the servo is running like a dream. thanks for all the ideas and tips.

    im starting a ac servo thread, since i got the dc servo going , and i hope ill get the same help and ideas.

    thanks guys.
    NAG CON WIFE!
    WIFE VAR MOOD

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