Engine sounds and motion with Arduino!

Status
Not open for further replies.

ChromeRhino

New member
Messages
285
Reaction score
0
Location
Michigan
Hey everyone,

I am getting back to my Rat Wagon build (http://www.diygokarts.com/vb/showthread.php?t=32790) that will consist of an electric 24v motor to power it with a fake engine up front to complete the "look" of a hot rod/rat rod. Now, we can't have a "hot rod" without the engine sounds of a hot rod, now can we?! (well, we COULD... it just wouldn't be as cool!) It seems that I don't get much done but am always adding to it and making it much more of a project with more difficulty. Ah well, it's in my nature.

Enter in to the project a Arduino Uno R3 microcontroller. I searched to see if anyone else has did anything on here with an Arduino but I couldn't find any so I guess I will touch a bit on what it is, how it works and what I plan to do with it.

Arduino (usually pronounced Ar-dwing-o, but there are other pronunciations) is a company based in Italy that makes an open-sourced micro-controller with various platforms with various options. (From Wiki-pedia) A microcontroller is a small computer (SoC) on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of Ferroelectric RAM, NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. The platform I decided on for this build is an Arduino Uno R3. The "R3" is just simply "Reversion #3", the third version of the Uno board. The Uno board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. The Arduinos have open source libraries written in C programming language.

My plan is to integrate a 10kohm POT into the throttle peddle to supply a 0-5+ volt signal to the Arduino Uno. As the throttle peddle is pushed down the POT will turn from one pole towards the other and supply a voltage between 0 and 5v. The voltage will be read by the microcontroller and depending upon the programming that I write for it, it will output certain functions in direct correlation to the input from the POT. The Arduino will process the information at 16Mhz with the program information that I write. If I do it well enough I hope to add realistic engine sound that rev in correlation to the throttle in "neutral" mode and accelerates in correlation to speed when in "drive" mode. It will have a "starter" at the beginning that sounds like a starter is turning the engine over, a horn when a button is pressed and anything else I come up with between now and then to make it more realistic.

Along with engine sounds the Arduino will also control a servo motor that will control the "throttle linkage" to the carbs for a realistic effect and a small DC motor that will spin the belts and fan in relation to supposed engine RPM. There will also be LED's for the headlights, tail lights, blinkers and whatever else I can come up with if time permits.

I am going to either build or buy a separate circuit to store the engine noise snippets, DAC (Digital to Analog Converter), and amplifier to power the 6.5" speaker that will provide the "engine noise." The speaker will be in a custom ported box tuned to the lowest frequency that the engine sound will "produce". There will be two ports that start in the speaker box but will exit the box, turn and terminate at the back of the go kart, making them look like the exhaust pipes. I will include all of the information on the speaker box and math that I used to get the right air space, port diameter and length and tone, as well as provide the Thiele/Small parameters of the speaker and a small "How-to" section to help others if there are any that want to see it.

So basically I have started this thread in the hopes that others might have some experience with Arduinos and could help me with this part of the build. If there aren't any, I guess I will write this as a "How-to" or in a way that others can read through and learn from.

Well, that's it for now.
 

Attachments

  • 20170326_144541.jpg
    20170326_144541.jpg
    246.8 KB · Views: 7
  • 20170326_144624.jpg
    20170326_144624.jpg
    188.9 KB · Views: 5
  • 20170326_144744.jpg
    20170326_144744.jpg
    123.9 KB · Views: 3

ChromeRhino

New member
Messages
285
Reaction score
0
Location
Michigan
Ok, so I have my Arduino Uno but nothing else to go with it yet. My LED's, starter kit with servo, DC motor, 10 Kohm POT and everything is still in the mail. The "Arduino" that I ordered is actually a cheap knock-off version. Because it is a cheap knock-off version the communications chip is different than a real Arduino. It uses the CH340G chip which is not in most driver libraries so I had to go and download the ch340/341 driver, open Device Manager, go to the Driver list, take out the current driver that my operating system used for it, install the new driver, and go back to double check that the driver was installed correctly. I checked to make sure communication between my computer and the Arduino was working with a simple on-board LED flash program. It loaded and worked just like it was supposed to so now I am good to go.... as soon as the rest of my parts get here. lol

In the mean time I need to figure out the best way to get the best sounding exhaust and revving engine noise to be controlled by the POT, interpreted, then magical electrical stuff happens and then it sounds great to everyone within 50ft. :stir:

Really I have a few ways of accomplishing this. One way is to use the Arduino as a synthesizer in which it would output a very small voltage out of a digital or analog pin with different notes, tones and controlled patterns to make a noise. I don't like this way so I am not going into it any further.

The second way is to make or buy a shield that has a microSD card slot and reader on it, sync it up within the program code and pull the individual sounds off from is as needed. The sound is then outputted to an audio amplifier, it's amplified and the audio control voltage is sent to the speaker so that it plays the sound. I like this idea better but I need to figure out how fast I can get the individual files to play and stop and play a different file.

The third way is to buy a module that already has the engine noise on it and can do the sound effect the way I want. This way is more money and I would have to convert it to my application. I looked at this option first because doing this yourself is a giant PITA but most options either sounded like crap, wasn't exactly what I wanted or was too expensive.

Option #3 is to source a SN76477N Complex Sound Generator IC made by Texas Instruments, build a test board with an amplifier to the speaker with many different POTs hooked up to determine the correct pitch, tone, etc. Then build the circuit with the main determining values set with only the 10kohm POT remaining being the one for the throttle. I looked online and they are going for more than I can get the Adafruit Sound FX board for. Then I would still need to source all of the needed components, troubleshoot and build a test unit and finally try to fit it all on the prototyping area on the Uno without causing problems with the rest of the things and not picking up noise from the servo or dc motor drivers. Hmm.... a true DIY route but I think I will leave it as a back up option for now.

So, I think I will go with option #2. I was looking at the Adafruit Sound FX WAV/OGG trigger board with 16mb flash. If I use WAV files it can load and start playing the sound within 120 milliseconds. It has multiple triggers so I could just add a horn trigger button and I wouldn't have to even spend time programming in a search input pin or output pin in the coding, it could run completely separate which is a big plus. I am not sure if 16mb will be enough for what I want to do but it seems like it should be plenty. I will have to get ahold of the exact WAV file I am planning on using, cut it up to what I need, put it in one file and read how big the file is.

Adafruit had another fx board with a built in amplifier but they pulled them off from the marker because some of them were faulty. So I thought I might get a DROK Amplify Module Audio Component Amplifier that uses the TDA7​297 (TDA7297 15W+15W). I really only need one channel and since it is a 4 channel amp bridged to a two channel already I can't bridge it further into a single channel to get 30 watts of power. Maybe I will search my burned car audio amps for a good audio IC and build my own small amplifier. Grrrr... but that is so much more work and more headaches. I will look for a mono amp that is under $15, puts out 20w or more and has a nice clean sound.

Does anyone have enough knowledge to point me in the right direction or to give some advice? If so, please let me know.

---------- Post added at 11:57 PM ---------- Previous post was at 11:51 PM ----------

[EDIT] Duplicate Textblock Removed [/EDT -sid-]

---------- Post added 03-27-2017 at 12:34 AM ---------- Previous post was 03-26-2017 at 11:57 PM ----------

In order to make sure that the Arduino Uno and computer were communicating properly I wrote a simple program that you can find anywhere. It is a simple "Blink" program that turns the on board LED on and off for whatever length of time you want. You can download "Sketch" from Arduino which is a program that allows you to write a sketch (program) and it will verify it, look for obvious errors, convert into the 1 and 0 computer language and load it on to your Arduino. It also has libraries that you can load and use for your programs and some programs you can use. It is all open source so you can look in the Arduino Playground for sketches that fits your needs, download or copy it and use it for your needs.... for free! It is always best to give credit for the sketch to the person who wrote it and made it available for everyone. This LED sketch is the one that comes on the Arduino Sketch program and credit is given in the code.
Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino model, check
  the Technical Specs of your board  at [url]https://www.arduino.cc/en/Main/Products[/url]
  
  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
  
  modified 2 Sep 2016
  by Arturo Guadalupi
  
  modified 8 Sep 2016
  by Colby Newman
*/


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
That is a very basic sketch (program). You can change the amount of time that the LED stays on by changing the number within the "( )" after (LED_BUILTIN, HIGH); delay(here). The main way to turn something "ON" is to write the command "HIGH", and to turn it off you write "LOW". This "pulls" the PIN "up" (HIGH) and sends voltage through the built in resistor to the LED and turns the LED on. The number you write in will be the amount of milliseconds. There are 1,000 milliseconds in one second, so (1000) is one second, (500) would be a half a second, (2000) would be 2 seconds and so on. You can change the amount of time that the LED stays off by changing the (LED_BUILTIN, LOW); delay(amount here).

The "delay" function actually makes the processor stop everything that it is doing and waits for the amount of time to pass before carrying out the next task in he "loop" program and so I will not be using "delay" unless the function I need it for should stall the program purposely. But, all I needed was to make sure that the communication was working and that I could upload sketches properly so it was simple, quick and did not make a difference in this instance so I just used that one.

In the future I will use a time stamp and read type of function to keep time based commands on task so that the processor is free to continue through the code and do other functions while keeping track of the timed procedures elsewhere in the code (sketch). This will become more clear as the project unfolds and more of the sketch is written.

OK. Back for more when time permits. I look forward to your comments. :eek:)
 
