Show Posts
Pages: 1 2 [3] 4 5 ... 31
31  Using Arduino / Audio / Re: RTTTL Library - Without the tone library on: August 28, 2013, 11:50:09 am
Hi, due to an incompatibility with my current program, I can not use the Tone library to play RTTL files, is there another library in which I can do this?

If there's a timer 2 compatibility issue and as a result you can't use the tone library, you can instead use my NewTone library which uses timer 1 instead.  NewTone is a drop-in replacement for tone so it would be very simple to impliment.

Another option (and maybe a better one) would be to use my toneAC library which also uses timer 1 and has many other benefits (twice as loud, uses fewer cpu cycles, more accurate, etc.).  It's not designed to be a drop-in replacement, and you would be limited to using specific pins for driving the speaker.  But, with very little effort you would have technically a better solution.  If nothing else, it would be louder (or allow you to control the volume).

Tim
32  Using Arduino / Audio / Re: Beep Sound on: August 28, 2013, 11:41:22 am
Frequency of beep, length of beep, and time between beeps.  It's then just a loop.

Tim
33  Using Arduino / Audio / Re: toneAC v1.2 - Twice the volume, higher quality, higher frequency, etc. on: August 28, 2013, 11:33:40 am
Thanks tim.

Also.. I do not want to hear the sound. Infact i want to make sure that it cant be head hence i am using this frequency. The only reason i need the amplifier is so that i can increase the volume up to a point that the phone can read it . do a fourier transform and then try and distinguish a particular frequency from another and noise... I can presently do that with a standard audio amplifier circuit but the "Volume" or db value of those frequencies is not high to distinguish them from noise enough beyond a certain distance(1 Meter in the present case) i want to extend it till about 5 M.

So can you suggest how can i connect the two outputs from the Arduino to an amplifier circuit?

I think it would be easier and cheaper to use a transducer that's designed to output ultrasonic frequencies like the  PROWAVE - 250ST180.  Also, you would need mic that's also tailored for ultrasonic frequencies.  The fall-off from most standard transducers and mics are both quite high beyond 17kHz.  In other words, if you want to transmit and receive at ultrasonic frequencies you should be using drivers and mics that are designed for those frequencies.

Also, making an amp for an alternating signal like with toneAC would be a challenge.  You can't just use two 2N2222 transistors as you also need to alternate the ground as well, which flips between the two.  Not that it's impossible, just much more complex than a typical simple transistor circuit.  Keep in mind that toneAC is designed to be like a voltage amplifier without needing an actual circuit. In essence, it doubles the voltage, which increases the volume.

It would be much easier to just use a single transistor as an amp and keep the polarity always the same by using toneAC to drive just one pin instead of both.  In other words, just use half of the output of toneAC.  The frequency will be the same, and you'll get no volume benefit as it's not doubling the voltage.  But, you don't care about that if you're going to connect the output to a transistor tied to a larger voltage.

Tim
34  Using Arduino / Audio / Re: toneAC v1.2 - Twice the volume, higher quality, higher frequency, etc. on: August 23, 2013, 11:22:56 am
Hey Thanks for that... im using ultrasound to transfer a code to a phone... So i actually do want to make sue humans cant here it.... 20k is used because the phone microphone has a die out beyond 22k... i been recording the ultrasound and using a fourier transform library on the phone that give be a power output. So i can measure if the sound is being generated. I will try using the transducer you'v mentioned.

Coming back to the amplifier question, how do i connect it to an amplifier. For the time being i am using an 8w 8 ohm buzzer that i got from a set of altec lansing speakers..

You can't make it 20kHz and expect humans to hear it.  We can't hear sounds generated at that frequency, it's at the very outer edge of what even a baby can hear, and even then it would be EXTREMELY soft.  Adults max out more in the 15kHz range.  Here's a website for you to test the maximum frequency you can hear.

Therefore, it doesn't matter how big the amplifier is, you're not going to hear a 20kHz signal.

