# Math With an 8-bit MCU

Status
Not open for further replies.

##### Junior Member level 3 So I'm making a spiderbot and am using 8-bit mcu's. To calculate the angle every joint has to be at, use various mathy things like the pythagoran theorem and tangents, it all works fine on paper, but i'm not so sure about whether it would work on an 8-bit mcu. I'm so late in the design process that changing to another mcu would really be a hassle though...I DO have that choice, I even have a dsPIC, so if that is REALLY necessary, I will do that.

A Little about my current configuration:

I have 4 mcu's in total, they are all pic18f47j53. I had to use more than one because the no mcu alone had 18 pwm signal sources (the robot has 6 legs with 3 Motors each, a 1D joint and a 2D joint).

So basically my current idea is that there's one master that sends out coordinates for each of the legs to the slave mcu's and the slaves calculate the angles and set the Motors in motion untill the angle is appropriate.

What the problem is:
I don't know whether the mcu is capable of calculating the angles. Having 8-bit values is enough for me, the maximum leg coordinate from the reference point of 255x255 is quite enough, but using those values to calculate other things can get to higher values, like 360.

The other thing is that can the pic succesfully calculate square, square root and tangets? I can make a lookup table for the tangents, but then I would need double precision numbers? Making a lookup table for the pythagoran theorem, I would need 255*255 bytes of memory, which is half of the amount available to the pic.

if I was to use the dsPIC, I would have to redesign and remake the pcb. In that setup I would still probably use 4 mcu's, but all the calculating is done By the master, and the angle values are sent to the slaves.

If the 8-bit pic can manage the calculations, even slowly, then I'd rather go that route and just make a short term memory for different leg positions because the values repeat a lot and recalculating them is silly anyhow( leg forward, leg backward, leg forward, leg backward.......)

#### FvM

##### Super Moderator
Staff member Most 8-bit PIC compilers provide the requested functions in their math library. You'll want to check if the involved code size and calculation time fits your requirements. I guess it does.

Status
Not open for further replies.