motor de corrent continu PIC18F452 codificació d'ajuda ...

W

Waran

Guest
Hola,

Aquest és el codi que vaig fer per al control d'un motor de corrent en sentit horari i en sentit antihorari i el control de la velocitat de la corrent continu motor.I prèviament havia problema quan es fan servir "delay_ms 'i substituir-la per l'aplicació d'un cicle simple de fer que un retard és 'esperar ()' comanda.El codi és lliure d'error quan compile utilitzant mikroC compiler.But PRO pot funcionar quan em crema i s'apliquen a un circuit que figuren a continuació?

esperar void () (
unsigned int k;
for (k = 0; k <5000; k );
)

void main (void)
(

TRIS = 0x00; / / Initialize aquests ports com sortides
Trisca = 0x00; / / Aquesta també
TRISD = 0x00; / / Aquest tooooPORTA = 0x00; / / Initialize PORTA ... així que el LED està apagat

PORTC.F0 = 0; / / fre Off
PORTD.F1 = 1; / / direcció d'avanç
PORTD.F1 = 0; / / invertir la direcció

while (1)
(
if (PORTD.F1 == 1)
(
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00001111 / / 0x0F Full Speed

wait ();
wait ();
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00001011; / / 0x0b (3 / 4 Full Speed)

wait ();
wait ();
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00000101; / / 0x07 (1 / 2 Full Speed)

wait ();
wait ();
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00000011; / / 0x03 (1 / 4 Full Speed)

PORTD.F0 = 1; / / Turn On fre
wait (); / / cert retard per veure que funciona amb ull humà
PORTD.F0 = 0; / / Turn Off fre
)
else if (PORTD.F1 == 0)
(
wait ();
wait ();
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00001111 / / 0x0F (Full Speed)

wait ();
wait ();
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00001011; / / 0x0b (3 / 4 Full Speed)

wait ();
wait ();
wait ();
wait (); / / 4 * 0.5 segons = 2 Segona Pausa
PORTC = 0b00000101; / / 0x07 (1 / 2 Full Speed)

wait ();
wait ();
wait ();
wait (); / / cert retard per veure que funciona amb ull humà
PORTC = 0b00000011; / / 0x03 (1 / 4 Full Speed)

PORTD.F0 = 1; / / Turn On fre
wait (); / / cert retard per veure que funciona amb ull humà
PORTD.F0 = 0; / / Turn Off fre
)
)
)
<img src="http://images.elektroda.net/49_1250340780_thumb.png" border="0" alt="PIC18f452 dc motor coding help..." title="Motor de corrent continu PIC18F452 codificació d'ajuda ..."/>
 

Welcome to EDABoard.com

Sponsor

Back
Top