PID help


Closed Thread
Results 1 to 2 of 2

Thread: PID help

  1. #1

    Default PID help

    Hello,

    I found this snippet of code for a PID written in picbasic. I need some help understanding a few things....

    1). What size are the variables? byte, word..?
    2). I don't want to use the X2 board. I have a PWM port set up for PWM driving an H-bridge using portb.0 and portb.1 for forward/reverse directions using 16F877A. How would I change the code to reflect the internal PWM and portb direction bits?
    3). What is going on with the LOOKUP bit of code? What is it trying to do?

    I am running a small electronic motor off of AA batteries, I am creating a servo.

    Best Regards,
    Nick


    PID-Control-Implementation-1.doc

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    957


    Did you find this post helpful? Yes | No

    Default Re: PID help

    Nick,

    Let me try to answer your questions

    1 - Word
    2 - Very simply, if Drive is a positive value, you move forwards, and vice versa
    The pwm magnitude can be set by the ABS(Drive) value
    3 - The LOOKUP command is checking if the value in Drive is positive or negative and filling Direction with either f or r.
    Understandably, the board wants the direction input to it as either 'f' or 'r' for forward or reverse

    Regards

Members who have read this thread : 0

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