Close

Motor Simulation and Sin/Cos Encoder Support

A project log for Axiom: 100+kW Motor Controller

High Power, High Performance 400V 300A 100+kW Motor Controller fully compatible with VESCĀ®

marcosMarcos 04/15/2019 at 00:062 Comments

Today some code we developed for the VESC platform was merged into the master branch, reaching thousands of current VESC users.

Motor simulation inside the firmware is a critical step in our path to having the greatest controller out there.

It runs in cpu time, you can halt the debugger, take a look, and resume operation. Or you can perform  slow code coverage tests to ensure you have exercised all the lines in your code, often required by some industries.

Here is a screenshot of a motor startup being simulated:

The virtual motor is modelled as an IPM machine, and is engaged from the VESC Terminal inside the GUI.

More details in our Pull Request

The other piece of code we authored is Sin/Cos encoder support. These encoders provide absolute rotor angle feedback, no need to wait for indexes. They provide 2 sinewaves in quadrature, and by reading that signal the code can calculate the rotor angle.

Medium power motors are commonly using this kind of feedback. Zero bikes use them for example.

Here is the signal input:

And resulting phase measurement:

Here is the Pull Request, and the line of code that calculates the angle

Discussions

Kirill Kostyuchenko wrote 10/21/2019 at 18:44 point

How I can change simulate external force affecting virtual motor? I'd like my control loop see pos changing.

  Are you sure? yes | no

Kirill Kostyuchenko wrote 10/21/2019 at 18:21 point

Hi Axiom,

I'd like to write custom control loop for VESC FOC mode. 

I'd like to start writing and testing my control loop using virtual motor. Please help me a bit with example of using virtual motor and custom control loop like here: http://vedder.se/2015/08/vesc-writing-custom-applications/

I have to set motor current depending on absolute motor position.

Thanks for any help.

  Are you sure? yes | no