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.

DRV8312 recommended PWM scheme from data sheet

PWM_scheme.txt
else{											/*													*/\
		    	/* State s1: current flows to motor windings from phase A->B, de-energized phase = C					*/\
		    		if (v.CmtnPointer==0)							/*													*/\
		    	    {												/*													*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM1	   		*/\
		    	      EPwm1Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)		*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM1  	*/\
		    		  EPwm1Regs.AQCTLA.bit.CAU = 1;         		/* Set low when CTR = CMPA on UP-count				*/\
		    		  EPwm1Regs.AQCTLA.bit.ZRO = 2;         		/* Set high when CTR = Zero							*/\
		    														/*													*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM2   	*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM2   */\
		    		  EPwm2Regs.AQCTLA.bit.CAU = 2;         		/* Set high when CTR = CMPA on UP-count				*/\
		    		  EPwm2Regs.AQCTLA.bit.ZRO = 1;         		/* Set low when CTR = Zero							*/\
		    		  EPwm2Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)		*/\
		    														/*													*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFA = 1;       		/* Forcing a continuous Low on output A of EPWM3   	*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFB = 1;       		/* Forcing a continuous Low on output B of EPWM3   	*/\
		    	    }												/*													*/\
		    	    												/*													*/\
		    	/* State s2: current flows to motor windings from phase A->C, de-energized phase = B					*/\
		    	    else if (v.CmtnPointer==1)  					/*													*/\
		    	    {												/*													*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM1   		*/\
		    	      EPwm1Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)  	*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM1  	*/\
		    		  EPwm1Regs.AQCTLA.bit.CAU = 1;         		/* Set low when CTR = CMPA on UP-count				*/\
		    		  EPwm1Regs.AQCTLA.bit.ZRO = 2;         		/* Set high when CTR = Zero							*/\
		    														/*													*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFA = 1;       		/* Forcing a continuous Low on output A of EPWM2   	*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFB = 1;       		/* Forcing a continuous Low on output B of EPWM2   	*/\
		    														/*													*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output A of EPWM3   	*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output B of EPWM3   */\
		    		  EPwm3Regs.AQCTLA.bit.CAU = 2;         		/* Set high when CTR = CMPA on UP-count				*/\
		    		  EPwm3Regs.AQCTLA.bit.ZRO = 1;         		/* Set low when CTR = Zero							*/\
		    		  EPwm3Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)  	*/\
		    	    }												/*													*/\
		    														/*													*/\
		    	/* State s3: current flows to motor windings from phase B->C, de-energized phase = A					*/\
		    	    else if (v.CmtnPointer==2)  					/*													*/\
		    	    {												/*													*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFA = 1;       		/* Forcing a continuous Low on output A of EPWM1   	*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFB = 1;       		/* Forcing a continuous Low on output B of EPWM1   	*/\
		    														/*													*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM2   			*/\
		    	      EPwm2Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM2 (Q15 -> Q0)  	*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM2  	*/\
		    		  EPwm2Regs.AQCTLA.bit.CAU = 1;         		/* Set low when CTR = CMPA on UP-count				*/\
		    		  EPwm2Regs.AQCTLA.bit.ZRO = 2;         		/* Set high when CTR = Zero							*/\
		    														/*													*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM3   	*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM3   */\
		    		  EPwm3Regs.AQCTLA.bit.CAU = 2;         		/* Set high when CTR = CMPA on UP-count				*/\
		    		  EPwm3Regs.AQCTLA.bit.ZRO = 1;         		/* Set low when CTR = Zero							*/\
		    		  EPwm3Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)  	*/\
		    	    }												/*													*/\
		    	   													/*													*/\
		    	/* State s4: current flows to motor windings from phase B->A, de-energized phase = C					*/\
		    	    else if (v.CmtnPointer==3)  					/*													*/\
		    	    {												/*													*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM1   	*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM1   */\
		    		  EPwm1Regs.AQCTLA.bit.CAU = 2;         		/* Set high when CTR = CMPA on UP-count				*/\
		    		  EPwm1Regs.AQCTLA.bit.ZRO = 1;         		/* Set low when CTR = Zero							*/\
		    		  EPwm1Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)  	*/\
		    														/*													*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM2   			*/\
		    	      EPwm2Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM2 (Q15 -> Q0)  	*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM2  	*/\
		    		  EPwm2Regs.AQCTLA.bit.CAU = 1;         		/* Set low when CTR = CMPA on UP-count				*/\
		    		  EPwm2Regs.AQCTLA.bit.ZRO = 2;         		/* Set high when CTR = Zero							*/\
		    														/*													*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFA = 1;       		/* Forcing a continuous Low on output A of EPWM3   	*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFB = 1;       		/* Forcing a continuous Low on output B of EPWM3   	*/\
		    	    }												/*													*/\
		    														/*													*/\
		    	/* State s5: current flows to motor windings from phase C->A, de-energized phase = B					*/\
		    	    else if (v.CmtnPointer==4)  					/*													*/\
		    	    {												/*													*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output A of EPWM1   	*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output B of EPWM1   */\
		    		  EPwm1Regs.AQCTLA.bit.CAU = 2;         		/* Set high when CTR = CMPA on UP-count				*/\
		    		  EPwm1Regs.AQCTLA.bit.ZRO = 1;         		/* Set low when CTR = Zero							*/\
		    		  EPwm1Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)  	*/\
		    														/*													*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFA = 1;       		/* Forcing a continuous Low on output A of EPWM2   	*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFB = 1;       		/* Forcing a continuous Low on output B of EPWM2   	*/\
		    														/*													*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM3  			*/\
		    	      EPwm3Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM3 (Q15 -> Q0)  	*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM3  	*/\
		    		  EPwm3Regs.AQCTLA.bit.CAU = 1;         		/* Set low when CTR = CMPA on UP-count				*/\
		    		  EPwm3Regs.AQCTLA.bit.ZRO = 2;         		/* Set high when CTR = Zero							*/\
		    	    }												/*													*/\
		    														/*													*/\
		    	/* State s6: current flows to motor windings from phase C->B, de-energized phase = A					*/\
		    	    else if (v.CmtnPointer==5)  					/*													*/\
		    	    {												/*													*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFA = 1;       		/* Forcing a continuous Low on output A of EPWM1   	*/\
		    	      EPwm1Regs.AQCSFRC.bit.CSFB = 1;       		/* Forcing a continuous Low on output B of EPWM1   	*/\
		    														/*													*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM2   	*/\
		    	      EPwm2Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output B of EPWM2   */\
		    		  EPwm2Regs.AQCTLA.bit.CAU = 2;         		/* Set high when CTR = CMPA on UP-count				*/\
		    		  EPwm2Regs.AQCTLA.bit.ZRO = 1;         		/* Set low when CTR = Zero							*/\
		    		  EPwm2Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM1 (Q15 -> Q0)  	*/\
		    														/*													*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFB = 2;       		/* Forcing a continuous High on output B of EPWM3  			*/\
		    	      EPwm3Regs.CMPA.half.CMPA = (int16)(Tmp>>15); 	/* PWM signal on output B of EPWM3 (Q15 -> Q0)  	*/\
		    	      EPwm3Regs.AQCSFRC.bit.CSFA = 0;       		/* Forcing disabled on output A of EPWM3  	*/\
		    		  EPwm3Regs.AQCTLA.bit.CAU = 1;         		/* Set low when CTR = CMPA on UP-count				*/\
		    		  EPwm3Regs.AQCTLA.bit.ZRO = 2;         		/* Set high when CTR = Zero							*/\
		    	    }												/*											*/\
    }														/*											*/\
    
    #endif  // __F2803X_BLDCPWM_H__

