PING Sensor - Unwanted Movement

Hello I am currently running on the original ActivityBot #32500 programming in C. I am running the test code to see if the ping sensor works with Test Ping.c. However, when the power switch is in mode 2, the left servo jerks according to the distance. If the power switch is in mode 1, it doesn't move and spits out correct ping distances. The problem is in mode 2. If my hand gets closer, the left servo only, jerks backwards and vice versa. Why is the bot moving when nowhere in the code does it say to move, or why is it only the left servo that jerks. The product was purchased in in 2016 so I don't think it's an external encoder issue.
The calibration program ran successfully when I first assembled the bot, and I re-ran it just now and was again successful. I have placed in fresh batteries. I read that the relative location (space above or space below) of the servo could affect the external encoders, but that it was mitigated in 2013 (not solved?). Could the space be large enough to make it move, even when it's not supposed to?


Any help or suggestions would be great.

Comments

  • Well I assume your running this code:
    /*
      Test Ping.c
    
      Test the PING))) sensor before using it to navigate with the ActivityBot.
    
    */
    
    #include "simpletools.h"                      // Include simpletools header
    #include "ping.h"                             // Include ping header
    
    int distance;                                 // Declare distance variable
    
    int main()                                    // main function
    {
      while(1)                                    // Repeat indefinitely
      {
        distance = ping_cm(8);                    // Get cm distance from Ping)))
    
        print("%c distance = %d%c cm",            // Display distance
               HOME, distance, CLREOL);           
    
        pause(200);                               // Wait 1/5 second
      }
    }
    

    This code does nothing with the movement of the motors. The motor however are not turned on by the code so they are left with no signal going to them and should not move. If they do move it maybe some random noise that the motor is seeing. For the test program you should only be putting the switch in position 1 as position 2 powers these motors on with no signal.

    Mike
  • Correct that is the code I am using, but I don't understand why the bot even moves at all in response to the numbers that ping is getting. Is there a default behavior where if it's too close it moves back or too far it moves forward? Looking at the code, it shouldn't matter if it's on 1 or 2, if nothing in the code makes it move, it shouldn't move. Am I missing something?


  • With the unit in position 2 with no code to drive the servos the pins that connect to it are floating. There may be a stray signal coming from the pin sensor but that should not make the motor move. There is no code running that would make the servos respond to the pin sensor. Random noise is the only thing.

    Since the pin sensor uses PWM pulses to show distance we need to rule out random noise.

    add the following two lines of code to the example:
    int main()                                    // main function
    {
      low(12);  <-- set left servo off
      low(13);  <-- set right servo off
    
      while(1)                                    // Repeat indefinitely
    

    here is the code for the ping sensor that you are using above:
    int ping_cm(int pin)
    {
      long tEcho = ping(pin);
      int cmDist = tEcho / 58;
      return cmDist;
    }
    

    Mike
  • Mike,
    I added the two lines of code as you indicated, and the bots left servo still just keeps jerking forward or backwards relative to my hand in front of the ping. Any other ideas you have?
  • So, when you move your hand away, the bot rolls one way, when you move your hand closer, it rolls the other?
    That's not an explosion! That's an unscheduled rapid disassembly!
  • Take out your phone and record the event so we can see what it looks like.

    Mike
  • A second thought I have is are you downloading the program to eprom. When you move the switch it will reboot the propeller and load whatever program was left on eprom.

    So for example I do this all the time. I have my default program download to eprom and then I build some test code and use the Run with Terminal to just load the new code into memory. If I don't like the code I reboot the unit and the default code from eprom is reload. The code I just tested is gone. When I have some new stable code I use the Load EEPROM and run button.

    Mike


  • Thats the link for the video. And yes AwesomeCronk, that's exactly what it does you can see it in the above video.
    I have been using the Load EEPROM and Run button as well.
  • I figured it out, I had a resistor going from the 3-pin extender I/O cable to the P13 I/O pin on the bread board. It was sending something to make the left servo move. I switched the resistor from P13 to P8 and it works fine, sorry for the confusion.
  • I figured it out, I had a resistor going from the 3-pin extender I/O cable to the P13 I/O pin on the bread board. It was sending something to make the left servo move. I switched the resistor from P13 to P8 and it works fine, sorry for the confusion.

    Awesome! Glad you got it working!
    Infernal Machine
  • The ping sensor most be really noisy if it caused the motor to move or induct a signal across the motor wire. Very strange results none the less.

    Mike
  • Thanks for all the help folks!
Sign In or Register to comment.