ADC Behavior Issue

illy@scharco.de
Posts: 11
Joined: Mon Nov 13, 2017 1:28 pm

ADC Behavior Issue

Postby illy@scharco.de » Thu Jul 05, 2018 1:08 pm

Hello,

I try to get the coordinates from a touch TFT. I have 4 wires X-and X+, Y- and Y+ (IO33-IO26-IO25-IO32). My supply voltage is 3v3. I can get with the ADC the position for X alone, the postion for Y alone as well. The problem is when I want the both position, I can't get any value from the ADC: X=Y=0!

int abscis() {
int X=0;
gpio_set_direction(GPIO_NUM_26, GPIO_MODE_OUTPUT); //X+
gpio_set_level(GPIO_NUM_26, 1);
gpio_set_direction(GPIO_NUM_32, GPIO_MODE_INPUT); //Y+
gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT); //Y-
gpio_set_level(GPIO_NUM_25, 0);
gpio_set_direction(GPIO_NUM_33, GPIO_MODE_OUTPUT); //X-
gpio_set_level(GPIO_NUM_33, 0);
adc1_config_width(3); //12 bits
adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_11db); // value on Y+ - for 3V3
X=adc1_get_raw(ADC1_CHANNEL_4)/(4096/240);//reads X axis touch position 240 pixels
return X;
}

int ordon() {
int Y=0;
gpio_set_direction(GPIO_NUM_32, GPIO_MODE_OUTPUT); //Y+
gpio_set_level(GPIO_NUM_32, 1);
gpio_set_direction(GPIO_NUM_26, GPIO_MODE_INPUT); //X+
gpio_set_direction(GPIO_NUM_33, GPIO_MODE_OUTPUT); //X-
gpio_set_level(GPIO_NUM_33, 0);
gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT); //Y-
gpio_set_level(GPIO_NUM_25, 0);
adc2_config_channel_atten( ADC2_CHANNEL_9, ADC_ATTEN_11db ); //value on X+ - for 3V3
adc2_get_raw( ADC2_CHANNEL_9, ADC_WIDTH_12Bit, &Y);
return (Y/(4096/320)); //reads Y axis touch position 320 pixels
}

while (1){
int X=abscis();
int Y=ordon();
printf ("X=%d Y=%d\r\n", X,Y);
Wait(300);
}

I have read all I could find on the web but nothing helped and I am stucked!

Any advice would be appreciate :)

Thanks and regards!

Who is online

Users browsing this forum: Majestic-12 [Bot] and 112 guests