View previous topic :: View next topic |
Author |
Message |
Kabukiman Guest
|
Touchscreen question |
Posted: Sat Oct 25, 2008 9:19 am |
|
|
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
|
|
Posted: Sun Oct 26, 2008 2:35 am |
|
|
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
|
|
Posted: Mon Oct 27, 2008 7:17 am |
|
|
I've found the solution. It was a problem on AD port configuration. |
|
|
LYFSA Guest
|
what was the solution? |
Posted: Fri Feb 06, 2009 10:13 am |
|
|
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
|
|
Posted: Fri Feb 06, 2009 10:24 am |
|
|
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! |
Posted: Mon Feb 09, 2009 11:53 pm |
|
|
I didn't realize that, thanks my friend, now it seems that its working right!!
Thank you very much! |
|
|
|