[SOLVED] Cd rom spindle motor driving

Status
Not open for further replies.

Jestin_cubetech

Advanced Member level 1
Joined
Jun 24, 2012
Messages
499
Helped
76
Reputation
152
Reaction score
73
Trophy points
1,328
Activity points
3,697
Hall Sensor Based BLDC Motor driving using microcontroller.

Code:
#include <pic.h>                         //BLDC DRIVER  delta connection and hall sensor
#define _XTAL_FREQ 20000000
unsigned char n=0,hall_sens=0,k=0;
bit DIR;
const unsigned char commutation[12][2]=
{
//---------------forward----------
 0x80,0x24,//10.01.00 0x31,//
 0xa0,0x06,//00.01.10 0x1F,//
 0x20,0x12,//01.00.10 0X07,//
 0x60,0x18,//01.10.00 0X0D,//
 0x40,0x09,//00.10.01 0X1C,//
 0xc0,0x21,//10.00.01 0X34,//
 //---------------Reverse---------
 0x80,0x18,//0X0D,//
 0xc0,0x12,//0X07,//
 0x40,0x06,//0X1F,//
 0x60,0x24,//0X31,//
 0x20,0x21,//0X34,//
 0xa0,0x09,//0X1C,//
};

void motor_startup() 
{
 RBIE=0;GIE=0; 
 PORTD=0x24;
 __delay_ms(10);
 PORTD=0x06;
 __delay_ms(10);
  PORTD=0x12; 
 __delay_ms(10);
  PORTD=0x18;
 __delay_ms(10);
  PORTD=0x09;
 __delay_ms(10);
  PORTD=0x21;
 __delay_ms(10);
 RBIE=1;GIE=1; 
}
////////////////////////////////////////
void motor_stop() 
{
 PORTD=0; 
 RBIE=0; RBIF=0;GIE=0; 
 PORTD=0;
__delay_ms(10);
 RBIE=0; RBIF=0;GIE=0; 
 PORTD=0;
}
void interrupt isr() 
{
 	if(RBIF)
      {
         RBIF=0;
         hall_sens=(PORTB&0Xe0);	// HALL EFFECT SENSOR READING

if(DIR)   //FWD
{
         for(n=0;n<5;n++)
        {
         if(hall_sens==commutation[n][0]){k=n;} 
        }
}   
else    //BWD
{ 
        for(n=5;n<11;n++)
        {
         if(hall_sens==commutation[n][0]){k=n;} 
        }
}       
        PORTD=(commutation[k][1]&0X3F);
      } 
}

////////////////////////////////////////
void main()
{ 
     TRISD=0x0;PORTD=0;TRISB=0xF0;
     TRISA=0x01; ADCON1=0x80;   LED=1;
    RBIE=0;RBIF=0;

 PEIE=1;GIE=1; 
motor_startup();    
while(1);

}


 

Sorry to be the critic, but from a brief look at your schematic I have a criticism to offer (and a solution):

The "transistor" side of your optocouplers, when they turn on, connect the MOSFET Gates to +12V. For the low-side MOSFETs (Q4, Q5, and Q6) this is fine; the MOSFETs turn on, and they pull their drains (Nodes U, V, and W respectively) to GND. For the high-side MOSFETs (Q1, Q2, and Q3), however, they can only pull their sources (Nodes U, V, and W) to 12V - Vgs (where Vgs is approximately the turn-on threshold voltage). If these MOSFETs have a threshold of 4V, then they have 4V across them in their "on" state—thus, the motor coil only has 8V across it! This means that the circuit isn't operating anywhere near as efficiently as it should! You're burning lots of power in the top MOSFETs.

Here are a few possible solutions:
a) You can replace Q1, Q2, and Q3 with P-channel MOSFETs. You'd have to reconfigure their respective opto-isolators to pull-down instead of pull-up. P-channel MOSFETs are also more expensive for the same performance.
b) You can connect U3, U4, and U5's transistor collectors, not to 12V, but to (say) 17V or 20V. If you add a power supply for that, it would only need to supply several milliamps.
c) You can connect a "bootstrap" capacitor and diode to each of Q1, Q2 and Q3. You'd have to be a bit careful with how you implement it, but it's a very common way of supplying gate charge for a high-side N-channel FET so you won't have trouble finding out how to do it.

Hope this helps.
 
Thanks For Your Help...
The Circuit Is not detailed, it just a rough sketch.
 

how you going to control the speed of the motor?

- - - Updated - - -

how you going to control the speed of the motor?
 

with a master power control MOSFET . [PWM controlled]
speed is directly depend to the voltage.

- - - Updated - - -

with a master power control MOSFET . [PWM controlled]
speed is directly depend to the voltage.
 

Re: Cd rom spindle motor driving (error in code)

Hall Sensor Based BLDC Motor driving using microcontroller.
Code:
....
void interrupt isr() 
{
    if(RBIF)
      {
         RBIF=0;
         hall_sens=(PORTB&0Xe0);	// HALL EFFECT SENSOR READING
....

Hi;
There are some minor programming mistake in the code, but it still works, as we see.
Explaining only one because it's a common error:

Seems the hall sensors are reading via the "interrupt-on-change" feature. But now at any input changing the IT routine runs twice because at first the RBIF flag is not cleared, only after reading PORTB, the second (unnecessary) round.

The correct method (look at the datasheet):

- first read PORTB (to clear mismatch condition)
- then clear RBIF

Code:
....
void interrupt isr() 
{
    if(RBIF)
      {
         hall_sens=(PORTB&0Xe0);	// HALL EFFECT SENSOR READING
         RBIF=0;
....
 

with a master power control MOSFET . [PWM controlled]
speed is directly depend to the voltage.

- - - Updated - - -

with a master power control MOSFET . [PWM controlled]
speed is directly depend to the voltage.

I got it.thanks for your help.
 

for efficient driving of Q1, Q2, and Q3 please add a bootstrap gate driving circuit.
thanks ZekeR for your valuable suggestion.

 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…