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

Touchscreen question

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







Touchscreen question
PostPosted: Sat Oct 25, 2008 9:19 am     Reply with quote

Hello I got a touchscreen on dev board easypic 5 touch screen is connected on:

RA0/AN0
RA1/AN1
RC0 -> No AD conversion
RC0 -> No Ad conversion

I wrote two functions to read x axis and y axis:
Code:


float get_X()
{
   float x;
   output_c(0b00000001);
   
   setup_adc_ports(sAN0);
   set_adc_channel(sAN0);
   delay_ms(20);
   x = read_adc();
   x = 5 * x / 1024;
   return x;
}

float get_Y()
{
   float y;
   setup_adc_ports(sAN1);
 
   output_c(0b00000010);
   
   set_adc_channel(sAN1);
   delay_ms(20);
   y = read_adc();
   y = 5 * y / 1024;

   return y;
}

Y axis returns diferrent voltages when is pressing but x axis value dosen't change.

I don't have much experience with touchscreen, but I think Y axis value
is correct.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Oct 26, 2008 2:35 am     Reply with quote

Did you understand the expected method of driving the touch screen? You know that RC0/RC1 need to be driven different for X and Y conversion?
Kabukiman
Guest







PostPosted: Mon Oct 27, 2008 7:17 am     Reply with quote

I've found the solution. It was a problem on AD port configuration.
LYFSA
Guest







what was the solution?
PostPosted: Fri Feb 06, 2009 10:13 am     Reply with quote

Hi,

i have the same problem, would you like to share the solution that you found?

Thank you!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 06, 2009 10:24 am     Reply with quote

Quote:
float get_X()
{
float x;
output_c(0b00000001);

setup_adc_ports(sAN0);
set_adc_channel(sAN0);
delay_ms(20);
x = read_adc();

The obvious problem in his code is that the ADC channel should not be
set with 'sAN0'. The channels are specified with 0, 1, 2, 3, etc.
To select channel 0, he needs to do this:
Code:
   set_adc_channel(0);
LYFSA
Guest







OMG!
PostPosted: Mon Feb 09, 2009 11:53 pm     Reply with quote

I didn't realize that, thanks my friend, now it seems that its working right!!

Thank you very much!
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