segunda-feira, 6 de fevereiro de 2012

CONTROL DIRECTION (LEFT,RIGHT AND STOP) FOR DC MOTOR.

Well...before begin explain the code , it's very important know how a H bridge Works.

H - BRIDGE 


An H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H bridges are available as integrated circuits, or can be built from discrete components.




Motors are high-powered devices in the world of digital electronics. A typical digital output can supply about 10 to 20 milliamperes  (mA) of current; a small permanent-magnet motor requires anywhere from 500 to 4000 mA of current. Special  circuits are therefore required to drive motors.



A circuit known as the H-bridge (named for its topological similarity to the letter "H") is commonly used to drive motors. In this circuit , two of four transistors are selectively enabled to control current flow through a motor.



As shown in Figure(above), an opposite pair of transistors (Transistor One and Transistor Three) is enabled, allowing current to flow through the motor. The other pair is disabled, and can be thought of as out of the circuit.
By determining which pair of transistors is enabled, current can be made to flow in either of the two directions through the motor. Because permanent-magnet motors reverse their direction of turn when the current flow is reversed, this circuit allows bidirectional control of the motor.

For this project  will used:

1.Hardware:
- ISIS PROTEUS

2.Software:
- microC PRO

1.Hardware:

For take an a positive polarity , you need active the control 1 , and clear the control 2 , for the activation the negative polarity makes the opposite configuration with the control pins. But be careful , never make the  activation of these two control spots in the same time , this action will do an a short-circuit between Vcc (Power Supply) and ground , and damage the transistors.


The simulation  in ISIS :



2.Software:


void main( void )
{
OPTION_REG = 0; //Resistance PULL-UP.
//Configuration of output and intpu for the PORTB
ANSEL=0;
ANSELH=0;     //Enable I/O digital
PORTB = 0;
TRISB = 0x0F;     // Configuration of output/input
PORTB = 0;

while(1) //LOOP
{
//LEFT <-----------------------------------
while( Button( &PORTB, 0, 10, 0 ) )
{

PORTB = 0; //Clear the control pins
PORTB.F7 = 1; //ENABLE CONTROL PIN 1
}
//Loop for the stop detection
while( Button( &PORTB, 1, 10, 0 ) )
{
PORTB = 0; //Clear the control pins
}
//RIGHT ------------------------------------>
while( Button( &PORTB, 2, 10, 0 ) )
{
PORTB = 0; //Clear the control pins
PORTB.F6 = 1; //ENABLE CONTROL PIN 2
}
}
}



I hope being useful. Any questions ask me.

Nenhum comentário:

Postar um comentário