"set_analog_pullup" Not Working

3 replies [Last post]
benliao
Title: NooBot
Joined: 03/29/2015
Posts:
BotPoints: 3
User offline. Last seen 2 years 36 weeks ago.

I wrote some code just to simply get the readings from the ET sensors on the front and back of my robot. The one on the front is plugged into analog port 7, and the one on the back is plugged into analog port 1. I know that to get readings from the ET sensors, you need to set the "analog pullup state" to 0, so here is what I wrote:

#include

int main()
{
set_analog_pullup(1,0);
msleep(20);
set_analog_pullup(7,0);
msleep(20);

while (a_button() == 0) {
set_analog_pullup(1,0);
set_analog_pullup(7,0);
display_clear();
printf("Front value at %d\tBack value at %d\n", analog(7), analog(1));
msleep(1000);
}
return(0);
}

When I run this program, the display on the Link just gives me "Front value is 889, Back value is 889" or something like that--as if I had not enable the pull-up resistors.

I am not an extremely good programmer, but I do have some experience. I also have some experience programming with the KISS IDE and the KIPR Link. This is my first attempt at programming with ET sensors.

Another thing, too--the ET sensors DO work. I went to Home>Motors and Sensors>Sensor List to view the readings from analog ports 1 and 7 and clicked "Toggle Pull-up" for both of them and I got good, accurate readings from both of them. So I really don't understand why my program isn't working, because from everything I've read on this website and on the "Getting Started on the KIPR Link" pdf file, the above program should work.

Thanks for anybody who helps! This problem is preventing me from doing anything with the sensors.....

bonnienichols
Title: NooBot
Joined: 03/07/2014
Posts:
BotPoints: 52
User offline. Last seen 1 year 36 weeks ago.

sorry. but i am not getting the flaws in the code.

free pokie games

Terry
Terry's picture
Title: NooBot
Joined: 06/08/2009
Posts:
BotPoints: 55
User offline. Last seen 28 weeks 6 days ago.

The problem is that the latest version of the OS has changed the command for using ET sensors to make it easier (unless you remember the old way!). For reading ET sensors, don't do anything overtly, just use the command: analog_et(n), where 'n' is the port number. This automatically removes the pullup, to return good levels.

History is a race, between Education and Catastrophe

panistefanin
Title: NooBot
Joined: 05/29/2017
Posts:
BotPoints: 42
User offline. Last seen 4 weeks 5 days ago.

I would like to read about it anymore. Prompt, what literature to study?
192.168.o.1