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 CCS Technical Support

Scanning many keys with one input

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



Joined: 13 Jul 2005
Posts: 7

View user's profile Send private message Send e-mail

Scanning many keys with one input
PostPosted: Tue Aug 02, 2005 1:20 pm     Reply with quote

Hi,
i am new to the CCS and i am interested in how to make "trick" with CCS showed on the picture > http://www.shrani.si/pics/tip58433.jpg
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Tue Aug 02, 2005 3:47 pm     Reply with quote

1. Configure GP2 to output a low voltage to
discharge capacitor through I/O resistor.
2. Configure GP2 as one comparator input and
CVREF as the other.
3. Use a timer to measure when the comparator
trips. If the time measured is greater than the
maximum allowed time, then repeat; otherwise
determine which button is pressed.

When a key is pressed, the voltage divider network
changes the RC ramp rate.

That's pretty much how to do it. Perhaps you should post your code so that someone may know where the problem is.
glavic



Joined: 13 Jul 2005
Posts: 7

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 02, 2005 4:33 pm     Reply with quote

Like i said, i am new to the CCS.

1. Configure GP2 to output a low voltage to
discharge capacitor through I/O resistor.

output_low(PIN_A2);

2. Configure GP2 as one comparator input and
CVREF as the other.

In datasheet of 12F675 on chapter 6.2. Comparator Configuration i can find where i can set GP2 as comparator input + i want to use GP0 and GP1 for other purposes.

3. Use a timer to measure when the comparator
trips. If the time measured is greater than the
maximum allowed time, then repeat; otherwise
determine which button is pressed.


Never used timer in CCS yet.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Wed Aug 03, 2005 11:05 am     Reply with quote

Frankly, you have some reading to do. I'd recommend trying one of the 30 or so books on programming PIC processors. Pic Micro MCU C by Gardner is a pretty good intro to CCS C, and an OK intro the the PIC in general.

There are also probably 30 good internet sites on basic PIC programming. Search for "PIC Tutorial" and see what happens.

Scott
glavic



Joined: 13 Jul 2005
Posts: 7

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 04, 2005 11:25 am     Reply with quote

I found another way, without the use of timer.

http://www.shrani.si/pics/tipke60169.gif

Code:
#include <12F675.h>
#device ADC=8
#fuses NOWDT, PUT, NOPROTECT, NOCPD, NOMCLR, XT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1) // for testing

main ()
{
   int value=0;

   set_tris_a(0b00000100);
   setup_adc( ADC_CLOCK_INTERNAL );
   setup_comparator( NC_NC );
   setup_adc_ports( sAN2 );
   set_adc_channel(2);

   while(1)
   {
      value = read_adc();
      delay_ms(1);

      if (value > 0)
      {
         printf("A/D value = %U\n\r", value); // print the ADC result value
         delay_ms(500);
      }
   }
}
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