Greetings!
I'm attempting to put together a simple PID line following program. Of course I've got no experience with RobotC and minimal programming in C. I've done some searching on the web (hence my customized line folowing program

) and still can't get a good grasp of the PID control program portion.The issue I'm having is that I need to be able to manipulate the P, I, and D variables. I found this in the forums,
viewtopic.php?f=1&t=1430 but it's quite complicated... is there an easy way to simplify it?
The embedded PID control in RobotC
nMotorPIDSpeedCtrl[motorA] = mtrSpeedReg;
does not allow for variable manipulation. I also looked into the debug windows and the PID section under the NXT device was apparently put in for testing and not user input.
This is what I have so far:
const tSensors lightSensor = (tSensors) S1; //sensorLightActive
task main()
{
while(true) //an infinite while loop is declared with"true" as its condition
{
if(SensorValue(lightSensor) < 45) //if the lightsensor reads a value less than 45 the if code will be run
{
motor[motorA] = 75; //motor A is run at a 75 power level
motor[motorB] = 0; //motor B is stopped with a 0 power level
}
else //if the lightsensor reads a value greater than or equal to 45 the the else's code will be run
{
motor[motorA] = 0; //motor A is stopped with a 0 power level
motor[motorB] = 75; //motor B is run at a 75 power level
}
}
}
I'm not interested in getting the robot to stop or do anything else at the moment. The students just need to see how changing the P, I, and D variables affect the movement of the robot.
Thanks!