bigtreetech / BIGTREETECH-S42B-V1.0

The closed-loop drive is to feedback the rotation angle of the stepping motor to the control panel, compare the distance that needs to be rotated with the distance of the actual rotation, calculate the error value, and then compensate, so as to prevent the problem of multi-step and lost step. The closed-loop drive can completely overcome the lost step of the open-loop stepping motor, and can also significantly improve the performance of the motor at high speed
109 stars 53 forks source link

RTC too fast #50

Closed imperator-maximus closed 3 years ago

imperator-maximus commented 3 years ago

Hi, I tried to implement RTC (LSI) but I am always getting too fast speed. So the result of a second=LL_RTC_TIME_GetSecond(RTC); is always too fast - around 20% which is out of any specs. I tried:

It does not matter how much I change anything - speed is always the same.

my MX_RTC_Init btw:

void MX_RTC_Init(void)
{

  /* USER CODE BEGIN RTC_Init 0 */

  /* USER CODE END RTC_Init 0 */

  LL_RTC_InitTypeDef RTC_InitStruct = {0};

  /* Peripheral clock enable */
  LL_RCC_EnableRTC();

  /* USER CODE BEGIN RTC_Init 1 */

  /* USER CODE END RTC_Init 1 */
  /** Initialize RTC and set the Time and Date
  */
  RTC_InitStruct.HourFormat = LL_RTC_HOURFORMAT_24HOUR;
  RTC_InitStruct.AsynchPrescaler = 127;
  RTC_InitStruct.SynchPrescaler = 255;
  LL_RTC_Init(RTC, &RTC_InitStruct);
  LL_RTC_SetAsynchPrescaler(RTC, 127);
  LL_RTC_SetSynchPrescaler(RTC, 255);
  /* USER CODE BEGIN RTC_Init 2 */
  LL_RTC_DisableWriteProtection(RTC);
  LL_RTC_TIME_SetHour(RTC,__LL_RTC_CONVERT_BIN2BCD (18));
    LL_RTC_TIME_SetMinute(RTC,__LL_RTC_CONVERT_BIN2BCD(30));
    LL_RTC_TIME_SetSecond(RTC,__LL_RTC_CONVERT_BIN2BCD (0));
  LL_RTC_EnableWriteProtection(RTC);
  /* USER CODE END RTC_Init 2 */
}

Thank you!

imperator-maximus commented 3 years ago

solution: 125-1, 320-1 as prescaler values