View previous topic :: View next topic |
Author |
Message |
chandra
Joined: 19 Mar 2010 Posts: 18
|
I/O Problem with PIC16F690. |
Posted: Wed Jan 04, 2012 3:14 pm |
|
|
Hi,
I tried this code...Only first step is working. Can you guide me.
It is for controlling a DC ordinary motor.
Code: |
#include <16F690.h>
#fuses INTRC,NOWDT,NOPROTECT,MCLR
#use delay(clock=8000000)
void main () {
while(1)
if (input(PIN_C0) == 1) // OVER LOAD
{
output_HIGH(PIN_C2);
output_HIGH(PIN_C4);
output_LOW(PIN_C3); // STOP
}
else if (input(PIN_A2) == 1) // STOP SW
{
output_HIGH(PIN_C2);
output_HIGH(PIN_C4);
output_LOW(PIN_C3); // STOP
}
else if (input(PIN_A0) == 0 && input(PIN_A1) == 0 && input(PIN_A2) == 0) // SW CHANGEING TIME
{
output_HIGH(PIN_C2);
output_HIGH(PIN_C4);
output_LOW(PIN_C3); // STOP
}
else if (input(PIN_A0) == 1 && input(PIN_A1) == 0 && input(PIN_A2) == 0 && input(PIN_C0) == 0 && input(PIN_B4) == 1 && input(PIN_B5) == 1 && input(PIN_B6) == 1) // SW AT FF
{
output_LOW(PIN_C3);
output_HIGH(PIN_C2);
output_HIGH(PIN_C4);
delay_ms(1000);
output_HIGH(PIN_C3);
delay_ms(1000);
output_LOW(PIN_C2); // FORWARD
}
else if (input(PIN_A0) == 0 && input(PIN_A1) == 1 && input(PIN_A2) == 0 && input(PIN_C0) == 0 && input(PIN_B4) == 1 && input(PIN_B5) == 1 && input(PIN_B6) == 1) // SW AT REW
{
output_LOW(PIN_C3);
output_HIGH(PIN_C2);
output_HIGH(PIN_C4);
delay_ms(1000);
output_HIGH(PIN_C3);
delay_ms(1000);
output_LOW(PIN_C4); // REVERSE
}
else
{
output_high(PIN_B7); // ERROR LED
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
chandra
Joined: 19 Mar 2010 Posts: 18
|
|
Posted: Wed Jan 04, 2012 3:34 pm |
|
|
I am using a rotary switch at A0,A1,A2.
And B4,b5,B6 are using for protection. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Jan 04, 2012 3:47 pm |
|
|
maybe you want to post a schematic - as the code makes little sense without it . the presence or lack of pull up pull down resistors is another
open question |
|
![](templates/subSilver/images/spacer.gif) |
|