Last edited by a moderator:

itsid

Moderator
Staff member
Messages
11,564
Reaction score
123
Location
Ruhrpott [Germany]
Hi;
what a wall of text ...

Frankly I skipped most of it myself,
but I imagine most of our members would do the same I'm afraid ;)

maybe you want to leave some of the less important/less interesting stuff out of this.
People that care know what an arduino is, and the others.. well don't care ;)
americans will NEVER pronounce it correctly.. and frankly that "pronounciation" you gave is misleading at least (wrong really)
it's more like "R - DO - E - NO" ;) (and yes, I mean the letter R, the word "do", the letter E and the word "no", that simple; that is if you don't have a nasty accent)

Anyways, that's a cool idea (sound module)
there are in fact ready made sound modules (to attach to your -say Prius- to have various engine sounds roarring like Ford or GMC v-8s Porsche Boxers, Mercedes V8s etc.)
expensive due to the sound engineering behind that.
it's rather difficult to sample prerecorded sounds in a rpm specific way accurately.

I've tried a somewhat related thing in the past (on a computer not my arduinos)
namely a simple "pop" sound tied and timed on eight different channels.. pairs slightly altered in frequency (exhaust manifold or something) and of spreaded apart to resemble the babbling of a V8
(IDK what timing I used.. I think it was Fords *shrugs*)
Anyways.. it WAS NOT convincing enough for me to proceed.
So I went and got some cups for a mechanical version of what I had in mind... (different story...)
but maybe you can get a better grip at that ;)

