I have three FOC controllers ready to go. I purchased Three Emax GB4114-42kv motors and three of the AS5600 encoders from Ebay. If one searches Ebay the first few that come up on the square white proto board are what I have. I would like to ask for guidance in hooking up the encoder and configuring the SimpleFOC board (jumpers?). Also what is needed to make the software match this hardware setup.
Are you planning to have three separate unos attached to your 3 simplefoc boards?
Whilst it is possible to stack 2 boards (and use 1 uno) it limits your comms options with the sensor, youâll be forced to use âanalogâ rather than i2c as the as5600 has a fixed i2c address.
yup! digging and reading. I did not realize examples were included in the FOC libs for Arduino. On finding an example of code using the AS5600 many things became clear. On hookup the motor now has a high pitched whine and handing values to the serial interface using the âAngle Controlâ example results in movement. Just not quite the movement I would expect yet. Perhaps the pole count value in the script of 11 needs changed but to what? The Emax motor I am using does not list this information on their website.
If you are not sure what your pole_paris number is. The library provides an example code to estimate your pole_paris number in the examples find_pole_pairs_number.ino .
then found out encoder configured wrong (I missed it in the pole pair program). So now upon getting accurate encoder counts I still did not have great luck. It returned 8, 12 and 14. Fourteen being the most common.
Problem is, even using numbers 6-16 to test, the motor will not make a complete revolution and position seems random.
okâŚstuck. I can not find any examples that will reliably rotate the motor. I have been working with the open loop example and various poll counts to no avail. I tried to write some code to let me try various poll counts but I am unsure if I did it correctly
clues: the motor will rotate about 90â when I run the pole pair estimator but when it gets to the point in the program were the motor should runâŚjust buzz, no rotation.
will this code work to change the poll count? IE, can driver.init and motor.init be called more than once in the code?
void restart_motor()
{
BLDCMotor motor = BLDCMotor(poll_count);
driver.init();
motor.linkDriver(&driver);
// init motor hardware
motor.init();
Serial.print("poll count: ");
Serial.println(poll_count);
}
ps. aux question. what is the recommended power on sequence? 12v motor power before or after arduino power via usb. I notice without the 12v the SimpleFOC board led lights dim and the motor seems to have some small amount of power via usb. Is that harmful?
another test. I used the âopen_loop_velocity_exampleâ. With a value of 11 for pole count. The motor WILL rotate (finally!) up to a value of 17 or 18 but 20 is very jittery. With the pole count at 22 only about 10 results in stable rotation. (negative values result in rotation the opposite direction)
I just found âfull_control_serialââŚuh, I have NO idea the effect of those parameters on the SimpleFOC controller. 10+ variables. Is there a page that gives some sort of instructions for this? I see this page: https://docs.simplefoc.com/communication but nothing that might indicate what affect something like âP gainâ will have on making my motors work. A âmotor tuningâ page would help.
For small, low torque motors with little or no gearing, one procedure you can use to get a good baseline tune is to probe itâs response to a disturbance.
To tune a PID use the following steps:
Set all gains to zero.
Increase the P gain until the response to a disturbance is steady oscillation.
Increase the D gain until the the oscillations go away (i.e. itâs critically damped).
Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations.
Set P and D to the last stable values.
Increase the I gain until it brings you to the setpoint with the number of oscillations desired (normally zero but a quicker response can be had if you donât mind a couple oscillations of overshoot)
What disturbance you use depends on the mechanism the controller is attached to. Normally moving the mechanism by hand away from the setpoint and letting go is enough. If the oscillations grow bigger and bigger then you need to reduce the P gain.
If you set the D gain too high the system will begin to chatter (vibrate at a higher frequency than the P gain oscillations). If this happens, reduce the D gain until it stops.
I like how detail oriented you are. And you are making progress!
If your motor is not really moving smoothly in the voltage control mode then you still have a problem of either pole pair count or the sensor. We have discussed few time recently the situations where the as5600 are shipped with wrong magnets. Are your magnets polarized axially or radially? They should be polarized radially. Here is a recent thread https://community.simplefoc.com/t/drv8302-tarot-motor-control-type-voltage-magnet-polarization-problem/401/17
Now in terms of PID, once when everything works i donât think youâll have many problems running it. Your guide from the post before will work well.
Simplefoc has some docs in the motion control here is the link: https://docs.simplefoc.com/velocity_loop
22 poles means 22 magnets on the rotor. You might be able to count them. The magnets are arranged N S N S etc so if you have 22 poles then you have 11 pole pairs. A pole pair defines an electrical rotation so an 11 pole pair motor undergoes 11 electrical rotations per shaft rotation.
Antun,
I believe my sensor is working correctly, using âmagnetic_sensor_12c_exampleâ shows stable readings for both pos and rate. Values for pos are 0 to roughly 6.2 for one revolution. Rotating in the opposite direction yields -6.2.
if I concentrate on the âopen_loop_velocity_exampleâ. The sensor/encoder is not used. It should be able to produce smooth rotation up to the theoretical max rpm of the motor (42kv * 12v). Is this correct?
Owen,
for pole count. Using the test I mentioned above, with a small voltage applied to one pair of motor wires, rotating the motor gives 11 distinct ânotchesâ. As I understand it, that would be 22 poles or 11 pole pairs.
I ran this modified version of âopen_loop_velocity_exampleâ and experimented with various pole counts. The motor will run with values of 1 through 17 with the speed increasing with greater pole counts. Above 17 and the motor shakes. Hence, I should be able to use a value of 11 from the earlier tests.
[quote="program"]
// Open loop motor control example #include <SimpleFOC.h>
// BLDC motor & driver instance
BLDCMotor motor = BLDCMotor(11);
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
ugh! I did not understand the ânomenclatureâ
âFramework:âŚ24N22Pâ
says 24 coils and 22 magnets.
IE âŚ11 pole pairs.
another note. This motor I have will oscillate badly at voltages higher than 2 with the default pids while sitting on my desk. There for I need to have it anchored down to tune it further.
Is it working for you? I have the 4114 - it has 11 Pole Pairs as you correctly found out.
It works fairly well for me with the default example settings. I donât need to tune it to get decent commutation at 10V. This is true for different drivers.
Which MCU are you using? SAMD (Arduino MRK and others) is not yet supported. An Arduino Uno in combination with an I2C sensor might be a bit slow for really nice commutation, depending on how much other stuff youâre doing in the main loopâŚ
If open loop is working but closed loop is not, then there is a high probability that it is a sensor problem. Is the I2C address set correctly? Are the I2C pull-ups installed? Is your magnet the right kind - i.e. radially magnetised?
even if it is not oscillating it needs to be fixed - when changing direction or stopping it moves a lot otherwise. Its quite a heavy beast for a gimbal motor.