• AVR Freaks

Hot!Control of HDD BLDC motor with PIC

Author
Mike432
Starting Member
  • Total Posts : 42
  • Reward points : 0
  • Joined: 2016/08/15 06:26:37
  • Location: 0
  • Status: offline
2019/10/20 10:09:02 (permalink)
0

Control of HDD BLDC motor with PIC

Attached is a schematic of a circuit that I was thinking about trying for control of a 4 pin HDD motor.  The pin numbers on the schematic mean nothing because I was not able to adjust the values, they just represent output pins from the PIC.
 
I would activate one coil at a time and 4 cycles would be one full rotation (001, 010, 100, 001, 010, 100, 001, 010, 100, 001, 010, 100).
 
Using IRFZ44N that has a built in Zener diode to provide power to the coils.
 
Looking for general input on this, need for free wheeling diodes, possible damage to the PIC with this configuration, acceptable method of control.
 

Attached Image(s)

#1

7 Replies Related Threads

    Bob White
    Super Member
    • Total Posts : 264
    • Reward points : 0
    • Joined: 2010/11/06 19:52:38
    • Location: Denver, Colorado
    • Status: offline
    Re: Control of HDD BLDC motor with PIC 2019/10/20 13:08:49 (permalink)
    +1 (1)
     
    The IRFZ44N does NOT have a "built in Zener".  It is, however, avalanche rated.

    Allowing a MOSFET to avalanche is controversial in the power supply/power electronics world.  Some engineers say as long as you don't exceed the ratings the device is OK.  Others, who are more conservative, say never let a power MOSFET avalanche.  I am in the latter category.
     
    Driving this MOSFET from +5 V will work but it is marginal.  If this is a "one off" hobby or research project then you will probably be OK.  If you are intending this for a production design then you can expect trouble either in manufacturing test or in the field.

    To further critique your design we need information on the drive frequency and expected drain/winding currents.
     
     
    #2
    Mike432
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2016/08/15 06:26:37
    • Location: 0
    • Status: offline
    Re: Control of HDD BLDC motor with PIC 2019/10/26 12:33:49 (permalink)
    0
    I created the circuit and tested it with the following code, the motor just vibrated.  This tells me that I would need a spin up routine as I expected that I would.
     
    I wanted to test each coil to make sure they were working so I disconnected 2 of them, powered on, had power to coil.  Disconnected that one and tried another, had power to the coil.  Disconnected that one and tried the last coil, had power, but then my PIC started smoking!  My PIC is not fried and I will have to replace it, but before I do, what measures are recommended to prevent this from happening again?
     
    Coil resistance is 3 Ohms.  I was going to start my timer at 250Hz.  The motor would move 30 degrees per timer overflow so 1250 RPM on the motor unless I calculated something wrong.
     

    while(1){
    if(PIR1bits.TMR2IF == 1){
    //Time to switch a phase
    switch(phase){
    case 0:
    PORTBbits.RB6 = 0; PORTBbits.RB7 = 0;
    PORTBbits.RB3 = 1; phase++; break; //
    case 1:
    PORTBbits.RB7 = 0; PORTBbits.RB3 = 0;
    PORTBbits.RB6 = 1; phase++; break; //
    case 2:
    PORTBbits.RB6 = 0; PORTBbits.RB3 = 0;
    PORTBbits.RB7 = 1; phase = 0; break; //
    }
    PIR1bits.TMR2IF = 0; //reset the flag
    }
    }

    #3
    ric
    Super Member
    • Total Posts : 24180
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Control of HDD BLDC motor with PIC 2019/10/26 14:55:35 (permalink)
    0
    Writing to PORTBbits rapidly in succession is just asking for read-modify-write problems on those ports.
    Either change to a less ancient PIC that has LATB registers, or modify your code to write the entire PORTB in one instruction.
    If the other PORTB pins are inputs, or not connected, you could just do this:
    while(1){
         if(PIR1bits.TMR2IF == 1){
             PIR1bits.TMR2IF = 0; //reset the flag
             //Time to switch a phase
             switch(phase){
             case 0:
                PORTB = 0b00001000;  //00xx1xxx
                phase++;
                break;
             case 1:
                PORTB = 0b01000000;  //01xx0xxx
                phase++;
                break;
             case 2:
                PORTB = 0b10000000;  //10xx0xxx
                phase=0;
                break;
             }
         }
     }

     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    Mike432
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2016/08/15 06:26:37
    • Location: 0
    • Status: offline
    Re: Control of HDD BLDC motor with PIC 2019/10/26 15:19:01 (permalink)
    0
    I'm using this PIC because I have a small pile of them that were acquired from scrap equipment.  I did plan to have other outputs on port B but I could work around that and apply your recommended changes..  My main concern right now is the smoke and not letting that happen again.
    #5
    ric
    Super Member
    • Total Posts : 24180
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Control of HDD BLDC motor with PIC 2019/10/26 15:30:59 (permalink)
    0
    I'd be double checking the wiring of the FET on that last coil.
    The schematic you showed should not be capable of overloading the PIC output.
     
    n.b. you can still use other PORTB pins as outputs, at a slight extra complication in the code.
    Just maintain a "shadow copy" variable of what you want on PORTB, manipulate that, then copy the entire byte to PORTB.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    Mike432
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2016/08/15 06:26:37
    • Location: 0
    • Status: offline
    Re: Control of HDD BLDC motor with PIC 2019/10/27 09:42:26 (permalink)
    0
    I was thinking about making several different routines and then just call the one that corresponds to the other outputs.
     
    I added 1K resistors between the PIC and FETs and a 5.6Ohm resister on the common of the motor
     
    After adding a ramp up procedure I was able to get the motor spinning at 1250 RPM.  If I try to go faster it stalls but I'm happy to get this high of a speed from it.
     
    Now I wanted to see if running it with a lower duty cycle would make it run smother.  So instead of (coil 1 on for 5 ms, coil 2 on for 5 ms, coil 3 on for 5 ms) i would try (coil 1 on for 3 ms, coil 1 off for 2 ms, coil 2 on for 3 ms, coil 2 off for 2 ms...).  I did some initial testing with this and was able to go down to a 60% duty cycle, at 50% the motor stalled.
    #7
    PStechPaul
    Super Member
    • Total Posts : 2428
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Control of HDD BLDC motor with PIC 2019/10/27 22:29:35 (permalink)
    0
    You should show your entire circuit, particularly bypass capacitors on the PIC, and the PIC's Vdd should be separated from the raw 5VDC supply that feeds the motor coils. Grounding paths and transient protection are also important.
     
    As the speed increases you can increase the duty cycle of the coil drivers because the inductance will limit the current.

     
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5