RC ESC modification part3 : Wire up RC ESC and 328P in 6 PWM with simpleFOC
Selection of MCU:
ATMega328p has 6pwm, just enough for 3p BLDC, which I can use to control the S2101 gatedrive. and this is also a MCU supported by simple FOC, but used to control some other gatedrive and mosfet, S2101is not officially supported in the example.
I still have a pro mini 5V 16Mhz, decide to give it a try.(not sure if 8Mhz pro mini can also do the job, I believe the PWM frequency is only half.)
Connection:
Arduino UNO and all the atmega328 based boards have only 6 pwm pins and in order to use the
we need to use all of them. Those are , , , , and . Furthermore in order for the algorithm to work well we need to use the pwm pins that belong to the same timer for each high/low side pair of each phase. 7 So Atmega328 pins belonging to the timers are:, | , | , |
I try to use a low Kv motor I have :a T-motor NM3508-29 with 380Kv, 14 mag, i.e. 7 pole pairs
which I added a As5600 mag sensor, the base is 3d printed.
Tested with AS5600 library, the IIC reading is correct.
Test with open loop:
I want to first test without sensor, to make sure the wire and driving are OK.
It's recommended to put phase resistance in code, I'm not sure should it measure with real current voltage data? I pick my battery internal resistor meter and tool the measure, 3 phases are between 225-245 mOhm.
The Kv value, simple FOC recommanded to put 1.5 times of marked.
Consideration in coding:
// BLDCDriver6PWM( int phA_h, int phA_l, int phB_h, int phB_l, int phC_h, int phC_l, int en)
// - phA_h, phA_l - A phase pwm pin high/low pair
// - phB_h, phB_l - B phase pwm pin high/low pair
// - phB_h, phC_l - C phase pwm pin high/low pair
// - enable pin - (optional input)
BLDCDriver6PWM motor = BLDCDriver6PWM(5,6, 9,10, 3,11, 8);
The enable is optional. The code should work like this:
BLDCDriver6PWM driver = BLDCDriver6PWM(5, 6, 9,10, 3, 11);
A example with 2101 is here: https://community.simplefoc.com/t/deadtime-6pwm-hacking-10-36v-500w-bldc-controller-to-run-simplefoc/431/4
2101 gatedrive does not control the relation of Hin and Lin, there is a chance that H and L are on at same time and make a short circuit.
The dead zone can be set: https://docs.simplefoc.com/bldcdriver6pwm#step-22-dead-zone-dead-time
// dead_zone [0,1] - default 0.02 - 2%
driver.dead_zone = 0.05;
it's in percentage of a duty cycle, so 0.05=5%
2101 and MOSFET both has rising delay and require rising time. I got following nr from data sheet.
2101:t on/off (typ.) 160 & 150 ns, Delay Matching 50 ns
MOSFET has someting like this:
Since the dead zone Nr is set in percentage of duty cycle, there is no means to calculated the delay for dead zone.
previous example need to set to 0.1 to avoid mosfet heating. I will see what would be my case.
I majorly use the code I found in part2 and modify some parameters:
Using power supply to limit the current, and hope no heating nor smoke.
The motor works when I put. PSU at 12V...
interesting is that when I change the deadzone, the current changes, if I set dead zone @=0.1, the motor is a little cogging. but the current is small.
This one is with dead zone =0.05, the current is a bit high, but motor run smooth.
留言
張貼留言