Here is the motor that I’ll be using. I don’t know if I mentioned this already, but I’ve got a big bag of these things. I don’t know where they originally come from, and I can’t find any sort of datasheet or description on the internet.
But that’s okay. I can work around that. I didn’t even know what kind of motors they were until I poked around with a multimeter. Turns out they’re brushless DC motors, which is pretty cool for both accurate positioning and speed, but relatively difficult to control.
Here’s the pinout, from left to right:
- Winding A
- Hall Effect sensor A
- Winding B
- Hall Effect sensor ground
- Winding C
- Hall Effect sensor B
- Hall Effect sensor power
- Hall Effect sensor C
Finding the windings was easy, I just checked the resistance between pins. My highly sophisticated method for finding the sensor pins, though, was putting a voltage across them and watching for smoke. I guessed wrong the first time, so, uh, make that three motors I’ve sacrificed, all told.
The output on the Hall sensors(powered by 3v) are very low, so they need to be hooked up with a differential amp to a potentiometer. The motors draw about 800mA at full load.
Because I have a whole bunch of these motors, I’ve been doing research for the absolute cheapest way of controlling these. Most of the controllers chips I’ve found are right around the $15, which is ridiculous.
So I built a quick test protoboard because it was cleaner than a breadboard, but it ended up getting a little complicated.
How I’ve got it right now:
While building this, I finally found an affordable solution, the MC33035. It was about $2. But hey, at least I’m intimately familiar with these motors in a way that a one-chip solution wouldn’t give me, right?
Here’s the test-code for PIC that I wrote. I still have maybe 30 of these motors, so they definitely could come into play in future projects. So, one-chip solution aside, I’d add forward/reverse control, PWM speed, and potentially speed/position feedback so I could include a PID loop. That would be pretty cool.
#include <htc.h>
//Int osc, wdt disabled, mclr disabled, bor, fscm __CONFIG(0x3F1B);
#ifndef _XTAL_FREQ #define _XTAL_FREQ 96000 #endif
//HALL EFFECT
#define PHALLA RA0 #define PHALLB RA1 #define PHALLC RA2
#define SENSEA RB5 #define SENSEB RB4 #define SENSEC RB3
void forward(void) { //AC', AB', B'C, A'C, A'B, BC' if(PHALLA == 0 && PHALLB == 0 && PHALLC == 1) { //Step 1 PITCHA = 1; PITCHC = 0; ENB = 0; ENA = 1; } else if (PHALLA == 0 && PHALLB == 1 && PHALLC == 1) { //Step 2 PITCHA = 1; PITCHB = 0; ENB = 1; ENC = 0; } else if (PHALLA == 0 && PHALLB == 1 && PHALLC == 0) { //Step 3 PITCHC = 1; PITCHB = 0; ENA = 0; ENC = 1; } else if (PHALLA == 1 && PHALLB == 1 && PHALLC == 0) { //Step 4 PITCHC = 1; PITCHA = 0; ENB = 0; ENA = 0; } else if (PHALLA == 1 && PHALLB == 0 && PHALLC == 0) { //Step 5 PITCHB = 1; PITCHA = 0; ENC = 0; ENB = 1; } else if (PHALLA == 1 && PHALLB == 0 && PHALLC == 1) { //Step 6 PITCHB = 1; PITCHC = 0; ENA = 0; ENC = 0; } SENSEA = ~PHALLA; SENSEB = ~PHALLB; SENSEC = ~PHALLC; }
void main(void){ ADCON1 = 0x07; //disable ADC CMCON = 0x07; TRISC = 0x00; //Port C Tris output TRISB = 0x00; //Port B Tris output TRISA = 0xFF; //Port A Tris input while(1){ forward(); } }
Edit, 6/12/2017:
It’s very weird to see something from legitimate sources start to appear as grey market goods, several years later.
I came across this and this item on AliExpress.
In case those links disappear (likely), it’s billed as: AIYIMA 2pcs Micro DC Brushless Motor 22MM Planetary Gear Motors External Rotor With Hall. The markings on the visible label read 4086013, 172336, and XF08F4901147. On the product page itself, the motor claims to be a AIYIMA-A4F321. The markings on the version I have, however, read 15246014, 172289, and XF04B4000507. Hopefully that helps someone.
The first link is a plastic shaft version I haven’t seen before, while the second link is the metal version that looks identical to my own.