DT-Ints latency and other interrupt conciderations


Results 1 to 40 of 59

Threaded View

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


    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.

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