We are building soccerbots based on 28X Project Boards using AXE033, Lego Hitechnics Compass and IRseeker sensors on I2C. See thread here
http://www.picaxeforum.co.uk/showthread.php?t=17307
The PICaxe is calculating absolute heading (range 0-360)
While all works brilliantly the compass reading needs to be used in a proportional control scheme for the drive motors. When programming in C this is not an issue as we convert to a relative (to a setpoint) heading using a few lines of code. Thought it would be just as easy in BASIC but unfortunately the PIC doesn't allow negative numbers. I have been trying today to get around this by calculating an error (ie deviation from setpoint) and a direction but I am having trouble finding a simple solution. I must be missing something obvious here.
I have failed to find anything I can use on the forum but surely I am not the first to need to solve this problem.
Can anyone offer me some guidance here.
Thanks,
Fast Freddy
http://www.picaxeforum.co.uk/showthread.php?t=17307
The PICaxe is calculating absolute heading (range 0-360)
While all works brilliantly the compass reading needs to be used in a proportional control scheme for the drive motors. When programming in C this is not an issue as we convert to a relative (to a setpoint) heading using a few lines of code. Thought it would be just as easy in BASIC but unfortunately the PIC doesn't allow negative numbers. I have been trying today to get around this by calculating an error (ie deviation from setpoint) and a direction but I am having trouble finding a simple solution. I must be missing something obvious here.
I have failed to find anything I can use on the forum but surely I am not the first to need to solve this problem.
Can anyone offer me some guidance here.
Thanks,
Fast Freddy