Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Driving Motor Directly from PIC

Status
Not open for further replies.
PICs are Rugged !

So, I risked it.
First off all, lets cut-off a pair of legs, (as talked in this thread)
**broken link removed**
Then, lets make this circuit
**broken link removed**
Then, Lets write this code
Code:
#include<htc.h>
#define _XTAL_FREQ 4000000
#define output RA4
#define output_tris TRISA4
void main(){
CMCON = 0xff;  //disable all the comparators
ANSEL = 0b00000000;  // disable all the analog modulse
OPTION = 0b11010100 ;// disable internal weak pullup,,internal clock source for T0
TRISA1 = 0;
TRISA2 = 0;
TRISA0 = 1;
while(1){
if(RA0){
 RA2 = 1;
 RA1 = 0;
}else{
 RA2 = 0;
 RA1 = 1;
}
}
}
Finally, Lets burn it and see it in action,
The motor I had was a 3V motor, and its resistance was 12ohm. To, limit the current down, I added, 250 ohm in series. Sounds absurd, yeah, but the motor rotates anyway. And thats all I wanted, I want the motor to rotate. No loads.


Next step: Rip another pair of legs and repeat.
 
Last edited by a moderator:
Many of the microbots use tiny motors directly driven from PIC pin outputs. Sometimes they parallel output pins.

The max back-EMF of the running motor (generated voltage) is the same as the driven voltage which won't get over 5v.

As for flyback spikes etc from PWM all you need is a large cap 0.68uF or so across the motor terminals, and a resistor between the motor and the PIC pin. Because they are driven from very low current it's more like a PWM->RC filter to the motor rather than normal PWM chopping to the motor.
 
Many of the microbots use tiny motors directly driven from PIC pin outputs. Sometimes they parallel output pins.

The max back-EMF of the running motor (generated voltage) is the same as the driven voltage which won't get over 5v.

As for flyback spikes etc from PWM all you need is a large cap 0.68uF or so across the motor terminals, and a resistor between the motor and the PIC pin. Because they are driven from very low current it's more like a PWM->RC filter to the motor rather than normal PWM chopping to the motor.

I think there are two different things, i) Back Emf by the motor (due it acting like a generator).
ii) Back emf due to inductance of the motor (due to rate of change of current)

As you said, the Back Emf of the first case will be the supply voltage at max.
But, normally, we aren't concerned about this Back-emf. We are mostly concerned about the second type of Back Emf which creates High Voltage spikes.

Back-Emf in i) persists as long as the motor is rotating. People also call it Armature Reaction, dont they?
Back-Emf in ii) persists only as long as the current is changing.
 
Last edited:
Locally absorbing the transient at the motor will help if you don't have enough capacitance decoupling the PIC, but it does nothing the esd diodes in the PIC don't already do.
 
PICMICRO...you're like every other beginner.

Just because something seems to work and not show any issues right away DOES NOT mean that it's going to keep working long term. Sure, it might work now...and it may work for a while...but eventually it's going to fail. It's just a matter of WHEN it will fail.

No I'm not closed minded and believe me I've done my share of "outside the box experiments" in my day. However, I don't go asking others what results to expect (just do the damn experiment and find out) nor do I go recommending to others that it totally worked and they should do it too just because it happened to work for 5 minutes, an hour, a day (name your short term time period here). Point being...if it falls outside of common sense and you have to ask, you probably shouldn't be doing it in the first place. ;)
 
Hi Jon,
I would go with you, if I were making some commercial/industrial products, where reliability matters. And taking risks / pushing limits / going unconventional isn't allowed.
But hey this is hobby project. If it fail some-day, then no worries, we would switch to better design then.
And here you shouldn't put off beginners by "Nope, it won't work" , if it could probably works for days. You better mention that too.
You seem to go with one general formula -- "PIC -- Direct Drive Motor = NO NO) disregarding any circuit data (like, the inductance and resistance of the Motor , series resistance added , the supply voltage, the thermal capacity of internal ESD diodes etc)
 
Last edited:
Point being...if it falls outside of common sense and you have to ask, you probably shouldn't be doing it in the first place. ;)

I am building up my 'common sense'. How can a beginner rely on his 'common sense' ? One has to either ask or search for answers.
 
Point being...if it falls outside of common sense and you have to ask, you probably shouldn't be doing it in the first place. ;)

hi Jon,
My counter argument would be if the Wright Brothers had not taken the , lets see IF route, they would still be manufacturing bicycles and the F22 Raptor would be an all terrain bike.

I would suggest that PICMICRO does a controlled test, using the suppression diodes that members have suggested and then get back to us with the results of the test.

E.

PICMICRO.
Give it a go, lets know what you get.;)
 
a little bit aside ... im currently driving a simple 2 steps motor, basicly a really small coil, since few weeks directly from pins of a pic without has it seems no problems ... i only draw around 12mA ... here where i got the idea :eek:P

https://www.waitingforfriday.com/index.php/Vetinari%27s_Clock

of course 'cause im a noob im not saying it's gonna works all years .... you should try it yourself :eek:P
 
Last edited:
a little bit aside ... im currently driving a simple 2 steps motor, basicly a really small coil, since few weeks directly from pins of a pic without has it seems no problems ... i only draw around 12mA ... here where i got the idea :eek:P

https://www.waitingforfriday.com/index.php/Vetinari%27s_Clock

of course 'cause im a noob im not saying it's gonna works all years .... you should try it yourself :eek:P
Thanks for giving me my next project. :D
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top