Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: November 19, 2012, 02:04:33 am
Dear amatbrewer,
First, thanks for the lib! I love it.
It is a great lib indeed!

Second I will apologize in advance if this has already been asked, but I can't seem to search just this topic so I may have missed it, if it was.
you did miss it indeed! It's just on the previous page: http://arduino.cc/forum/index.php/topic,106043.msg959928.html#msg959928

Has any one else experienced an error when attempting to use tone() along with this lib?
I had stumbled upon this error just a while ago, and after searching around I found the toneWorkaround function in a book (Arduino Cookbook, page 307). You can find the function I used here: http://arduino.cc/forum/index.php/topic,106043.msg959970.html#msg959970

basile
2  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: October 30, 2012, 01:43:43 am
After the substitution of the tone function with the toneWorkaround one and the change of the power supply of the PING))) (attached to A4) to getting it's power from the Arduino everything is working juuuust fine!!!
I am now using the ping_median for the pings just in case there is some interference.

Thanks again for the great library.

basile
3  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: October 17, 2012, 03:27:24 am
This is part of the sketch I am using:
This is part of an answer I am giving: tone.

That's exactly why I replaced the tone function with this function:
Code:
void toneWorkaround(byte tonePin, int frequency, int duration) {
  int period = 1000000L / frequency;
  int pulse = period / 2;
  for (long i = 0; i < duration * 1000L; i += period) {
    digitalWrite(tonePin, HIGH);
    delayMicroseconds(pulse);
    digitalWrite(tonePin, LOW);
    delayMicroseconds(pulse);
  }
}

Even after this modification to my code though the Parallax PING))) refuses to work when using the NewPing library.

Right now the Parallax PING))) is working and returning correct values with this code:
Code:
long ping(byte pingPin) {
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  pinMode(pingPin, INPUT);
  long duration = pulseIn(pingPin, HIGH);
  return duration;
}

basile

P.S.: robot's full code as is right now: http://pastebin.com/jc2sgQ4t
4  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: October 17, 2012, 02:18:26 am
This is part of the sketch I am using:
Code:
#include <NewPing.h>

NewPing sonar = NewPing(A4, A4, 300);

void setup() {
}

void loop() {
  tone(12, 2999, 3000);
}

When I try to verify the sketch I always get this error:
Code:
core.a(Tone.cpp.o): In function `__vector_7':
C:\...\arduino-1.0\hardware\arduino\cores\arduino/Tone.cpp:523: multiple definition of `__vector_7'
NewPing\NewPing.cpp.o:C:\...\Documents\Arduino\libraries\NewPing/NewPing.cpp:214: first defined here

Even when I comment out or delete the 3rd line ("NewPing sonar = ...") I still get the same error.

basile

P.S.: I am using a Parallax PING))) sensor on an Arduino UNO board and I think (I am not sure because the test has been performed by a friend) that when it is connected to A4 (as in the example) it doesn't work. Unfortunately right now there are no digital ports available.
5  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: October 11, 2012, 01:45:15 am
Unfortunately for me, I am using the tone library and wanted to use the NewPing library too.
Do you know any way around the conflict?
It can be also a new tone library (or a modified one) or another way of playing a tone without the usage of the Timer2

TIA,
basile
Pages: [1]