PDA

View Full Version : C code for PID control using PIC18F452 with 3 individual potiental meter for kp,ki&kd



Lawrence
- 27th March 2011, 20:10
Hi ,
I am currently working as a sales but taking some part time course and need to do a mini project for a PID control using PIC18F452 or PIC18F877 but I am not good in C code as I am electricial trained.

Below is my project requirement:
Hardware interfaces :

(1) 4 potentiometers as inputs to set the values of Kp, Ki , Kd and desired speed setting via analogue channels
(2) A dc permanent magnet motor to act as the targeted process to be controlled.


(3) A driver circuit to power the motor to its desired speed , using PWM output control from the PIC controller ( unidirectional control will be sufficient )
(4) A speed sensor to provide speed feed-back signal to the PIC controller ( a tacho-generator mechanically coupled to the motor shaft will be the easiest interface)
Software codes in C :


(1) Speed of the dc motor to be adjustable by the setting of the speed potentiometer.

(2) A simple PID algorithm to enable the motor speed response characteristics to be adjusted via the settings of Kp, Ki and Kd.

I had already done a simple driver circuit to control a motor and it coupled with another motor which provide the output voltage. Can you help me to give me some ideas how to write c code for the PID requirement and also help to interface the circuit with my controller with the 4 potential meter intergated?