cancel
Showing results for 
Search instead for 
Did you mean: 

How to add inverter board in MCSDK6?

Junde
Senior III

Hi there,

My team has designed a dual motor control board, and I'm responsible for spinning the motors.

I have already added the board to MCSDK6 and generated the project without error.

However, when I add the code like MC_StartMotor1() after initialization, both the motors are static.

I don't know the reason why the motor can't spin.

Find the board file and the schematic in the attachments.

Can someone help me double-check if I did something wrong?

Thanks for your help. May you have a goooood day!

4 REPLIES 4
STuser2
Senior III

Have you verified if the motor gone to RUN state and not in fault state? Did you verify the PWM at the Gate Drivers etc, some of the very few inspections. 

@STuser2 

Thanks for your reply.

I checked the state of both motors, and the phenomenon was as follows:

Junde_0-1766633939010.png

Given the identical input, the output varies wildly. I can't figure out why.

Could you give me some advice?

Thank you.

(The following is the code I added. The log file can be found here: GitHub - ShadowThree/dbger)

  uint32_t then = 0, now, tick = 0;
  uint16_t curFault, occFault;
  uint16_t preCurFaultM1 = MC_NO_ERROR, preOccFaultM1 = MC_NO_ERROR;
  uint16_t preCurFaultM2 = MC_NO_ERROR, preOccFaultM2 = MC_NO_ERROR;
  while (1)
  {
      now = HAL_GetTick();
      /*if(now != then) {
          then = now;
          tick++;
      }*/
      
      size_t cmd_len = get_RTT_cmd();
      if(cmd_len) {
          //LOG_DBG("cmd[%s] len[%d]\n", RTT_cmd_buf, cmd_len);
          if(strncmp(RTT_cmd_buf, "startM1", 7) == 0) {
              if(MC_StartMotor1()) LOG_DBG("[%d] startM1 succ\n", now); else LOG_ERR("[%d] startM1 fail\n", now);
          } else if(strncmp(RTT_cmd_buf, "startM2", 7) == 0) {
              if(MC_StartMotor2()) LOG_DBG("[%d] startM2 succ\n", now); else LOG_ERR("[%d] startM2 fail\n", now);
          } else if(strncmp(RTT_cmd_buf, "stopM1", 6) == 0) {
              if(MC_StopMotor1()) LOG_DBG("[%d] stopM1 succ\n", now); else LOG_ERR("[%d] stopM1 fail\n", now);
          } else if(strncmp(RTT_cmd_buf, "stopM2", 6) == 0) {
              if(MC_StopMotor2()) LOG_DBG("[%d] stopM2 succ\n", now); else LOG_ERR("[%d] stopM2 fail\n", now);
          } else if(strncmp(RTT_cmd_buf, "ackM1", 5) == 0) {
              if(MC_AcknowledgeFaultMotor1()) { preCurFaultM1 = MC_NO_ERROR; preOccFaultM1 = MC_NO_ERROR; LOG_DBG("ackM1\n"); }
          } else if(strncmp(RTT_cmd_buf, "ackM2", 5) == 0) {
              if(MC_AcknowledgeFaultMotor2()) { preCurFaultM2 = MC_NO_ERROR; preOccFaultM2 = MC_NO_ERROR; LOG_DBG("ackM2\n"); }
          } else if(strncmp(RTT_cmd_buf, "staM1", 5) == 0) {
              LOG_DBG("[%d] M1 sta[%d]\n", now, MC_GetSTMStateMotor1());
          } else if(strncmp(RTT_cmd_buf, "staM2", 5) == 0) {
              LOG_DBG("[%d] M2 sta[%d]\n", now, MC_GetSTMStateMotor2());
          }
      }
      
      curFault = MC_GetCurrentFaultsMotor1();
      occFault = MC_GetOccurredFaultsMotor1();
      if((curFault != preCurFaultM1) || (occFault != preOccFaultM1)) {
          preCurFaultM1 = curFault;
          preOccFaultM1 = occFault;
          LOG_DBG("[%d] M1 curF[0x%X] occF[0x%X]\n", now, curFault, occFault);
      }
      curFault = MC_GetCurrentFaultsMotor2();
      occFault = MC_GetOccurredFaultsMotor2();
      if((curFault != preCurFaultM2) || (occFault != preOccFaultM2)) {
          preCurFaultM2 = curFault;
          preOccFaultM2 = occFault;
          LOG_DBG("[%d] M2 curF[0x%X] occF[0x%X]\n", now, curFault, occFault);
      }

    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

 

I never worked with dual motors but my suggestion would be to make one motor running smoothly without any faults and then go for dual motors testing. 

Verify the threshold levels of fault parameters of voltages,

Verify the current sensor circuitry.

Record the voltages and currents and check them for valid ranges.

 

@STuser2 

Thank you for your advice; I will follow it and try it.

If there is any progress, I will update the information below this question.

Have a good day!