[electronics and microcontroller newbie]
Hi all,
I'm trying to get a DC motor to spin backwards and forwards.
I'm getting ~ -39 mA and ~ +44 mA to the motor. Source is a 9V battery.
Obviously it's not getting the necessary amps. It just clicks back and forth but doesn't rotate.
Any ideas? What am I doing wrong? It needs at least 100 mA for decent rotation.
But please don't ask me to use "such and such doo-hickey". I'm into the electronics hobby to learn about electronics. I don't want to just plug in IC's.
I included the program and schematics.
Thanks for everything,
Salim
//------------------------------------------------------------
sfr at 0x90 P1;
sfr at 0x89 TMOD;
sbit at 0x8C TR0;
sbit at 0x8D TF0;
void forward(void);
void reverse(void);
int overFlowCounter = 0;
void main(void)
{
TMOD = 0x01; // 16-bit timer. No gate, no C/T
TR0 = 1; // run timer0
while (1)
{
if (TF0)
overFlowCounter++;
if (overFlowCounter < 2550) // Leads to approx. 1.5 secs with 11.059200 Mhz crystal.
forward();
else
reverse(); // ...and 1.5 secs in reverse.
if (overFlowCounter > 5100) // crude but gets the job done for now
overFlowCounter = 0;
}
}
void forward(void)
{
P1 = 0x01;
}
void reverse(void)
{
P1 = 0x02;
}
Hi all,
I'm trying to get a DC motor to spin backwards and forwards.
I'm getting ~ -39 mA and ~ +44 mA to the motor. Source is a 9V battery.
Obviously it's not getting the necessary amps. It just clicks back and forth but doesn't rotate.
Any ideas? What am I doing wrong? It needs at least 100 mA for decent rotation.
But please don't ask me to use "such and such doo-hickey". I'm into the electronics hobby to learn about electronics. I don't want to just plug in IC's.
I included the program and schematics.
Thanks for everything,
Salim
//------------------------------------------------------------
sfr at 0x90 P1;
sfr at 0x89 TMOD;
sbit at 0x8C TR0;
sbit at 0x8D TF0;
void forward(void);
void reverse(void);
int overFlowCounter = 0;
void main(void)
{
TMOD = 0x01; // 16-bit timer. No gate, no C/T
TR0 = 1; // run timer0
while (1)
{
if (TF0)
overFlowCounter++;
if (overFlowCounter < 2550) // Leads to approx. 1.5 secs with 11.059200 Mhz crystal.
forward();
else
reverse(); // ...and 1.5 secs in reverse.
if (overFlowCounter > 5100) // crude but gets the job done for now
overFlowCounter = 0;
}
}
void forward(void)
{
P1 = 0x01;
}
void reverse(void)
{
P1 = 0x02;
}
Attachments
-
54.2 KB Views: 55