Close

PSOC4 Controller software

A project log for 3D Printed Robot Actuator

A high speed and high torque robotic actuator using low-cost brushless motors, custom controller, 3D printed parts and bearings.

paul-gouldPaul Gould 05/16/2018 at 15:030 Comments

The software runs on the PSOC4 by Cypress and is a Programmable System on Chip which includes

In the PSOC4 you can choose between fixed blocks (as in normal micro-controllers) or Universal Digital Blocks (as in FPGAs). So features  like SPI, I2C, UART, Timers and Counters (PWM), can be either fixed or custom. 

I was hoping to say that is it fully configurable but it is really not. There are many limitations and work-arounds in both hardware and software. That being said, it is a brilliant chip, you can do many things without the CPU being involved at all. The sequencing SAR ADC is a good example of this. The IDE is good but hides too much low level functions. Things like being able to change the CAN ID on the fly meant searching through lines of undocumented c code.

The software/configuration went through many iterations depending on the Controller version.

Software Structure for Brushless Controller 2.0

The sub-routine for the controller loop runs at 10kHz and uses about 20% of the CPU time. Not bad for a 48MHz CPU and doing FOC. The main reason it runs efficient is the that FOC array is pre-calculated to suit the number of poles of the motor being used. The other two phases are just offsets in the main array. The output from the PID is just a multiplied by the FOC array and shifted to get the three PWM signals. There are no sin and division calculations in the controller loop.

The FOC array is based on modified sinusoidal waveform, often called saddle profile. It has the benefits of higher voltages between phases (than pure sin waves) and 1/3 less switching losses. The FOC array has 4096 (2^12) points and the Motor's Magnetic encoder has 16384 2^14 steps. Which is fine, because the encoder has some noise.

The hardware and software has been updated to the "file page".

Discussions