SimpleFOC came up in a discussion about a motorized autonomous tricycle and we thought it might make an interesting example project to demonstrate use of brushed, brushless, and stepper motors all in the same project and syncronizing their movement automagically with a bare minimum of user input. Its just a napkin sketch currently. Seems possible.
Would like feedback whether you think this would be useful as an open source educational demonstrator prior to investing more time in it.
2 Brushed wheel motors in a symmetric differential drive configuration without encoders.
1 Brushless wheel with hall effect encoder.
1 Stepper with incremental encoder controlling the steering angle of the brushless wheel.
The brushless wheel may be in front or behind the brushed axle and you do not need to tell the software. Encoder count and direction does not need to be specified, it just needs to change in proportion to steering angle controlled by stepper. Wheel diameters and other build dimensions do not matter. Attach any hardware conforming to the above lines, set it on open level ground and it will do a self calibration and just work.
The goal is to write software controlling multiple SimpleFOC modules which will sense what type of motor and encoder is plugged into each port. Brushed motor ports will be open circuit on exactly 1 phase. Stepper port will be the only one with an incremental encoder. Brushless will have all 3 phase connections. The auto configuration can attempt motion on various ports and look for encoder and current feedback to determine which is which.
At first, the brushless wheel and steering axis are undriven and their sensors merely observed while brushed wheels are driven.
Once ports are sorted, apply equal low voltage to both brushed motors until steering encoder settles into a stable value or a stable oscillation. Stop. This direction will be assigned as Forward and can be toggled by user. Because the brushed wheels are coupled to the brushless through the ground, watching the hall commutation sensor rate while driving straight establishes a relationship between brushed Kv and brushless commutation rate.
Apply opposite, same low voltages to each brushed motor until steering encoder settles into a stable value or a stable oscillation. This direction will be assigned as full left spin. Note the number of encoder transitions and encoder direction from “Forward” state to “full Left spin” state.
Repeat for Backward and full Right spin. The difference in number of encoder transitions between Left and Right spin is an indicator of steering axis offset from the differential drive axle centerline. This is a low precision value that can be improved with more driving, but it sets a rough upper limit on full lock to lock steering counts ~>180 degrees.
That is enough for basic calibration while consuming a minimum of floor space. With a longer straightaway we can explore how changing differential voltages affects steering angle over time and how steering angle actuation by stepper affects encoder direction and rate as well as differential brushed current.
It is unclear whether we will be able to achieve straight line driving and turn negotiation with this most basic sensor suite, but we have some things to try.
After calibration, basic teleoperation could be done by sending characters.
‘E’ ‘e’ or ‘space’ Emergency Stop
‘F’ ‘f’ ‘up arrow’ or ‘W’ ‘w’ Forward
‘L’ ‘l’ ‘left arrow’ or ‘A’ ‘a’ Left
‘R’ ‘r’ ‘right arrow’ or ‘D’ ‘d’ Right
‘B’ ‘b’ ‘down arrow’ or ‘S’ ‘s’ Backward
‘tab’ Toggle the direction defined as Forward
‘+’ increment keystroke multiplier *10
‘-’ decrement keystroke multiplier *10
Any single number preceding a valid command multiplies the effect of a single keystroke.
1 turn keystroke = 1 steering encoder tick.
1 direction keystroke = 1 brushless commutation.
2 numbers preceeding a valid command; first is the number of keystrokes, second is the rate of keystroke repeat. 100 is the normal repeat rate.