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.
john21403:
To convert the results to millimeters, just multiply the centimeter results by 10.
multiplying adds 0 at the end nothing more...
elac:
You want it to print mm instead of cm in the console?
If so change the abbreviations in the sketch:
Serial.println("cm");
to
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..
makerman:
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:
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:
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).
john21403:
To convert the results to millimeters, just multiply the centimeter results by 10.
multiplying adds 0 at the end nothing more...
elac:
You want it to print mm instead of cm in the console?
If so change the abbreviations in the sketch:
Serial.println("cm");
to
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:
#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.
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.
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.
My problem is that I am using a waspmote, not arudino (although are almost the same, but have their own API etc).
So I really can't use this and I am not having a lot of time right now to even look into understanding it and try to port it to waspmote
Thanks anyway
Oh, this is an Arduino forum. If your microcontroller isn't ATmega8, you're not going to get a lot of help here. If it is ATmega8, then NewPing should work.
I would like to use 12 x HC-SR04 with an I/O multiplexer MCP23017 (or other) and NewPing library.
Is it possible ?
If yes, how do we configure the newping trigger et echo of the library?
If not, what solution to use knowing that I do not have enough I/O port?
I would like to use 12 x HC-SR04 with an I/O multiplexer MCP23017 (or other) and NewPing library.
Is it possible ?
If yes, how do we configure the newping trigger et echo of the library?
If not, what solution to use knowing that I do not have enough I/O port?
Thank you in advance for your information
First, you only need 12 pins to control 12 HC-SR04 sensors using NewPing. So, using an I/O multiplexer may not even be required. Secondly, you can't use NewPing with an I/O multiplexer as it uses direct port register calls. If you don't have 12 available pins to control 12 sensors, you'll either need to use a Adruino Mega or develop your own custom sensor library or sketch to interface with your I/O multiplexer.