DT-Ints latency and other interrupt conciderations


Closed Thread
Results 1 to 40 of 59

Hybrid View

  1. #1
    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

  2. #2
    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

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


    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.

  4. #4
    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

  5. #5
    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

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


    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.

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

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