Monday, December 30, 2013

Driving ESC from STM32F4-DISCOVERY

It's way easier by simply driving ESC to make the 750kv HP2217 three phase BLDC motor rotate. The motor is far away smaller than the electric scooter I had in the summer. The control is way more suitable than the previous bldc motor. I do not need extra driver for rotating clockwise and counterclockwise. The direction is fixed to either CW or COUNTER CW.

The connection is easy for just driving the motor to rotate using the ESC. BLACK Wire from the ESC go to the GND to the discovery board. Do not connect red cable, so far i still do not know why the ESC has the red cable and without BEC.

And the White wire is the signal in wire, go to the PWM output pin of the Discovery board. And I guess it is the TTL rule of voltage recognition not CMOS.

Anyway it works for me, just changing the original code to 50hz and pulse to 1ms-1.2ms.

 PrescalerValue = (uint16_t) ((SystemCoreClock /2) / 1000000) - 1;//generate 1Mz frequency

  /* Time base configuration */
  TIM_TimeBaseStructure.TIM_Period = 20000-1;//down to 50hz
  TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;//84-1

TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
TIM_OCInitTypeDef  TIM_OCInitStructure;
uint16_t CCR1_Val = 1000-1;
uint16_t CCR2_Val = 1200-1;


It is not really surprising as thinking in time domain. 20ms for one period and 1ms or 1.2ms pulse. 1ms it will turn off the motor and 1.2ms will probably make it rotate CW or CCW, it depends on the connection from ESC  to motor.

Code in github: https://github.com/bli19/UAV_Compete-Source

No comments:

Post a Comment