Show Posts
Pages: 1 2 3 [4] 5 6 ... 35
46  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: May 02, 2014, 08:36:50 am
Hi Tim,

I was wondering if you could advise me on how to connect a HC-SR04 to the official arduino robot, I am stumped and have promised some kids a model of R2-D2 for a music event on Sunday using the robot as it's base but only realised afterwards that it doesn't support digital sensors out of the box, please help!

Thanks,
Jay.

I don't know what you mean buy it doesn't support digital sensors.  The Arduino Robot's control board has 5 digital I/O ports and the motor board has 4 I/O ports.  It looks like the control board has 8 multiplexed pins labeled TK0-TK7 that can't be used with NewPing.  But, the specs say there's 5 digital I/O pins, so the interfaces to these pins are in other locations.  The motor board's 4 I/O pins TK1-TK4 do have connection ports right on the board that are not multiplexed so they can go straight to the ultrasonic sensor.  NewPing can interface with a HC-SR04 using only one pin, so you can wire both the trigger and echo pins on the sensor to the same I/O pin on the Arduino Robot.  While TK1 and TK2 are analog pins, they will work just fine as digital pins as well.  Remember, analog pins are also always digital pins (but not vice versa).

Since it seems that the motor board is the easier to connect an ultrasonic sensor via NewPing, here's some code that should work (keep in mind that I don't have an Arduino Robot so this is just a shot in the dark, anyone willing to donate one?):

Code:
#include <NewPing.h>

NewPing sonar(TK3, TK4, 200);

void setup() {}

void loop() {
  delay(50);
  unsigned int cm = sonar.ping_cm();
  // Do something with the results
}

To conserve available pins, you could also use the same pin for trigger and echo.  Also, remember that you could just as well use TK1 and TK2 even though they're analog pins, they will work as digital.

Hope this helps!

Tim
47  Using Arduino / Audio / Re: how can i display high frequencies (40kHz to 75 kHz) on: April 30, 2014, 11:57:36 am
My toneAC library was designed to work at very high frequencies, 2.66 MHz even!  As a bonus, it will also drive the two ultrasonic leads in a push/pull manor which will generate much louder output (almost twice as loud).  So, you'll be able to scare those little buggers from further away.

Here's an example sketch that will loop from 40 kHz to 75 kHz.  You would connect your speaker leads to pins 9 & 10 if you're using an Arduino Uno.  If you're using different hardware, you should check the toneAC website to see what pins to use.  You'll also (obviously) need a transducer that can generate sufficient output in this frequency range (I have some that are designed to peak at 40 kHz and 60 kHz).

Code:
#include <toneAC.h>

void setup() {}

void loop() {
  for (unsigned long freq = 40000; freq <= 75000; freq += 20) {  
    toneAC(freq); // Play the frequency (40 kHz to 75 kHz in 20 Hz steps).
    delay(2);     // Wait 2 ms so it will generate output.
  }
}
48  Using Arduino / Audio / Re: TimerFreeTone Library v1.1 - Generate audio tones without any timer conflicts on: April 30, 2014, 11:44:55 am
New version of the Timer FreeTone library released.

Download TimerFreeTone v1.1

This release was actually tested on an Arduino, so I'm sure it works now.  I also fixed/changed a few things.  It generates code that's a bit smaller as well.  Let me know how it works for you!

Tim
49  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 28, 2014, 07:56:52 pm
Hi I'm trying to use your library with arduino due and the 1.5 version direct seem to have support. I noticed on the Google code page a note said that 1.6 will have support but it's not released yet. I tried to find the source on the Google code page but u don't seem to host the source code on it. Is there due support available?

Version 1.6 does support the Due.  Well, I believe it does.  I don't have a Due to verify this.

Tim
50  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 25, 2014, 04:38:14 pm
little confused on the "code.google" site changes.  are the "issues" you marked as done going to have the changes in the next version?  also, why remove that issues list?  it seems a very effective way to track features and bugs.  the forum thread is kind of overwhelming, and very difficult to track any issues on.


I'm not notified when issues are created or when people make comments to sketches.  Also, there isn't a good way of communicating about an issue.  On this forum, I get notifications and others or myself can answer.  No issues were looked at on the code.google site.  If you have an issue or a suggestion, just post to this thread.

Thanks!

Tim
51  Using Arduino / Audio / TimerFreeTone Library v1.1: Play tones without timers and therefore no conflicts on: April 25, 2014, 09:45:42 am
I've already written 3 alternative tone libraries (toneAC/toneAC2 & NewTone).  However, a user asked for a way to create tones without using any timers as he had conflicts with both timer 1 and timer 2.  This seemed like a perfect opportunity to confuse people further by creating a 4th library that did essentially the same thing, generate sound.  So, I wrote up sample code that evolved into the TimerFreeTone library.  As a bonus, it works with all ATmega/ATtiny AVR microcontrollers as well as the Arduino Due, Teensy 3.0/3.1 and other ARM-based microcontrollers equally well.

Download TimerFreeTone v1.1

Version 1.1 added a few small changes (after I got around to actually tested the library first-hand with an Arduino).

Code:
#include <TimerFreeTone.h>

#define TONE_PIN 10 // Pin you have speaker/piezo connected to (be sure to include a 100 ohm resistor).

