Help reading Sharp sensors with Pololu 3pi

Hi,
Please help me solving the following problem. I have a Pololu 3pi robot. I am interested to attach 2 Sharp GP2Y0A21YK (10cm - 80cm) sensors in an application for avoiding obstacles. I have tried to connect them an PC5, ADC6 and ADC7 but I cannot read any changing value.
Measuring the signal on the sensor signal line shows that the sensors works ok. Testing different examples found in this forum couldn’t solve the problem. Any idea is highly appreciated… Thanks.

Hello.

We have a sample project that shows how to connect two Sharp distance sensors to a 3pi. Comparing our approach to what you are doing might uncover the source of your problem.

- Ryan

Hi Ryan,
Thanks a lot for your response and for your promptitude. Sorry for replaying so late. I will take a look more closer and I will come back with my news… Hope to be good news…

Hi Ryan,
After all attempts we cannot solve the problem.
The sensors are connected just like in the tutorial forum Pololu, jumpers are not connected and the 1023 value is permanently displayed on the LCD, for each program in the attachment.
We will appreciate any idea.

Thank you very much.
Pololu Problems.docx (20.7 KB)

Those programs are too complex to debug quickly. Can you make a simple program that just sits in a loop reading the sensor value and printing it to the LCD?

- Ryan

Hi Ryan,
Thanks for your response.
When trying to read signal from PC5, with or without jumper, using the program below, the result is 1023 (see photo attached).

#include <pololu/3pi.h>
int main()
{
while(1)
{
print_long(read_trimpot());
print(" p "); // to clear the display
lcd_goto_xy(0,0);
}
while(1);
}

Thank you very much.


Hi Ryan,
We are back with more information.
When connecting the SHARP sensor to GND and Vcc and ADC6 line, the signal measured on ADC6 is modifying from 0V to about 3V. That means the sensor works ok.
When trying to read with the following code, the displayed value is 1023 p.

#include <pololu/3pi.h>

int main()
{
while(1)
{
print_long(analog_read(6));
print(" p "); // to clear the display
lcd_goto_xy(0,0);
}
while(1);
}

Do you think it can be a wrong setting for the microcontroller?
Thanks

Hello.

Thanks for posting a simpler program; it makes it much easier to see what is going on. The read_trimpot method reads ADC7, not PC5. Which jumper are you adding or removing? The jumper related to read_trimpot is the one in center of the 3pi.

- Ryan

Edit: I just saw your last post, this post is just a response to your previous post, not your last one.

Hi,
For the last program code, ADC6 jumper is removed.

Thanks

Can you try disconnecting all of your additional hardware, putting back all the jumpers and reprogramming your 3pi with the Demo program? What do you see for the battery voltage when you do that? Does changing the trimpot have a corresponding change to the trimpot reading in the Demo program?

- Ryan

All additional hardware disconected…
All the jumpers put back…
Reprogramming 3pi with the Demo program…
Battery voltage = 7500 mV
Changing the trimpot --> no change in the trimpot reading in the Demo program.

:frowning:

Dear Ryan,
It’s unbelivable…
We have solved the problem installing the latest Pololu libraries. Now we can read sensors.
Thank you very much for your help and your kindness.

Best regards,
Chris

I’m glad you got it working, and thank you for letting us know what caused the problem. What version of the libraries were you using when it did not work?

- Ryan

Hi Ryan,
Please find attached the library with problems.

Best regards,
Chris
libpololu_atmega328p.zip (48.4 KB)