B-G431B-ESC1 Encoder initialization + Energiemanagement

Hey guys,
I am using a hub motor with an encoder (4096 steps/rev) but I don’t have an indexing output at the motor.
I want to use the encoder to get a smoother run of the it at low speeds. Therefore i am not interested on the position of the motor. So as used on the Hall-Sensor code, it would be great to skip the initialization process.

When using the software interrupt library PciManager, I am not able to upload the code to the board.
When I try to upload the encoder_software_interrupts_example.ino sketch, i get this response:
image
image

If I change the values to the specifications of my encoder, I get the same result.

Is there a way to tell the motor.initFOC() the initialization process data, as when using Hall sensors??

And while I’m here, I plan on powering the setup with batteries. How are my changes to get a deepSleep for the B-G431B-ESC1? Or at least lower the power consumption when the motor is not in use?

Hey @SimonFO,

While you might not need the position of the motor for your purposes, the SimpleFOC algorithm needs to know, very precisely, the position of the motor’s “electrical zero” position to work correctly.

So while you can pass the offset to the motor.initFOC() function, it won’t work with encoders unless you also pre-initialize the encoder’s pulse count to the correct value, so that the sensor angle given by the current pulse count + the offset actually equal to the motor’s electrical zero…

In theory this is possible by storing/restoring the values, but it will fail if the motor shaft is moved in the meantime.

You will have this same problem if you put the CPU into deep sleep mode and don’t keep counting the encoder pulses…

This is where (absolute) magnetic sensors have an advantage over the encoders. Because they are absolute you can just calibrate once and then remember the offset.

Hey @runger

Thank you for the helpful reply. I will get back to the Hall-Sensors than.

Since you mentioned the deep sleep, too. Do you have an idea, how I can get the driver into a deep Sleep state and waking it up with an interrupt?

I kept on working on my project in the meanwhile, because i am very new to SimpleFOC I have to read much to get things working properly.

But what I didn’t find information about is on how to get the Motor to freewheeling. I tried disabling the driver and the motor in the code, but that doesn’t really work, I suppose.

Do I have to set the phase_voltage = 0, or is there an other way to get the freewheeling working?

Thank you.

In principle the STM32 MCU that’s on there can be put into deep sleep. This isn’t the simplest thing to do, and it is documented in the data sheet. There do seem to be some Arduino libraries to help you though:

Note that waking from deep sleep is like restarting the MCU, memory will be cleared, so you’ll have to save the motor position and initialisation data to flash or redo the initialisation actions (motor alignment) each time you wake up.
Personally I would save this function for the end, once other stuff is working.

The motor.disable() function sets all the PWM outputs for the driver to 0, normally meaning the high side FETs are off and the low side FETs are on. This means the motor’s windings are not energised, and you can spin it freely, with only the natural opposition to motion caused by the motor’s permanent magnets. Is this what you mean by freewheeling?
The ESC board uses fairly simple separate FET drivers, which don’t have a disable pin. If you want to switch all the FETs off (leaving the windings “unconnected” and the current flowing out only via FET’s body diodes) it’s possible, but not without some modifications. Basically you’d have to disable the motor driver, then disable the hardware timer the driver is using, and then set all the driver control pins to low (using digitalWrite() ).