CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I/O Problem with PIC16F690.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chandra



Joined: 19 Mar 2010
Posts: 18

View user's profile Send private message

I/O Problem with PIC16F690.
PostPosted: Wed Jan 04, 2012 3:14 pm     Reply with quote

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
}
}
chandra



Joined: 19 Mar 2010
Posts: 18

View user's profile Send private message

PostPosted: Wed Jan 04, 2012 3:34 pm     Reply with quote

I am using a rotary switch at A0,A1,A2.
And B4,b5,B6 are using for protection.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jan 04, 2012 3:47 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group