emekbot - a PID controlled robot
I have updated the code, and made a project page for it on github. PID now works nicely.
This is my experiment. It has a LSM303 compass, an arduino nano. Compass is mounted at a tower. There is also a bluetooth module that will send data. I am using the arduino PID library to turn towards a heading. The results are much nicer then using if else type clauses to find the heading. There are however some jittering. I will be posting the source code also. The loop is designed such that it can accept commands and do other things, while the bot is moving. I am a professional coder and this is my little experiment as to what can be done with a primitive platform such as arduino.
Here are code highlights:
1. non-obstrusive loop. for example, when the robot is executing a command, it can perform other tasks. this was hard to accomplish. in my first version, i could not send an emergency stop signal, while the robot was executing some task. but now, with each loop it will do whatever adj is necessary, and then go on to next task. for example if you send 's' over bluetooth, it can stop.
2.will accept commands over bluetooth serial. here are commands:
'c' will return current heading
'h180' will make it turn to 180
's' emergency stop
3. there is a PID control loop. what i have done is to set the target variable always to zero. process variable is angular difference between targetHeading, and currentHeading. the output is used to control motors. I can not say it is perfect yet, but it works. The heading algorithm now works perfectly.
No delay statement is used while looping, and it samples the compass and adjusts motors at 200Hz.
Here is the project page on github