int melody[] = { 262, 196, 196, 220, 196, 0, 247, 262 };
int duration[] = { 250, 125, 125, 250, 250, 250, 250, 250 };

void setup() {
  for (int thisNote = 0; thisNote < 8; thisNote++) { // Loop through the notes in the array.
    TimerFreeTone(TONE_PIN, melody[thisNote], duration[thisNote]); // Play thisNote for duration.
    delay(50); // Short delay between notes.
  }
}

void loop() {}

TimerFreeTone Library home page

Tim
52  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 23, 2014, 05:44:55 pm
Hi,

I am using 3 HC-SR04 sensors. I tried the sketch but it doesnt even print out anything. What should I do

Check your settings and sketch, as I'm 101% sure it works.  Thousands have used it.  Maybe you don't have the serial baud rate set correctly to match the sketch?

Tim
53  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 23, 2014, 04:37:23 pm
@Teckel thank you for this library contribution. Is it possible to use this with an ultrasonic sensor like the Hagisonic HG-M40DAI? Its signal output timing is from rising edge of input pulse (trigger) to rising edge of output pulse (echo). In other words, almost the reverse of sensors like Ping.

Datasheet: http://www.robotshop.com/media/files/pdf/hagisonic-anibat-data-sheet.pdf.

If you're curious why the Hagisonic sensor, this "AniBat" model has the unique advantage (AFAIK) of an extremely wide field of view - 180°.

Thanks,

Eric

It sounds like it's similar to the URM37 sensor (hi/low switched).  I'm sending you a private message that may help.

Tim
54  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 11, 2014, 10:13:35 am
Got it working on my obstacle avoidance robot with three SR04 sensors up front and it is working very well.   Great improvement.

The "multi-tasking" or maybe I should correctly stay "event-driven" or "task-switching" method of pinging even one sensor that NewPing uses is a vast improvement over other methods.  Using multiple sensors multiplies this improvement.  Glad it's working for you!

Tim
55  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 10, 2014, 02:15:40 pm
In the multiple sensor examples, how do I actually call up the data for the individual sensors to use that data?  For instance, I might want to compare the first sensor to the second, or the first to the third, or figure out which sensor has the highest or lowest reading.

Please see the 15 Sensors Example Sketch Help.  Everything is detailed in that post.  Basically, everything is stored in an array so you can easily extract the information you want.  The above linked help message will explain everything and gives alternative code to accomplish different tasks.

Tim
56  Using Arduino / Sensors / Re: More prescise control of Ping Sensor on: April 03, 2014, 03:41:28 pm
Hey, I'm using an ultrasonic ping sensor similar to the "Parallax PING sensor", using the NewPing library: http://code.google.com/p/arduino-new-ping/ . What I'm wondering is if I can get ore precise control, such as sending out a single pulse, and being able to listen for the sent pulse. For example I want to send a pulse towards 2 panes. I should get back multiple reflected signals and from the results possibly measure the distance between the panes

As the author of NewPing, I know a thing or two about how ultrasonic sensors are designed.  Your first problem is that most send out several pings when you initiate just one.  This is done to be more sure they get a reflected ping back.  Therefore, all it ever really knows is when the FIRST reply comes back.  Your second problem is that almost every ping sensor has a "quiet time" after a ping where it basically turns off before it will initiate another ping.  This is done to prevent any echo readings.

Basically, you won't be able to do what you want, even with multiple sensors as each sensor will only ever give you the reading of the FIRST echo (the closest object).  To do what you want, you would need to design your own custom ping sensor that would send out a ping and then catch all return pings and process this information probably in your sketch.  Designing your own ping sensor can be done, but is very challenging.

My first thought is to contact MaxBotix.  They may have designed a sensor like this already and are known for designing sensors for custom applications.  As it would be difficult to design your own ping sensor, it may be easier and less expensive to have MaxBotix do it for you.

Hope this helps!

Tim
57  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: April 03, 2014, 03:30:35 pm
Hello,

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.

Tim
58  Using Arduino / Sensors / Re: HC SR04 getting dammage? on: March 28, 2014, 08:21:39 am
As noted several times, here's the NewPing library page along with sample sketches.  The library also comes with sample sketches when you download it.

And here's a help page on how to customize the 15 sensor sketch.

These have already been provided and this is the most I can give you.  It's up to you to figure it out from here, or find someone who's willing to do all the work for you (which is NOT me, you can't afford me).

Tim
59  Using Arduino / Sensors / Re: HC SR04 getting dammage? on: March 27, 2014, 12:48:37 pm
Sounds like you got bad sensors.  I have some that I've run for days without a problem.  But, as most are cheap Chinese knockoffs, I'm sure this can happen.

Tim
60  Using Arduino / Sensors / Re: HC SR04 getting dammage? on: March 27, 2014, 10:56:35 am
hello, my HC SR04 is getting damage again and again. initial when i change it it works for few minutes and then not working, it happens to 3 of this sensor modules what can I do ?

If they're damaged, you would get replacements.  Or, do they just stop working and when you restart the sketch they work again.  If so, it could be a programming issue, not damage.  Have you tried a different way to interface with the sensor?  Try using the NewPing library to see if that changes things.

Tim
Pages: 1 2 3 [4] 5 6 ... 35