Thread: Control Algorithm

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    3

    Control Algorithm

    Hi,

    I have been searching the net for some help, and stumbled upon this site that appears to have a wealth of information, and some rather intelligent people on it I have carried out a search, but to no avail

    I have this project to do:

    Turn a pot, which in turn communicates with a PIC18F252 to carry out PWM in order to move a motor/gearbox, using a bridge chip. The motor/gearbox has another pot connected to the shaft, which needs to send a feedback signal to the PIC.

    I'm fairly happy with how most of the program will work, with the exception of applying a control algorithm to control the PWM, therefore altering how the motor/gearbox responds to the input pot. My best guess is that I need to update a memory location with the algorithm writing to it, and the PWM reading from it, therefore setting the duty cycle as required.

    I will be using MATLAB to devise my control algorithm, and have been informed that it is fairly easy to transform this into the Z domain for the PIC.

    My ultimate question is how would I implement this Z code in a way that is suitable for C???

    I have limited experience with C, so please bear with me. I have been thrown into the deep end!

    Any guidance is appreciated

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If you need to write a value to a memory location, pal, you have *definitely* come to the right place!

    And welcome to the forum, lotfust.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    3
    Thanks for the welcome

    Yes, I do need to write to a memory location, ie:

    I/P pot and f/back pots are compared, if they are the same, nothing happens (in the process of sorting this out)

    If they are different, the value is written to a file.

    This file is read by the algorithm

    The algorithm manipulates the string in a way that has been predetermined by MATLAB (compensators etc)

    The algorithm writes the new value to another file

    PWM reads this file to set the duty cycle.

    My main concern is how to write the algorithm in C, when transferring it in Z from MATLAB onder:

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You have *got* to get those Pringles outta your mouth and quit MUMBLING.

    ... transferring it in Z from MATLAB onder:
    Never mind me, but I hope you get a LOT closer to the C portion of this. We've got some (geeks, eggheads, pocket protector types), er *people* around here that might be able to help with that part, though.

    I've only had Pi memorized to 16 digits, so I'm darn near useless!

    What was that Dilbert quote: "I'm gong to be an engineer, even if it takes me all day".

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    100
    Take a look at "PID" equations.
    Those are the general standard for positional or velocity control algorithms, and can be implemented fairly simply.
    Get started: PID control Algorithm

  6. #6
    Registered User
    Join Date
    Apr 2010
    Posts
    3
    Cheers for your help everyone...it really hit the nail on the head :0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM