Go Down

Topic: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7 (Read 615826 times) previous topic - next topic

tsmacinspires

There's no reason to put people down here, especially if they are being kind. I didn't mean your code doesn't work, I meant (as you stated) it probably needs median assistance. I know the limitations of sonar and I'm not putting it at a 90 degree when testing nor am I using soft materials. I'm actually using a flat board just like you stated.
I already had code similar to this running, using your GitHub, but I cannot get the median to work with multiple sensors. You have many fans of your code asking for an example using median and multiple sensors. Any way you can put that up?
I really do appreciate your support, I think it's really cool you continue to support this community as I'm a teacher.
Thank you!

teckel

There's no reason to put people down here, especially if they are being kind. I didn't mean your code doesn't work, I meant (as you stated) it probably needs median assistance. I know the limitations of sonar and I'm not putting it at a 90 degree when testing nor am I using soft materials. I'm actually using a flat board just like you stated.
I already had code similar to this running, using your GitHub, but I cannot get the median to work with multiple sensors. You have many fans of your code asking for an example using median and multiple sensors. Any way you can put that up?
I really do appreciate your support, I think it's really cool you continue to support this community as I'm a teacher.
Thank you!
As for working with multiple sensors, that example has already been written, and is on the official page. Please see the example "Ping 3 Sensors Sketch". Start with that code, not code using a programming paradigm you don't understand. See the NewPing official page that includes all kinds of warnings NOT to use code that you don't understand (which is what you're using now and why you're having problems).

Next, there's already a method for doing multiple pings and returning the median result called ping_median(). In the "Ping 3 Sensors Sketch", you would simply exchange
Code: [Select]
ping_cm()
with
Code: [Select]
ping_median() / US_ROUNDTRIP_CM
 
That's it! That's why I say it's uber simple, just use ping_median()! It's already all written for you, why make it difficult by instead using code you don't understand?

As I've said probably 100 times in this forum, don't use code examples you don't understand. Use the examples on the official page and HEED ALL WARNINGS about NOT using an event-driven programming paradigm example if your not an expert.

If you feel you're and expert coder or you must use the event-driven 15 sensor sketch example instead of the 3 sensor example, there's a HUGE wiki with tips (and a TON or warnings that it's probably over your head). The wiki is (again) on the official site, here's the direct link:

Help with 15 Sensors Example Sketch

So what's this nonsense about people wanting to use median results with multiple sensors? The code is all written for you, just use it!

Can you understand my frustration? I've written the library, I've given you the examples, and instead of using these, you choose to use the most complex example that's beyond your understanding, ignore all the warnings, refuse to read the wiki, wonder why it's not working, then ask for your code to be debugged, when it will never work as you're using two different programming paradigms in the same code. It will NEVER work! There's no way to fix it. Start over using code examples you understand (simple blocking mode programming paradigm).

I've literally said this 100 times. From now on, anyone who asks for help when using code they obviously don't understand will be pointed to the wiki and that's it. If you're an expert coder, that's all you'll need. If you're not an expert, not even God can help you.
My platforms Arduino, Teensy 3.2, Arduino Pro Mini, ATmega328
My libraries: NewPing, LCDBitmap, toneAC, toneAC2, NewTone, TimerFreeTone
My projects: https://dogblocker.com & https://baconorbeer.com
My beer: Great Lakes Brewing Co. Lake Erie Monster

tsmacinspires

I'm sorry for your frustration. Once again, I only went to the convoluted code after trying the code on your GitHub. I tried your instructions to change
ping_cm()
with
Code: [Select]
ping_median() / US_ROUNDTRIP_CM
and it didn't work for me. Then I went to this forum and found that code you hate. I will give it a shot again. Thanks.

asghar144

Hello,
I am testing your library multi sensor example with 5 sensors on arduino mega every thing is work just fine i am not using any delay in my sketch using 15 sensors   unmodified (removed only serial.print) my sketch should run on 250HZ constant loop time and my sketch keep 250HZ confirmed with oscilloscope but when arrive ping time the loop time goes to 240HZ then come back again. is there a way to make this library true multitask to solve my issue?? thanks in advance for any help.

asghar144

No body has Answer my question so answering myself.
newping library is not as multitask as claimed and vary cycle time that cannot be tolerate in a serious robot project i have solved my problem by adding an Arduino Nano as driver for 5 sr-f06 and connected with Arduino Mega via I2C so every variation of time remain in Nano and Mega have perfect timing for drive motors.
Anyway Thanks to Author of this library.

asghar144


jaybelfast

Hi, Silly question but does anyone know how to store the actual sensor data into 3 separate variables (or array) from the 3 sensor example so that they can be recalled later in the code if needed?

ballscrewbob

@jaybelfast

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

DaveEvans

Hi, Silly question but does anyone know how to store the actual sensor data into 3 separate variables (or array) from the 3 sensor example so that they can be recalled later in the code if needed?
Sounds like you need to do some self-education. 

Start with the basic example sketches and also take time to study the section of the on-line reference that talks about variables (which includes arrays): https://www.arduino.cc/reference/en  <-- can also be accessed from the "RESOURCES" tab of the Arduino website menu.

Go Up