Prerecorded engine noise can be found on yt if you keep looking around (and IIRC there was a website for Free SoundFX that had some in the list [too long ago to remeber the url tbh] )

But then again, as a loop it's annoying and stitching different "rpms" together is not as trivial as it might seem
(that's why the car soundmodule is so **** expensive)

Sound: I wouldn't bother to make an amp and attach speakers TBH;
I'd pick up a JBL CHARGE2 which is splash proof (I use mine in the shower actually)
it's pretty loud (loud enough I'd say) has a good amount of bass (for the V8 brabble)
the battery seems to last forever,
and you can easily add a bluetooth module to an arduino too.. so maybe that's easier here
(more expensive though if you don't already have a good BT speaker for your phone ;))

'sid

PS I'll stop here to not add another wall of text :D
 
Last edited:

tinamcjittles

ello m8
Messages
391
Reaction score
0
Location
Allovau
No matter what you do that loop will be flippin' annoying as heck.. Honestly the fake engine noise and fake engine might ruin it if it's too much :/ Thanks Sid, less wall is better hahaha

Okay so if you did go the route of the looping audio, you'd take a really short sample and loop it through at just the right times so that it "wraps" into itself in a natural sounding fashion! This will make it easier to rev and decelerate the engine. You could take the value from the analogRead function, send it to an integer, then use that integer value to determine the delay time between loops (i.e. int I = analogRead(A0); A = I/4; then for the loop --> delay(A); )
https://www.sparkfun.com/products/11125
SparkFun makes these and you can load your audio sample onto the micro SD, then trigger the audio sample!

I wouldn't use the delay though, it completely stops your processor from doing anything (I know you know that) but instead use a millis() function :D

Or, since the arduino will be controlling many operations based on each read value from the pot at once you could go with a multiple core MCU like the P8X32A by parallax! Probably not worth learning a whole new language tho haha
 

karl

Well-known member
Messages
2,447
Reaction score
643
Location
North east Ohio
You could like attach a servo to the throttle flap of a straight piped briggs to make noise. Then conveniently attach a clutch and chain to the tires. Then the noise will go with the rpm.
 

ChromeRhino

New member
Messages
285
Reaction score
0
Location
Michigan
Hi;
what a wall of text ...

Frankly I skipped most of it myself,
but I imagine most of our members would do the same I'm afraid ;)

maybe you want to leave some of the less important/less interesting stuff out of this.
People that care know what an arduino is, and the others.. well don't care ;)
americans will NEVER pronounce it correctly.. and frankly that "pronounciation" you gave is misleading at least (wrong really)
it's more like "R - DO - E - NO" ;) (and yes, I mean the letter R, the word "do", the letter E and the word "no", that simple; that is if you don't have a nasty accent)

Anyways, that's a cool idea (sound module)
there are in fact ready made sound modules (to attach to your -say Prius- to have various engine sounds roarring like Ford or GMC v-8s Porsche Boxers, Mercedes V8s etc.)
expensive due to the sound engineering behind that.
it's rather difficult to sample prerecorded sounds in a rpm specific way accurately.

I've tried a somewhat related thing in the past (on a computer not my arduinos)
namely a simple "pop" sound tied and timed on eight different channels.. pairs slightly altered in frequency (exhaust manifold or something) and of spreaded apart to resemble the babbling of a V8
(IDK what timing I used.. I think it was Fords *shrugs*)
Anyways.. it WAS NOT convinving enough for me to proceed.
So I went and got some cups for a mechanical version of what I had in mind... (different story...)
but maybe you can get a better grip at that ;)

Prerecorded engine noise can be found on yt if you keep looking around (and IIRC there was a website for Free SoundFX that had some in the list [too long ago to remeber the url tbh] )

But then again, as a loop it's annoying and stitching different "rpms" together is not as trivial as it might seem
(that's why the car soundmodule is so **** expensive)

Sound: I wouldn't bother to make an amp and attach speakers TBH;
I'd pick up a JBL CHARGE2 which is splash proof (I use mine in the shower actually)
it's pretty loud (loud enough I'd say) has a good amount of bass (for the V8 brabble)
the battery seems to last forever,
and you can easily add a bluetooth module to an arduino too.. so maybe that's easier here
(more expensive though if you don't already have a good BT speaker for your phone ;))

'sid

PS I'll stop here to not add another wall of text :D

Thanks 'sid,

Yeah, I figured most would skip/skim most of it because it was either too much info and others because they already knew it. But I was bored, this project is going to be in the build competition and I figured that if anyone else wanted to attempt the same thing but had no knowledge of Arduinos or microcontrollers they might find the "wall of text" useful.

I was thinking of doing full idle loops at different rpm's and triggering each one as the POT voltage changes instead of doing a noise for each piston fire. The kart is not going to be very fast at all and so I will only need a smooth rpm range from idle to about 3,000 rpm. I plan on putting a little 36 -1 trigger wheel on the drive axle with a hall-effect sensor to gauge speed and determine engine rpm sound in "drive." I will have a shifter for "neutral" and "drive" mode to trigger the different modes within the sketch.

As far as the prerecorded engine sounds made for electric cars I got ahold of the place out of Australia and they want over $100. That's not in the budget. I was thinking about buying a DragFX that you plug into your cigarette lighter and it plays through your car speakers and hack it to work for me but it seems like that might be just as difficult as doing it myself. I know the sound stitching and buttering is a huge obstacle so we will see what happens.

The Bluetooth option and Bluetooth speaker idea is a good idea. I was wanting to make it pretty load and with good sound. I have made tons of speaker boxes and know that I could tune a small speaker and speaker box to sound just how I want it so I figured it would be one of the easier parts of the build for me. But if the Bluetooth speaker could output the amount of bass and volume I am looking for, that would make it a little bit easier. I was already thinking of adding BT so that I could have a remote kill switch and program a simple app for a security alarm and other silly things that would only take time to sketch it in. While I was waiting for parts I made a few Android apps to communicate with Arduinos, so that part is mostly taken care of, I just have to make sure the PINs are correspond to the Arduino when I get it all done.

There. Finally done with another wall of text for you. :lolgoku:

---------- Post added at 02:56 PM ---------- Previous post was at 02:46 PM ----------

You could like attach a servo to the throttle flap of a straight piped briggs to make noise. Then conveniently attach a clutch and chain to the tires. Then the noise will go with the rpm.

LOL Yeah, that would be a sure fire way of making engine noise. Not sure that I want my 2yo daughter driving it around, but it would take care of the noisy part for sure.

She has an extra Barbie Jeep that might find itself with a gasser in it this winter. :thumbsup:

---------- Post added at 03:28 PM ---------- Previous post was at 02:56 PM ----------

No matter what you do that loop will be flippin' annoying as heck.. Honestly the fake engine noise and fake engine might ruin it if it's too much :/ Thanks Sid, less wall is better hahaha

Okay so if you did go the route of the looping audio, you'd take a really short sample and loop it through at just the right times so that it "wraps" into itself in a natural sounding fashion! This will make it easier to rev and decelerate the engine. You could take the value from the analogRead function, send it to an integer, then use that integer value to determine the delay time between loops (i.e. int I = analogRead(A0); A = I/4; then for the loop --> delay(A); )
https://www.sparkfun.com/products/11125
SparkFun makes these and you can load your audio sample onto the micro SD, then trigger the audio sample!

I wouldn't use the delay though, it completely stops your processor from doing anything (I know you know that) but instead use a millis() function :D

Or, since the arduino will be controlling many operations based on each read value from the pot at once you could go with a multiple core MCU like the P8X32A by parallax! Probably not worth learning a whole new language tho haha

Thanks for your input. I agree that a droning loop would be annoying. If that's all that I end up being able to produce I will just deal with it not having sound and use the Uno for my dyno project instead.

As far as the sound loop and sketch goes that is pretty much exactly what I was thinking of doing. I am glad to see someone thinks that would be the best way to go... now all I have to do is implement the strategy. No biggie. :sarcasm:

I looked into the SparkFun module but it says that it has a funky "4-bit ADPCM @ 6-32kHz) so you’ll need to download the utility in the documents below in order to convert your .WAV files into the 4-bit ADPCM format required". It seems that if the file would need to be converted every time before it plays it would take too long to make a smooth transition of engine noise. I could be wrong but it takes an additional 40ms to pull .OGG, convert and play than it does to play .WAV files so I figure that it would take even longer to convert and play .ad4 then a module that plays .WAV directly.

Thanks for the Propeller info. I had found those a while back as something to really look into but I lost the page. They seem like a really nice option for tons of projects. I think the 16Mhz will be fast enough to keep up with the processes without being twitchy, but we will see. The main thing that I worry about is the amount of RAM and Flash memory not being enough. I guess I will have to just try and see.
 

pRoFiT

Can't buy it?, build it!
Messages
1,147
Reaction score
41
Location
California
like sid said i did not read all this only a little.

but you could get one of these (i have them and they are awesome for the car) http://www.soundracer.se/?p=98&p2=539 and then wire the electric engine to it. probably enough noise coming from the electric to imitate the RPM from a car. and then connect to amplifier with speakers! looks like soundracer X has cool functions. i have the cheaper V8 model.
 

ChromeRhino

New member
Messages
285
Reaction score
0
Location
Michigan
like sid said i did not read all this only a little.

but you could get one of these (i have them and they are awesome for the car) http://www.soundracer.se/?p=98&p2=539 and then wire the electric engine to it. probably enough noise coming from the electric to imitate the RPM from a car. and then connect to amplifier with speakers! looks like soundracer X has cool functions. i have the cheaper V8 model.

Yeah, that one is very similar to the dragfx. I might look into using one of those if I don't have to pay extra for an American hot rod v-8 sound. I would still need to use an IC chip or microcontroller to make it function properly but it might be worth the money if I don't have to deal with getting the sound just right.
 

LulaNord

New member
Messages
1
Reaction score
0
Hi...i am a new user here. I think so if you did go the route of the looping audio, you'd take a really short sample and loop it through at just the right times so that it "wraps" into itself in a natural sounding fashion! This will make it easier to rev and decelerate the engine. You could take the value from the analogRead function, send it to an integer, then use that integer value to determine the delay time between loops .

printed circuit board
 

ChromeRhino

New member
Messages
285
Reaction score
0
Location
Michigan
Hi...i am a new user here. I think so if you did go the route of the looping audio, you'd take a really short sample and loop it through at just the right times so that it "wraps" into itself in a natural sounding fashion! This will make it easier to rev and decelerate the engine. You could take the value from the analogRead function, send it to an integer, then use that integer value to determine the delay time between loops .

Thanks, LulaNord. And welcome to the forum!

I was originally thinking the same thing (I think, if I understand you correctly) but I then became concerned that the audio would become too choppy due to the time it would take to pull (play) each short burst of noise even with the digitalwrite(), micros time stamp and such to keep the timing accurate and without flaws. The lowest delay between a trigger event and the start of a .WAV file being played is ~80 millis, which isn't much time at all, but when you have many trigger events/audio play switches per second 8 don't know how it would sound. Have you havd experience with a rapid audio triggering/play situation similar to this before? I haven't found anyone who has tried to tackle a good engine sim/synth sound.

I was Thinking of going with a Ginsing complex waveform synthesis board that uses the Babblebot IC with the Ginsing Tweaker and Babbletron software or setting up a circuit using the Texas Instruments SN76477N to synthesize the sound but I don't want just a crappy, flat droning effect either.

I am really trying to determine the best approach because both ways will involve a ton of work and they are in different directions. I don't want to spend the time, effort and money going in one direction just to "learn the hard way" that I should have went in the other direction. You know what I mean?
 
Status
Not open for further replies.
Top