Tim
35  Using Arduino / Audio / Re: toneAC v1.2 - Twice the volume, higher quality, higher frequency, etc. on: August 22, 2013, 10:26:30 am
Hi ,
I was trying to use the toneAC library to produce ultrasound in the 20kHz range. Firstly, the library works brilliantly and thank you for that smiley .
The only issue that i have been having is that sound isin't loud enough. I was using a standard 4 ohm buzzer and the sound output coming from it dosnt seem to be loud enough.

I tried using an Amp LM386 circuit to amplify the output .. described here http://web.mit.edu/6.s28/www/schematics/lm386.htm
But i then had to resort to use one of the 2 pins(9 or 10) which brought the clicking soung back. I have an Atmeg168.

Any you help me figure out how can i raise the output volume. I want t be able to detect the sound in a range of abt 10 m.

Lastly, Im fairly new to this smiley-grin


Humans can't hear well in the 20kHz range.  Also, many transducers don't produce much at that frequency either.  You would need an ultrasonic transducer designed for that range as well as a SPL meter to actually measure the sound output in that frequency range.  Basically, you need a different transducer and a different way to measure the volume (not your ears).

As far as the transducer, something like the PROWAVE - 250ST180 would work well, that's what I use.  Keep in mind, when you're creating a 20-25kHz sound, humans can't hear it at all.  So, while it may be able to output 105dB you won't be able to hear it at all.

To measure the volume at ultrasonic frequencies, you'll need a SPL meter.  Depending on your age and how many concerts you've gone to, the max you may be able to hear is probably in the 15kHz to 17kHz range.  Here's a Digital Sound Level Meter.  But, you can get older models on eBay for cheaper.

Hope that helps!

Tim
36  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: August 08, 2013, 02:53:58 pm
hi smiley-wink i spent the past hour trying to figure this out, but just couldnt find an answer smiley-wink so excuse me if i missed it!

here goes:

i want to use a HC-SR04 single pin solution with an Arduino Mega 2560, on the sketch page someone posted

Quote
This works with an Arduino Mega 2560 and a HC-SR04.

Be aware though that it draws 60-85mA during the 10μs trigger HIGH time from the Arduino pin to overrule the echo LOW, which is beyond the datasheet per-pin maximum (40mA). You can also see a small drop in VCC during these 10μs.

is this true? i want to use 4 of these sensors and that would basicly "overload" 4 pins by double of its specs every couple seconds and potentialy damage the arduino?

i dont really see a reason for this using up to 85mA on the ping pin since it should only draw those amounts of power from the 5V connection, or am i wrong?

i do not have the sensors here yet so i can not measure this my self currently smiley-wink so i figured i just ask smiley thank you for your reply!

Anyone can post any comment, incorrect or not.  I believe this person is just seeing a normal spike they would see with two pins as well.  It's also only for 10μs.  But, you could use a diode across the trigger and echo pins instead of just a jumper.  That would prevent any current from going to the echo pin if you're really worried about this.  I would have no way to accurately measure the current drawn for only 10μs.  But, I'd highly doubt it was 60-85mA.  I've also ran sensors for days and never had a problem.  I have done current draw measurements, but they were substantially lower.

Tim
37  Using Arduino / Sensors / Re: Help interfacing with this ultrasonic sensor - DYP-ME007Y on: July 30, 2013, 12:54:08 pm
Tim

What is you address and I will sent you the DYP-ME007Y, You can keep it. The only think, when you get the library working please let me know as I need a working waterproof ultrasonic sensor

Ron

Private message sent.  If I can tweak things to get the sensor working I'll send it back.

Tim
38  Using Arduino / Sensors / Re: Help interfacing with this ultrasonic sensor - DYP-ME007Y on: July 29, 2013, 04:36:46 pm
I to have tried to get the  DYP-ME007Y to work, the best I could get was 32cm. I plug  in a HC-sr04 ultrasonic sensor into the same program (first code listed) and I was able to get as far as 200cm. My DYP-ME007Y is going in the junk box for parts only

Maybe send it to me?  I can send it back too if you like.  I actually like getting sensors that don't work well for others.  It allows me to test to see if I can do something in the library to work around some differences between sensors.

Tim
39  Using Arduino / Sensors / Re: NewPing - last bit of performance on: July 24, 2013, 08:52:29 am
Hi,

first - big thanks for this fantastic library. I used it in two projects so far. Works perfectly.
With my new project I am pushing the Arduino Mega to its limits. I need to drive two steppers - that's the time critical part.
When I enable the pings (using the timer from the 15 sensor example) they sometimes start to stutter as it can't keep the step frequency. As far as I can see it's when the distance to ping is high. If I hold my hand in front of the sensor it's much better.

I went through all the rest of my code. No delays (all implemented as FSM) and no unnecessary complicated calculations.

So I thought it might be possible to get out the last bit of performance with direct addressing of the pins (http://forum.arduino.cc/index.php/topic,46896.0.html) and with an alternative solution on the micros delays in newPing::ping_trigger()
But it is above my capabilities. I assume if it would be simple it would be in the library  smiley-lol

Does someone see an “easy” to implement approach? Or am I on the wrong track at all?

Thanks
Robert

NewPing is already using port register calls like in digitalWriteFast, so no additional speed would be gained. If there is a timing problem, it has nothing to do with the ATmega processor. The issue would be with the sensor and how quickly you are trying to ping. There's set delays and dead periods with ultrasonic sensors. Try changing the ping to once every 100ms, that get around any kind of delay inherent with the sensor. If you still have a problem, please post your code so someone can maybe point you in the right direction.

Tim
40  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: July 24, 2013, 08:44:38 am
If I understand correctly, I should change the ping pin to trigger pin and add a routine with the echo pin as an input.  I'm sorry that I'm asking in detail, but I'm new to this and my strong point is not programming.


You would replace that entire routine with something similar to the NewPing example sketch. Probably best to get the sensor working with just the example sketch and then implement it as a replacement to the distanceCm() routine.

Tim
41  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: July 24, 2013, 05:01:29 am
Good day

Sorry I am new to this forum and Arduino. With regards to the insect bot code I posted. The question was, how do I addapt the code to use a 4 pin ultrasonic sensor.

Kind regards

Kevin

You would change the distanceCm() routine to accommodate a different sensor.

Tim
42  Using Arduino / Sensors / Re: NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.5 on: July 15, 2013, 09:20:44 am
Hi Tim,

This is great information! Many people have no idea about timers and conflicts.

Can you include this in the NewPing documentation, or point to this post there?  I KNOW I'll need this in the future..


I have this post linked from the opening post in this thread.  Also, I created Wiki pages for this as well as another common question here: https://code.google.com/p/arduino-new-ping/w/list

Tim
43  Using Arduino / Programming Questions / Re: Conflicting Libraries on: July 11, 2013, 12:41:32 pm
Thanks again,

I should have been more clear.  The error I posted there was *almost* what I was experiencing.  The following is the actual error (the only difference is the vector and libraries involved):
Code:
/tmp/build5446.tmp/Tone/Tone.cpp.o: In function `__vector_11':

/Users/oli/Documents/Arduino/libraries/Tone/Tone.cpp:438: multiple definition of `__vector_11'

/tmp/build5446.tmp/Servo/Servo.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/Servo.cpp:103: first defined here

I have googled some more and found that the Tone and Servo libraries are using the same timer on the Uno, I think these are necessary for both modules, and don't know if I can change them.

Any thoughts?

See the following post:

http://forum.arduino.cc/index.php?topic=106043.msg1312639.html#msg1312639

Tim
44  Using Arduino / Sensors / Multiple Definition of `__vector_7' Error When Compiling on: July 11, 2013, 12:17:11 pm
A common problem with using NewPing is getting a `__vector_7' error during compile.  What this error means is that you're using two libraries that are both trying to use timer 2.  The timer 2 stuff is only in NewPing for the timer interrupt method ping_timer().  If you're just using the standard ping(), ping_in(), ping_cm(), or ping_median() methods, NewPing is not using timer 2.  However, the compiler is not smart enough to know that you're not using those interrupts. So you'll get this error if any other library is also using timer 2.

There's an easy solution as long as you're not using ping_timer().  Change the NewPing.cpp program and comment out the section that calls timer 2.  Find this section at around lines 210 - 216 in version 1.5:

Code:
#if defined (__AVR_ATmega32U4__) // Use Timer4 for ATmega32U4 (Teensy/Leonardo).
ISR(TIMER4_OVF_vect) {
#else
ISR(TIMER2_COMPA_vect) {
#endif
if(intFunc) intFunc(); // If wrapped function is set, call it.
}

Comment it all out like this:

Code:
/*
#if defined (__AVR_ATmega32U4__) // Use Timer4 for ATmega32U4 (Teensy/Leonardo).
ISR(TIMER4_OVF_vect) {
#else
ISR(TIMER2_COMPA_vect) {
#endif
if(intFunc) intFunc(); // If wrapped function is set, call it.
}
*/

That's it!  Also, if the conflict is with the tone library, you can use a different tone library that doesn't use timer 2.  I've created a couple tone replacement libraries that not only use timer 1 instead of timer 2 to avoid a conflict, they also have many other advantages:

NewTone - About 1,200 bytes smaller code size than the standard tone library. Faster execution time. Exclusive use of port registers for fastest and smallest code. Higher quality sound output than tone library. Plug-in replacement for Tone. Uses timer 1 which may free up conflicts with the tone library.

toneAC - Nearly twice the volume (because it uses two out of phase pins in push/pull fashion). Higher quality (less clicking). Capability of producing higher frequencies (even if running at a lower clock speed). Nearly 1.5k smaller compiled code. Bug fixes (standard tone library can generate some odd and unpredictable results). Can set not only the frequency but also the sound volume. Less stress on the speaker so it will last longer and sound better.

In addition, version 1.6 of the NewPing library (currently under development) will include a setting that allows you to easily turn off the timer 2 stuff if you're not using the ping_timer() method.

If, however you are using the ping_timer() method you still may have options.

First, do you really need to use the ping_timer() method?  Many people incorrectly assume that if they're using multiple sensors they must use the ping_timer() method shown in my 15 sensor example.  That's simply not the case.  It's best to do it that way for "multitasking" reasons.  But, there's no reason why you can't just ping() multiple sensors like in the NewPingExample sketch.

Secondly, maybe you can use a different library that's causing the timer 2 conflict.  I've shown two other tone libraries above that use timer 1 instead of timer 2.  But, if the timer 2 conflict is with a different library, there's still a chance that you have another option.  For example, maybe the timer 2 conflict is with an LED dimmer library.  Try to find another LED dimmer library that uses timer 1 instead.  While this may not be an option for every library, there are many libraries out there so it's worth looking into.

Tim
45  Using Arduino / Programming Questions / Re: DMX output and PING sensor input won't work together on: July 11, 2013, 12:13:07 pm
Hi there!

For an art installation, I would like to read data from 3 Parallax ultrasonic PING distance sensors. These values will be used in my code to feed a function that detects if someone walks through a sensor line. In the end, depending on which sensor a distance change is detected, I would like to feed different brightness values into a DMX dimmer. That's it.

I have all the hardware, built the DMX inverter, to. I got DMX working with DmxSimple.h, and also the 3 PING sensors with NewPing.h.
Problem: as soon as I want to use them both at the same time in one program, either the DMX output doesn't work (doesn't change the brightness value on the output), or the sensors are not read (or just one of them).

I assume that they both use the same timer register of the Arduino, but as I'm new in C++ and in Arduino, I'm totally lost now in regards how to get out of this dilemma...

Here a simple example code where the problem already occurs. It would be too complicated to post my whole code, including the algorithms for the triggerings. It's not needed, I think. The code sample here not much more than two Arduino code examples taken from the web, and after successfully testing them separately, being merged into one program.

Could anyone please help me? The project was fun so far, but being stuck kind of stresses me out. Please.....

I would suggest not using the multiple ping sensor ping_timer() method that you're using.  That uses timer 2 and is conflicting with the dimmer library.  Instead, change your code to ping the 3 sensors using the standard ping(), ping_in(), or ping_cm() method which won't use timer 2. You'll also need to comment out the code that calls timer 2 in the NewPing.cpp file as shown in this thread:

http://forum.arduino.cc/index.php?topic=126251.0

Tim
Pages: 1 2 [3] 4 5 ... 31