|
Sachiel,
A few things:
1. Beware of "automatic initialization" in embedded code. It almost never works. Unlike a PC, where the entire program (both code and data segments) are loaded by the operating system into RAM, an embedded controller loads into ROM... RAM is (at best) all zeros or (at worst) random noise when you boot.
If you need a table, load it into ROM and always EXPLICITLY initialize any variables.
2. Using Float or Double is pure "death by libraries" in an application like this. You have no floating point co-processor in this baby. More specifically, the PIC is a RISC processor (reduced instruction set). It does integer multiplication lightning fast (1 machine cycle) but that's it.
Any floating point reference invokes a software library routine which can be hundreds of instructions long.
Note that even a division operation in not supported by the machine code!
3. Plan what you want to do before you do it. What is the required update rate? What is your time "budget" for instructions within the loop?
Some professional help could not hurt... There are a million ways to get lost... Embedded programming is an art which take years to master.
KISS!
Good luck.
__________________
Mike Betts
Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013
As easy as 355/113...
|