Steer by wire - FOC Shield configuration

Hi everyone,

I am new in FOC matters and especially interested in Steer by wire. I have used exactly the schema and sketch from the official Simple FOC. The problem is, it is not working at all. Both motors move a little just at the beginning, when I plug the system. But nothing more happens.

I have 2 Simple FOC Shields V. 2.0.4. and right here are my pinouts:

FOC Shield No. 1: Solderpoints: 5V, A0, A2, A5, 11,13, 3, 7, 10, 6

FOC Shield No. 2: Solderpoints: 5V, A1, A3, 12, 2, 4, 5, 8, 9, 11

Well, that is the best I could do…I have respected all the rules of configuration, I hope… I really did not know if or how to incorporate eventually pins for the AS5600 - I2C – sensor. Is this configuration wrong? Or what else is to be done, so that the system works like in your video?

The schema and the sketch are exactly like on



Hi Martin, and welcome to SimpleFOC!

Do you think you could provide a picture of your solder-points, and maybe the code or link to the exact example you’re using?

You seem to be using 11 twice?

Hey @mar_kec,

Are you using the sketch from

You are abolutely right, I have not included the configuration of the shields, I should have.
I’ll try to upload them soon.

Could you also let us know what microcontroller and sensor are you using, that will help to debug.

Some of those configuration pins are only necessary if you are using 2 encoders.

Sorry, my configuration is:

FOC Shield No. 1: Solderpoints: 5V, A0, A2, A5, A4,13, 3, 7, 10, 6

FOC Shield No. 2: Solderpoints: 5V, A1, A3, 12, 2, 4, 5, 8, 9, 11.

The rest is below:

Steer by wire
using Simple**FOC Shield and Arduino UNO

#include <SimpleFOC.h>

// software interrupt library

#include <PciManager.h>

#include <PciListenerImp.h>

BLDCMotor motor1 = BLDCMotor(11);

BLDCDriver3PWM driver1 = BLDCDriver3PWM(3, 10, 6, 7);

Encoder encoder1 = Encoder(A2, 2, 500, A0);

void doA1(){encoder1.handleA();}

void doB1(){encoder1.handleB();}

void doI1(){encoder1.handleIndex();}

// encoder interrupt init

PciListenerImp listenerA(encoder1.pinA, doA1);

PciListenerImp listenerB(encoder1.pinB, doB1);

PciListenerImp listenerI(encoder1.index_pin, doI1);

BLDCMotor motor2 = BLDCMotor( 11);

BLDCDriver3PWM driver2 = BLDCDriver3PWM(9, 11, 5, 8);

MagneticSensorI2C sensor2 = MagneticSensorI2C(0x36, 12, 0x0E, 4);

