I want to control the position of a motor using a PWM output from Arduino as an input to a Polulu High Power Motor controller.
The PWM output from Arduino is calculated from the output of a 2D lookup table. The axis of the lookup table are inputs from two 0-5V sensor outputs.
Additionally, the motor position is fedback from a hall effect sensor and a PID function controls the position.
The fedback position from the motor hall-effect sensor has been measured and the range counted using the simple AnalogueReadSerial sketch runs from 136 to 964 counts. So my question is, do I need to convert this range into 0-255 so that Arduino can work with it? Does it also then need to be translated into hex values for storage in the flash memory (I am using the ideas for this found here: http://arduiniana.org/libraries/flash/
As I see it, I need a 0-255 table for the PWM output. Really I want a table of motor positions in degrees. So there will be alot of conversion going on!
- Convert 0-5V sensor ranges using lookup array for axis of main lookup table to 0-255 (or if linear output from sensor just use one line of code to convert (i.e. y = mx+c)
- Convert 0-5V motor position in degrees through measuring max/min count and convert to 0-255 using lookup array
- Convert desired motor position table in degrees into 0-255 for main lookup table PWM output (16x16).
Is there an easier way of doing this? Will I even have enough space on the flash for 3 linearisation curves and a 16x16 PWM lookup tabe?