I am using DRV8312-C2 kit with the software BLDC_Sensored. I modified the bldcpwm_BLDC.h to follow the recommended complementary PWM scheme as described by the datasheet (refer to section 9.2.4).

Testing the code, I changed the DFuncDesired from initial of 3276 to final value of 14000. The measured speed decreased. I decreased the DFuncDesired from 14000 to 12000. The measured speed increased.

This is exactly opposite to what I expected. Increasing DFuncDesired should increase speed. Decreasing it should decrease the speed. 

The DFuncDesired value should correlate to the PWM Duty Cycle (as seen with the original bldcpwm_BLDC.h). Using the recommended complementary PWM scheme (see attached portion of revised bldcpwm_BLDC.h), the DFuncDesired value correlates to when PWM = LOW.

How do I correct this? I want to use the recommended PWM scheme but the DFuncDesired value should correlate to the PWM Duty Cycle.

  • First, I would check for overflow of the PWM register. Look at the PWM register and change the values from above. Make sure that the EPWM compare registers make sense.

    If the EPWM compare register makes sense, then I would look at the inverter output on the oscilloscope to make sure that there are no glitches in the PWM waveform.

    You mentioned that this is sensored, so I am assuming that you are using hall sensor inputs for commutation feedback. Are you using the motor that came with the kit or your own motor? Make sure that the hall sensor feedbacks are arranged properly.