This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Best ControlCard/Microcontroller to use with DRV8312

Other Parts Discussed in Thread: DRV8312, TMDSCNCD28035ISO, CONTROLSUITE, DRV8301

Hey guys,

I bought a Stellaris DK-LM3S-DRV8312 and I have a very specific mission. I have to obtain PID control parameters so that my motor can spin at 60 rpm with a very accurate position control (0.1% of error).

I know that sensorless technique doesn't match my objectives. I tried hard using GUI and even CCS code. Now, I want to use Hall Sensors and then an Encoder.

Unfortunately, Stellaris microcontroller disappointed me. It's a new platform. There is no already done code to use with Hall Sensors and Encoder.

What I want is a microcontroller that has good documentation and computing codes to use with Hall Sensors and Encoders (preferably, encoders) and which fits in DRV8312.

Please, I'm running against time.

Danilo

  • considering you already have the DRV8312 kit, I'd recommend getting the Piccolo TMDSCNCD28035ISO controlCARD

    There is a kit that includes this card and DRV8312 already: DRV8312-C2-KIT

    so the SW and documentation already exist for the hall sensored project.

    It can be downloaded through the MCU's software package, called controlSUITE

    you can install the whole thing, or just for the DRV8312-C2-KIT

    If you prefer Stellaris it is not much effort to port the drivers from this project over to Stellaris code, in fact I've seen a user in this forum already post that they have done so.

     

  • Thanks, Chris.

    And, what about encoders code? Do Piccolo or Stellaris have? Do you know someone in this forum that have already done this?

    Best,

    Danilo

  • Yes, Piccolo has encoder code (used on HV PMSM for speed feedback; there is an older version for F280x that does position control)

    C:\ti\controlSUITE\development_kits\HVMotorCtrl+PfcKit_v1.6\HVPM_Sensored

    C:\ti\controlSUITE\libs\app_libs\motor_control\drivers\f2803x_v1.2

    There will be a new dual motor kit out later this year (probably summer) that does 2 axis position control and motion using differential encoders.

  • Hi Chris,

    Now I'm using a Piccolo MCU. Well, I'm trying to follow the lessons in "Trapezoidal Control of BLDC Motors Using Hall Effect Sensors.pdf". In Level 2, my motor does not spin continuously. It suddenly has constant breaks at each 0.6s or 0.7s (seconds). I tried to change the motor parameters below believing that they could be the issue. I was wrong. Even calibrating other parameters (RampDelay, DfuncTesting, CmtnPeriodTarget, ...), the problem persists.

    Do you know what is it?

    Thanks,

    Danilo

     

    // This machine parameters are based on 24V PM motors inside Multi-Axis +PFC package

    // Define the PMSM motor parameters

    #define RS 0.79 // Stator resistance (ohm)

    #define RR 0 // Rotor resistance (ohm)

    #define LS 0.0012 // Stator inductance (H)

    #define LR 0 // Rotor inductance (H)

    #define LM 0 // Magnetizing inductance (H)

    #define POLES 8 // Number of poles

     

  • Chris,

    A second problem appeared: Suddenly the motor started to run continuosly, stopping the brakes. But, the error "Error: execution state prevented access" started to appear in the Value column of the Watch Expression Window. And it happened for all the Levels (1 to 6) in the document I mentioned above. That's very strange.

    Please, help me.

    Best,

    Danilo

  • That's strange. You're using the DRV8312 kit, F28035, and the motor that came with the kit?

    I'd start fresh with a clean install of the project code and follow step by step.

    These projects have all been checked out, and just recently used it to move to a DRV8301 with a sensored motor for a customer, using the incremental build levels. No issue.

  • Hi Chris,

    I fixed the issue; everything is OK with Hall Sensors code right now, except that it is not possible to achieve 60 rpm in LEVEL 6. Ok, that was expected. Now, I'm starting using C:\ti\controlSUITE\libs\app_libs\motor_control\drivers\f2803x_v1.2. What initializers and my encoders disk characteristics I have to personalize in the code?

    Please, help me.

    Danilo

  •  

      Hi. Danilo

     I developed the motor driver with drv8312-C2-Kit by modifying LEVEL6 code.

    The motor is PMSM with encoder 2048 pulse, speed is from 0 to 6000rpm, 

    Before starting,  can find out the calibration angle.

     In order to achieve your goal, what I have to say to you is that you don't believe all code provided from TI.

    I think there are a few bugs in the code. and you must know the structure and working method of the motor in detail.

    good luck to you.

                                                                     Cho from Korea.

     

  • Hi Cho,

    Thank you. Actually, I'm modified Level 6 and created a Level 7. My modifications are:

    • Creating SpeedLoopPrescaler and SpeedLoopCount; Should I maintain SpeedLoopPrescaler = 10 at low speeds (60 rpm)?
    • Now, I'm using pid_reg3 instead of pid_grando, because it is more simple, but without Kc (integral corrective gain);
    • I'm using speed_fr.h;
    • I'm using f2803xqep.h;
    • I initialize QEP module with CalibrateAngle = 0. What is this CalibrateAngle? I didn't understand the sentence: "Parameter: Raw angular offset between encoder index and phase a". How can I calibrate it?;
    • I initialize  the Speed module for QEP based speed calculation;
    • I initialize the PID_REG3 module for speed;
    • And then, in Level 7, I added: 

    if (SpeedLoopCount==SpeedLoopPrescaler)
           {
            pid2_spd.Ref = rc1.SetpointValue; /
            pid2_spd.Fdb = speed1.Speed;
            PID_MACRO(pid2_spd);
            SpeedLoopCount=1;
           }
        else SpeedLoopCount++;

        if(SpeedLoopFlag = FALSE)    pid2_spd.Ui=0;

    if (RunMotor==True) {EQep1Regs.QPOSCNT=0; EQep1Regs.QCLR.bit.IEL = 1;} // Reset position cnt.

        if ((EQep1Regs.QFLG.bit.IEL==1) && Init_IFlag==0)     // Check the first index occurrence
           {qep1.CalibratedAngle= EQep1Regs.QPOSILAT; Init_IFlag++;} // Keep the latched position

          if (RunMotor = FALSE) QEP_MACRO(qep1);

      speed1.ElecTheta = _IQ24toIQ((int32)qep1.ElecTheta);
          speed1.DirectionQep = (int32)(qep1.DirectionQep);
          SPEED_FR_MACRO(speed1)\

    • In my opinion, the only thing that is missing is the activation trigger based on the encoder signal. I mean, I have to change "mod1.TrigInput = (int32)hall1.CmtnTrigHall;". How did you do it?

    Am I missing any thing?

    Thank you again. Please, help me.

    Danilo

  •  

     

     HI. Danilo

    I recommand SpeedLoopPrescaler = 1, to improve accuacy, but sometimes become unstable, then adjust PID gain.

    I think pid_reg3 is better than pid_grando,

    you have to use speed_pr for low speed, to use for speed_fr for high speed.

    CalibrateAngle  is the count or PU value between a axis of input phase and d axis of rotor flux ( I think you need to study q axis and d axis for control)

    I use the code for PMSM, not BLDC, so I didn't modify "mod1.TrigInput = (int32)hall1.CmtnTrigHall;"

    Actually, PM code can control BLDC motor more precious than BLDC code. if you use PM code,  you have to know calibrateAngle  to start  motor moving.

    good luck!

     

                                                                                     Cho from Korea.