Pages: 1 ... 27 28 [29] 30 31 ... 34   Go Down
Author Topic: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5  (Read 115116 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I try to compile a sketch that includes the NewPing library, I receive the following error:

In file included from echo_sensor_test_NewPing_lib.ino:1:
/Applications/Arduino.app/Contents/Resources/Java/libraries/NewPing/NewPing.h:113: fatal error: avr/io.h: No such file or directory
compilation terminated.

I can't find any information about the avr/io.h file or the avr library to tell me where to find it or how to load it .

I am new to this, and didn't find any information about this error.

john
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I forgot to include my environment info:
MAC OS X 10.6.8 Snow Leopard
Arduino 1.5.4
Hardware is an RFduino, version 1.7, with the HC-SR04 sensor.


When I try to compile a sketch that includes the NewPing library, I receive the following error:

In file included from echo_sensor_test_NewPing_lib.ino:1:
/Applications/Arduino.app/Contents/Resources/Java/libraries/NewPing/NewPing.h:113: fatal error: avr/io.h: No such file or directory
compilation terminated.

I can't find any information about the avr/io.h file or the avr library to tell me where to find it or how to load it .

I am new to this, and didn't find any information about this error.

john
Logged

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

how can i change results to mm?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To convert the results to millimeters, just multiply the centimeter results by 10.
Logged

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

no, i mean real mm ... 
multiplying adds 0 at the end..
Logged

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You want it to print mm instead of cm in the console?
If so change the abbreviations in the sketch:
Code:
Serial.println("cm");
to
Code:
Serial.println("mm");
And do as  john21403 says to mathematically  convert cm to mm.
Logged

It's all about the skills

Estonia
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To convert the results to millimeters, just multiply the centimeter results by 10.
multiplying adds 0 at the end nothing more...
You want it to print mm instead of cm in the console?
If so change the abbreviations in the sketch:
Code:
Serial.println("cm");
to
Code:
Serial.println("mm");
And do as  john21403 says to mathematically  convert cm to mm.
that changes only printed text ..


but i need real measured values in mm not  cm
because cm result is rounded to full cm, but i need to see fraction
and i cant find where the rounding process is in code..
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having problems compiling v1.5 for the Arduino Due. It compiles and works great for Uno, Mega 2560, Yun and Leonardo.

I am using the 1.5.5 version of the IDE on Ubuntu 13.10.

Here is the result of the compile:
Code:
In file included from NewPingExample.ino:5:
/home/afy/sketchbook/libraries/NewPing/NewPing.h:113: fatal error: avr/io.h: No such file or directory
compilation terminated.

I realize that this is an IDE issue, but am asking if it has already been solved for others.

Thanks.

NewPing uses port registers and timer interrupts and is therefore designed for ATmega microcontrollers.  With that said, v1.6 of NewPing will support non-AVR microcontrollers for all but the ping_timer() method.  Meaning the following methods will work:

ping()
ping_in()
ping_cm()
ping_median()
convert_in()
convert_cm()

The ping_timer() method will not be functional as custom timer interrupt code would need to be written for every microcontroller variant which at this point is a never-ending task with all the ARM-based mircocontrollers being used in different projects both Arduino and others (like Teensy 3.0/3.1).

Tim
« Last Edit: March 04, 2014, 01:45:09 pm by teckel » Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To convert the results to millimeters, just multiply the centimeter results by 10.
multiplying adds 0 at the end nothing more...
You want it to print mm instead of cm in the console?
If so change the abbreviations in the sketch:
Code:
Serial.println("cm");
to
Code:
Serial.println("mm");
And do as  john21403 says to mathematically  convert cm to mm.
that changes only printed text ..


but i need real measured values in mm not  cm
because cm result is rounded to full cm, but i need to see fraction
and i cant find where the rounding process is in code..

Just use the ping() method instead of ping_cm() then do your own conversion from distance at the speed of sound to mm.  Without your sketch it's hard to tell you exactly what to do.  But, it would be something like this:

Code:
#include <NewPing.h>

NewPing sonar(12, 11, 200); // NewPing setup of pins and maximum distance.

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  delay(50);                     // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping()/6); // Send ping, get distance in mm and print result (0 = outside set distance range)
  Serial.println("mm");
}

Keep in mind, I'm dividing by 6 although 5.7 to 5.9 may yield more accurate distances, with the disadvantage of much larger and slower code to do floating point math.  So, you could do something like "sonar.ping()/5.7" if you'd like, but your code will be much larger.

Also, keep in mind that the sensor is not accurate down to a mm level, which is why people typically round to the cm level.  It can give very stable results at a cm level.  However, using the above sketch will give wildly different results each time with no consistency or even more accuracy.  Which is why others have just suggested that you multiply by 10 if you really just want to get a value in mm.  As it's no more accurate to use the above sketch, and if anything more confusing as the results are always different.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 With that said, v1.6 of NewPing will support non-AVR microcontrollers for all but the ping_timer() method.  

Has v1.6 been released yet?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!
I have a DYP-ME007Y connected to an Arduino as follow:

Arduino          Sensor
5V                     5V
Trigger            Pin 2
Echo                Pin 4
Ground          Gnd

How do I use your NewPing files?

Thanks a lot for the help!! smiley

Martin
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 With that said, v1.6 of NewPing will support non-AVR microcontrollers for all but the ping_timer() method.  

Has v1.6 been released yet?

No, you can check for a new version here:

https://code.google.com/p/arduino-new-ping/downloads/list

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!
I have a DYP-ME007Y connected to an Arduino as follow:

Arduino          Sensor
5V                     5V
Trigger            Pin 2
Echo                Pin 4
Ground          Gnd

How do I use your NewPing files?

Thanks a lot for the help!! smiley

Martin

Use the demo sketch and set the trigger and echo pins accordingly.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey dude this is great!

However I am using a Waspmote board with the DYP ME007 and I am using pulsein and I bad readings, as it seems to have problem with "high" distances (like above 160cm) and it actually "crashes" when I move the sensor to sense longer distances.

Anyone have experienced this? I am losing my head :/
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey dude this is great!

However I am using a Waspmote board with the DYP ME007 and I am using pulsein and I bad readings, as it seems to have problem with "high" distances (like above 160cm) and it actually "crashes" when I move the sensor to sense longer distances.

Anyone have experienced this? I am losing my head :/

Correct, using the pulsein method can create "crash" like situations.  Instead, use the NewPing library.  It will also be faster and use less program space.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Pages: 1 ... 27 28 [29] 30 31 ... 34   Go Up
Jump to: