8

I have done various applications with the Ultrasonic example project but it is always using one pinger. I'd like to make a scanner resting on a servo sweep but to reduce sweep time use more than one censor.

the documentation is rather basic ping sonic that states the signal 40khz is used.

Down to the question now. Is there a means to tell one pinger to use 40Khz and another say 45Khz.

This would allow me to scan two areas (different directions) per cycle, reducing the time frame to complete area scan by half.

6
  • @NickAlexeev, there actually may not be an answer, the pinger hardware is the key not the Arduino itself - the 40Khz cycle may indeed be fixed by it's hardware. I will leave it sit a day and then take your suggestion, thank you.
    – alexmac
    Mar 11, 2014 at 12:09
  • The question might also work on EE.SE, but consider leaving out the Arduino tag if it's not essential.
    – Nick Alexeev
    Mar 11, 2014 at 23:30
  • By the way. With a single sensor, how long does the scan take? How many increments? How much time does the servo adjustment take? How much time does the actual ping take?
    – Nick Alexeev
    Mar 11, 2014 at 23:33
  • I am sweeping 180 degrees, its about 30 seconds all told, I am guessing from memory I did not time it. But I'd like to reduce the time.
    – alexmac
    Mar 11, 2014 at 23:45
  • You may want to clarify the question a bit. These ping sensors work on a "pulse driven" method. The Arduino sends the activation pulse, and detects the difference in time from the return (echo). Using two (or more) sensors on separate I/O pins means each sensor is activated (pulsed) separately, their ultrasonic signals do NOT interfere with each other as they will not fire off at the same time.
    – Ron J.
    Mar 12, 2014 at 12:57

3 Answers 3

4

There is no way to change the frequency, however there are other ways of doing what you want to accomplish. I think the best thing to do is stagger the timing of the pings so they don't happen at the same time.

Example code, modified by me:

#include <Servo.h> 
Servo servo; // create servo object to control a servo

int pingPins[] = {7,8}; //The pins for the two sensors
char *pingString[] = {"Ping1", "Ping2"};

void setup()
{
  servo.attach(10); // attaches a servo to pin 10
  Serial.begin(9600);
}

void loop()
{
  unsigned long ultrasoundValue;
  for(int i = 0; i < ultraSoundSignalPins.length; i++)
  {
    ultrasoundValue = ping(i);
    Serial.print(pingString[i]);
    Serial.print(": ");
    Serial.print(ultrasoundValue);
    Serial.print("in, ");    
    delay(50);
  }
  Serial.println();
  delay(50);
 } 

//Ping function
unsigned long ping(int i)
{
  unsigned long echo;

  pinMode(pingPins[i], OUTPUT);         // Switch signalpin to output
  digitalWrite(pingPins[i], LOW);       // Send low pulse
  delayMicroseconds(2);                 // Wait for 2 microseconds
  digitalWrite(pingPins[i], HIGH);      // Send high pulse
  delayMicroseconds(5);                 // Wait for 5 microseconds
  digitalWrite(pingPins[i], LOW);       // Holdoff
  pinMode(pingPins[i], INPUT);          // Switch signalpin to input
  digitalWrite(pingPins[i], HIGH);      // Turn on pullup resistor
  echo = pulseIn(pingPins[i], HIGH);    //Listen for echo
  return (echo / 58.138) * .39;         //convert to CM then to inches
}

Sources:

1

The Ping))) sensor uses a crystal for timing. Some of the cheap knock-offs actually use a MAX3232 chip (which is an RS232 serial port/usart) to detect the return pulse, just for the carrier detection. If the parallax is similar, these have a fairly wide range of frequencies they work at, since you never know the baud rate to expect, from 9600 up to 1mhz, although they are deliberately not very fussy about accidentally picking up nearby frequencies. Since there's probably some other logic on the other chips, and everything is probably run off the one crystal, I'd recommend going to lower frequencies, otherwise you're overclocking. Also, make sure to send a longer trigger pulse because all the logic will be slower. From the picture, it looks like a 16MHz crystal, which must be divided down to the 40KHz. So solder in a 14MHz, and an 11MHz, lengthen the 5 uS trigger pulse accordingly, and you should be good to go.

As an aside, you might also consider scanning further apart. If it's taking you 30 seconds, you're probably checking every degree; maybe try every 15 or 30 degrees (just make sure to give the servo time to move)

0

I don't think it would be very easy to change the frequency unless Parallax decides to release the firmware for the Ping. It is possible to use two, as long as you use a different data pin for each, but the ultrasonic signals may interfere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.