void setup() {

// initialise encoder hardware


// interrupt initialization




// link the motor to the sensor


// init driver


// link driver


// set control loop type to be used

motor1.controller = MotionControlType ::torque ;

// initialise motor


// align encoder and start FOC


// initialise magnetic sensor hardware


// link the motor to the sensor


// init driver


// link driver


// set control loop type to be used

motor2.controller = MotionControlType ::torque ;

// initialise motor


// align encoder and start FOC


Serial.println(“Steer by wire ready!”);



void loop() {

// iterative setting FOC phase voltage



// virtual link code

motor1.move( 5*(motor2.shaft_angle - motor1.shaft_angle));

motor2.move( 5*(motor1.shaft_angle - motor2.shaft_angle));



Hi runger,

Sorry, Here is my right configuration:

FOC Shield No. 1: Solderpoints: 5V, A0, A2, A5, A4,13, 3, 7, 10, 6
FOC Shield No. 2: Solderpoints: 5V, A1, A3, 12, 2, 4, 5, 8, 9, 11

You find it as attached files too…

and the sketch:

Thank you!!!



I am using Arduino UNO, AS5600, AMT103, 2 x GM4108 and 2 x Simple FOC v. 2.0.4

The solder points are on the pictures.

The sketch - link is here: Haptics - Steer by wire | Arduino-FOC

Is my configuration wrong or maybe the shields are broken?



Hey Martin,

I hope we can get this working! Normally, the SimpleFOC shield is quite robust, so let’s hope it is not broken!

You mention AS5600 and AMT103:

  • the AMT103 can be connected to the encoder pins, there are examples in our docs
  • the AS5600 has to be connected to the Arduino’s I2C pins, SDA and SCL

Am I to understand you are using one of each kind of sensor, the encoder with one shield and the magnetic sensor on the other?

Did you connect the magnetic sensor to SDA and SCL?

Have you tried the boards separately, e.g. does each setup work by itself, with only one driver/sensor/motor attached to the Arduino?

You should test each setup individually first, making sure each of them is working well with open-loop, torque-voltage and then velocity mode, in that order.
I think if you try to debug everything all at once there are too many “moving parts” and it will be more difficult.

Hi Richard,

In between I tried hard to get my project working. Unfortunatelly without success. I am afraid I do not get it without some expert - advices… so I decided to send You in the attachement (upload)

a shrort decription of my project. In summary: I would like to accomplish a “STEER BY WIRE” project. Pls. could You have a look at the description in the attachment to tell me, if there is something wrong, that can not work or does not fit… or I dont know… I tried and combined really everything possible and I do not understand why it is not working. I am surely no profi in electronics and programming, but I tried my best logical approach…
Thank you so much !!!


P.S.: The drawing is awful, I know … :frowning: Just for orientation…

Thanks !!!

Hi Martin,

lets see if we can figure out what’s wrong…

My first piece of advice is to try the two setups independently first. This will be easier than trying to debug both at the same time. I know it won’t be steer by wire, but just to get sensor and motor working, so the motor turns, on each board independently, that would be a really good idea.

In terms of the boards, I think there are still some problems with the pinouts.

Looking first at the Encoder AMT 103 and middle board:

For the encoder, you use 2 pins: A5 and A4 and 13.
For the phases you use the pins: 9, 11, 3 - and pin 7 for enable.

This seems ok to me, but you probably want to change pins A5 and A4 because you need them for I2C.

Now looking at the AS5600 and upper board:

You’re using A5 / A4 for the AS5600 SCL and SDA. SDA should be A4 and SCL should be A5.
On the phases it is 10, 5, 6 and 8 for enable.

So this is a conflict with using A5/A4 for the encoder. You can’t use those pins for both the encoder and the AS5600. I suggest you change the solder spots on the encoder board to use pins 2 and 12, and adjust your code accordingly.

Next problem: on the AS5600 you’ve also got the 2 and 12 solder spots marked, and also 13 - since the upper board is not using any encoder, I would remove these spots.

You’ll have to use the PciListenerImp at least on pin 12 - Arduino UNO only supports external interrupts on pins 2 and 3, but you’re using 3 for the PWM.

In your code, you also don’t set any voltage or voltage limits, it might be a good idea to do so:

driver1.voltage_power_supply = 10; // your PSU voltage
driver2.voltage_power_supply = 10;
driver1.voltage_limit = 5; // start with a lower limit
driver2.voltage_limit = 5;
motor1.voltage_limit = 2.5; // set the motor limit to half the driver limit
motor2.voltage_limit = 2.5;
1 Like

Hi Richard,

thank you very much for your advices!

As you have written, I have removed the conflict with the pins. So on the upper board I use now only pwm pins 5, 10, 8, 6 and I have removed the encoder pins 12, 2 and 4.

On the middle board the pwm pins are as before 3, 9, 11, 7, but I have changed the encoder pins to: 12, 2 and 13 - and of course I changed the sketch accordingly.

For voltage limits I just copied, what you have written and I put it to the end of the sketch. I did not know, where else… Is that ok?

I put the sketch as an attachment… the changes are highlighted with yellow colour…

And finally, you have written the following: You’ll have to use the PciListenerImp at least on pin 12 - Arduino UNO only supports external interrupts on pins 2 and 3, but you’re using 3 for the PWM.

Well, I do not know how to do this… should I write something in the sketch to do it…? What exactly do You mean by: using PciListenerImp on pin 12 ???

I hope, this will be the last problem to solve… sorry…

Thank you.


Hi Martin,

The voltage limits should be set in the setup() function, before initialising the driver and motor.

Otherwise this code now looks better. Are things working?
I repeat again the need to really get these setups working individually first…