Problem with ultrasonic sensor - what are pins 16/17?

I am troubleshooting my blimpduino in autonomous mode. I have tracked it down to the ultrasonic sensor. I am using the serial console while manually holding the assembled gondola. My ultrasonic sensor returns an altitude of 0 almost all the time. Occasionally I will get a reading of something around ~250 and then within 3 - 4 system_refresh() prints, it goes back to zero. This is regardless of what I have the sensor pointing at (the roof, the floor, or even my hand about 12" in front of it).I think I have found another issue, but it could just be my noob status with arduino. I have read the MaxSonar EZ4 datasheet and I think I have a pretty solid grasp on the timing and how to use the PW and RX ports, which is what the blimpduino code is using to get the distance reading. What has really thrown me for a loop though is that its using pin 15 as the EZ4 "RX" pin and pin 16 as the EZ4 "PW" pin. Call me crazy, but the atmega168 doesn't have digital pins 15 and 16. According to http://arduino.cc/en/Hacking/PinMapping168 it only has up to pin 13. I know the link to that chip is a different package style than the one on the blimpduino, but shouldn't the pin naming be the same? ( I was mapping blimpduino pins to the above referenced diagram using the naming found in the datasheet at http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf )For that matter, I see some of the LEDs using pins higher than 13 as well (east led is using pin 17 for example).What gives? Is there some funky pin configuration on the blimpduino or should it be like any other atmega168 arduino pinout?If all this pin stuff is correct and I just don't understand it, then why is my ultrasonic sensor acting this way?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • I figured out the pin mapping. Pins 15 and 16 used for the ultrasonic sensor are the same as analog pins 1 and 2, physically known as PC1 and PC2 or ADC1 and ADC2 in terms of ATMega mapping. All so clear now :) The basic pinout diagram I found doesn't show both the digital pin ID and the analog pin ID, so I didn't know digital pin 15 was the same as analog pin 1.

    Now that I have that down....

    I was spending a little more time learning more about the blimpduino board, looking at the EAGLE files, etc, and I came across something interesting that might be the cause of my ultrasonic sensor issue. I see the board has a solder jumper on the bottom to select between PWM and Analog modes from the EZ sensor. On the B6 board (or at least on mine), the default solder position is in AN mode, but the source code for version 1.1.1 is clearly treating it as if it was in PW mode. This made me think I might have old code. Sure enough, there is a file dated newer than 1.1.1 in the google code repo and when I looked at the code, the raw_ultrasonic function seems to be using analog reading code instead of the pwm code found in 1.1.1.

    I am going to try the unversioned code on google dated may 23rd and hopefully have better luck with the sensor.
  • I haven't found a good source of logical vs physical pin layout. I did just come across this page which helps a little, but as a beginner, it's hard to say which pin is which on the different physical format atmega chips.

    http://www.arduino.cc/playground/Learning/Pins

    If this page does apply to the blimpduino, then it looks like the code is using a couple of the analog pins to try and talk to the EZ4. So maybe it is a sensor problem.

    I will take you up on your offer and PM you my address. Thanks Chris!!
  • 3D Robotics
    It's a standard Arduino. Are you sure you're not confusing physical pins with logical pins?

    Sounds like you've but a bum ultrasonic sensor or a soldering problem. Want me to send you a replacement sensor so you can test? You can send it back if that's not the issue.
This reply was deleted.

Activity