Help required, simulate variable diesel engine noise.

the old fart

Senior Member
Hi Guys,

This is a project for one of my model boats.

How can I replicate the sound of a diesel engine noise using an 08m2 picaxe.

It needs to vary with the speed on the boat electric motor.
the easy bit is reading via the serin command to detect the speed.

the hard bit, which I'm struggling with, is how to produce a realistic sound of a 9 cylinder diesel engine.

Regards

TOF
 

geoff07

Senior Member
I would start with a square wave at the frequency of your cylinder ignitions, so it would be rpm dependent. Then try some filtering to lose some of the higher harmonics. If you can find a recording of the silenced engine under power, and a spectrum analyser, that would be a guide to what harmonics to add or remove.
 

AllyCat

Senior Member
Hi,

I don't know what your Marine Diesel sounds like, but I guess the frequencies are quite low? So I foresee two (at least) issues. Firstly, the PICaxe has primarily only a single-channel "tone" generator, so it may be diffiult to generate a complex or "rich" sound. Secondly, what type of "loudspeaker" do you plan to use? Low frequencies generally require large loudspeakers and high drive powers. You may need to look at the construction methods used for "woofers" or even sub-woofers. It's generally necessary to move a large volume of air, so the loudspeakers often take the form of "long-throw" pistons. Furthermore, the "enclosure" (also known as an "infinite baffle") needs to be large, perhaps you can or need to use the whole hull of the boat?

But as far as the (PICaxe) synthesis of the sound is concerned, do you have a sound recording of a similar engine? You probably don't have a "spectrum analyser", but I believe that you do have a DP / PCB ("Santa") scope? That has a "FFT" (Frequency Spectrum) mode, which basically can derive the component frequencies from a complex (audio) waveform. I've not used the FFT mode myself, and you may need some trial and error to choose a suitable scan-time and waveform, but it might give a few clues. Note that some PICaxes have an on-chip "modulator" which may help to combine multiple signals.

My guess is that the "throb" (firing stroke) of the engine is quite slow, so could/would be done by a direct software control loop (for the signal amplitude). Then, one (or more) PWM channels might be set up to generate the fundamental tone(s) of the engine noise. What actually causes the "noise", is it vibrations of the engine block, air being "inhaled", resonances caused by the exhaust pulses, or perhaps the propeller?

Cheers, Alan.
 

the old fart

Senior Member
Thanks Alan,

I do have a Santa scope, so I'll experiment as you suggest.

There is a commercially avaliable unit, which uses the 8pin pic, but where's the fun of using ready made units.

Output is to a 3 1/2" 8 ohm speaker, driven by a 1 watt amplifier chip. speaker is mounted on a cutdown pringles tube. Sounds on my other boat came be heard 50yds away when sailing.

I have built a board, using a 20x2, that will playback 8 recorded sounds, using recordable sound chips (from china), but not a variable sound.
if anyone wants the circuit / program I'll upload it.

TOF
 

goom

Senior Member
Perhaps you could try a complex sound generator chip (search on eBay). I used one many years ago, and remember generating quite realistic sound of a propeller aircraft accelerating from idle to full power. These chip have various oscillators, mixers ad noise generators so can produce quite a range of different sounds. I am sure that a Picaxe based control would be possible, perhaps through digital potentiometers and/or analog voltage.
Alternatively, why not get hold of engine sounds at (say) 5 different powers, and play the appropriate one according to throttle position.
 

the old fart

Senior Member
I have this engine sound.

Code:
http://www.filefactory.com/file/6duy7v60g0c1/35499__bansemer__diesel-motor-on-fishing-boat.mp3
I've put it into the santa scope Frequency Spectrum, and get a waveform.

It means little to me...

see attached screen dump.
 

Attachments

AllyCat

Senior Member
Hi,

I've not attempted (yet) to listen to your sound file on my netbook's tinny speakers, but that's a rather better waveform than I might have expected. :)

I'm not sure about the first "double-peak", but it basically has (reducing) frequency components at 150, 450 and 750 Hz. That's the classic signature of a 150 Hz "square wave", so the normal (time) 'scope waveform should show a repetitive pattern at 150 Hz (but not necessarily with a "square" shape). Relative phase shifts can make the waveform look rather different, but they don't affect the apparent "sound" (that is the reason for using a FFT, which ignores phase differences).

Of course, that FFT is only from a "snapshot" of the overall waveform, so you may also need to look at other times and also at the overall "envelope" of the sound (for a period corresponding to a few revolutions of the engine). But it does look as if a 150 Hz square wave might be a good starting point (uless the recording was plastered with a third harmonic of the 50 Hz "mains hum").

Listening to the recordings linked by hippy, I'd forgotten about the traditional "clatter" of (older) diesel engines, but don't know how that would be best simulated. Also, those engines seemed to be operating almost without silencers; I guess much will depend on how the engine is configured and whether you are trying to emulate the sound of a "nearby" (clattering? ) or a "distant" (throbbing? ) engine. But I suspect that creating a good sound emulation in this case is probably as much an "art" as a "science".

Cheers, Alan.
 

AllyCat

Senior Member
Hi,

I've now had a chance to look at / listen to your soundfile on my desktop PC. A rather different sound to hippy's, not what I really expected from your scope FFT, but perhaps a sound that can be simulated with a PICaxe (and a little extra hardware).

Firstly, what I think I hear in the sound are fairly "pure" (sine wave) resonances probably of the exhasut system/silencer and then a slow "patter"/clatter/throb associated with the engine revolutions (or its firing strokes). I suspect that the latter may not show on the FFT (or a normal) scope display, but it might be emulated by amplitude modulation and/or pulses of "white noise" varying with the engine speed?

My DPscope FFTs are rather different to yours; I'm not certain that they're correct, but they do seem plausible. Initially, I was rather disconcerted that the scope produces FFT "waveforms" with NO input signal, but that seems to be a "noise" effect which disappears when a real signal is applied. In particular a few "clear" peaks become apparent at low frequencies (on the left), with little content above a few hundred Hz (on the right). An advantage of the FFT is that it can be "averaged" with the "Persistance" mode, not possible with the "normal" mode because of the lack of a reliable trigger (on a "test bed" one might take an external trigger from the crankshaft, for example).

The sound changes about halfway through the file, so I took two FFT screengrabs, the second is at lower rpm and some of the peaks are clearly at lower frequencies (i.e. towards the left). However, some of the frequencies (~170 and 230 Hz) do NOT change, which perhaps "confirms" a background resonance in the silencer/exhaust.

BoatFFT10-20sA.jpgBoatFFT35sA.jpg

Note that the frequencies do not have a simple integer relationship (i.e. they are not harmonics of a single "note") so you will likely need several oscillators and at least one low pass filter to remove the higher harmonics of the square waves that are produced by PIC(axe) PWM outputs. However, a "raw" PIC runs very much faster and might be able to synthesise these low frequency sine wave(s) directly, using D-A conversion.

Cheers, Alan.
 

PeteShep

Member
There was a PICAXE based unit on the Solent Radio Control Model Boat Club web site
http://srcmbc.org.uk/index.php
some time ago, under the section that is now Alans Electrics
http://srcmbc.org.uk/ht_afb_intro.php

Seems that now the designer sells the unit completed, rather than DIY.
There are three versions of the simple one, Steam, Petrol and Diesel, with videos (and sound) of the units in action.

All I can remember of the circuit was that one 08 took an input from the motor servo signal, and outputted a PWM signal to a resistor and Cap to give an analogue value, then a second 08 used the analogue voltage as an input and converted it into a varying frequency (and some other stuff) signal which was the engine noise signal. I think it used the "SOUND" function....

The two chip solution removed the asynchronous frequency problems between the servo signal and the engine revs.
 

bluejets

Senior Member

Attachments

the old fart

Senior Member
Gee, thanks ever so much Guys.

Lots for me to explore.


One question on the santa scope,

How do I interpretate the Frequency Spectrum

TOF
 

the old fart

Senior Member
I've managed to get waveform from a bought unit.

a diesel slow and a diesel fast. see attachment of waveforms.

looks like just a matter of squeezing square waves closer together for increased speed.


I'm experimenting with the pwmout on pins c.1 and c.2 of an 08m2.


lots of different noises, but not what I need.

guidance please.

TOF
 

Attachments

JimPerry

Senior Member
Just like a steam loco --- CHUFF ....... CHUFF slow CHUFF..CHUFF fast the trick is to turn the PW signals into something that sounds like a CHUFF :confused:
 

hippy

Technical Support
Staff member
There was a PICAXE based unit on the Solent Radio Control Model Boat Club web site
http://srcmbc.org.uk/index.php
The sounds Alan managed to achieve are quite impressive -

http://www.youtube.com/watch?v=SufFJyLrDrM
http://www.youtube.com/watch?v=pX3biLUAtkI
http://www.youtube.com/watch?v=M8SYbL4F7EM

Pages 6 and 7 of below provide details on how the original dual-PICAXE engine sound generator functioned. That used the SOUND command and it appears only one PICAXE generated the sound, the other read the R/C signal and determined which sound -

http://www.srcmbc.org.uk/pdf_files/News_Sep_08.pdf

From casually rummaging through Google it appears there may be some software source code here, but not sure what it relates to, and note that it is copyright -

http://www.srcmbc.org.uk/pdf_files/SPEED_DEMAND.pdf
http://www.srcmbc.org.uk/pdf_files/SOUND_GENERATION_(PETROL).pdf
http://www.srcmbc.org.uk/pdf_files/SOUND_GENERATION_(DIESEL).pdf
http://www.srcmbc.org.uk/pdf_files/SOUND_GENERATION_(STEAM).pdf
 

AllyCat

Senior Member
Hi OF,

Those waveforms just look like square waves at 6Hz + 25Hz and 16Hz + 64Hz. How are the two different components (red + blue traces) actually connected to the amplifier/speaker? I would not expect them to produce a "realistic" diesel sound. However, those waveforms could be easily created with a PICaxe, using something like: High pin1 : Pause 15 : Low pin1 : Pause 15 : High pin1 : Toggle pin2 : Pause 14 : .... etc. in a loop.

But I suspect that the complete waveforms are more complex. You may need to use a slower timebase and/or with NO trigger (i.e. "free running") and maybe in single-shot mode. Note that square waves like that might also be examined with the logic analyser mode (which can have a longer timebase).

The sound on the model "tug boat" video does seem good: what I hear/see is a constant frequency around 300 Hz (simulating a resonance in the exhasut system?) which is modulated by a lower frequency and/or pulses of noise. The new "mark2" version of the comercial unit does seem much more sophisticated, and reading between the lines I think it's using a "Class D" (switching mode) power amplifier, which is quite an innovative technique (although I did work with them 40+ years ago ;) .

How do I interpretate the Frequency Spectrum
First, perhaps I should mention that the "Frequency Spectrum" (FFT) display uses the same data as the normal 'scope trace, but presented in a different way. So it's important that the original "time domain" waveform is sensible, i.e. of sufficient amplitude but not clipped (i.e. past the top or bottom of the screen) and triggered (or not) as appropriate.

The "Frequency Spectrum" is basically a histogram of the frequencies which are present in the waveform, from zero (at the left-hand-side) with a linear scale up towards half the digital sampling rate (at or past the right-hand side). So a "peak" in the display indicates that the frequency is present (as a sine wave). Specific waveforms have a particular "signature", for example a 1 kHz pure sine wave appears as a single peak (or spike), but a 1kHz square wave has additional peaks of reducing amplitude at 3kHz, 5kHz etc. (i.e. "odd harmonics") and a "sawtooth" waveform has reducing spikes at all harmonics (i.e. 1kHz, 2kHz, 3kHz, 4kHz, etc).

There seemed to be some confusion about the "Feedback Shift Register" in the other thread, so I wondered about reviving it; would that be a better thread to discuss FSRs ? Often FSRs are used to produce "noise" (hiss/chuff) type sounds, but the PICaxe version in that thread is a rather unusual application of a FSR. To summarise, it simply produces different pulse trains, depending on the value initially loaded. There are three patterns which repeat every 3, 7 or 21 clock cycles, the 3 (and 7) will basically sound like simple tones, the 21 loop might sound rather more intermittent.

I see that hippy has now posted more, but I haven't examined all that yet

Cheers, Alan.
 

the old fart

Senior Member
Hi OF,

Those waveforms just look like square waves at 6Hz + 25Hz and 16Hz + 64Hz. How are the two different components (red + blue traces) actually connected to the amplifier/speaker? .


the two traces are taken from 2 output pins on the 08M2.

o/p pin5-----104 cap--------------resistor--------------------1uf elec cap =================sound amplifier.
o/p pin6-----104 cap--------------resistor------------------/

hope that explains it.



@Hippy, thanks for all those links, will be having a good read.

TOF
 

hippy

Technical Support
Staff member
There seemed to be some confusion about the "Feedback Shift Register" in the other thread, so I wondered about reviving it; would that be a better thread to discuss FSRs ?
Probably deserving of its own thread rather than burying it in something else - links to that older thread would probably satisfy 'for example...' references.
 

AllyCat

Senior Member
Hi,

hope that explains it.
Not entirely, is the 1uF in series (in which case it appears redundant) or as a low-pass filter (negative to ground) in which case the actual resistor values may be significant? I can't see how those waveforms might produce a "realistic" diesel effect, but perhaps the lower frequency signal drives the amplifier into saturation (overload) to act as a modulator?

Alan's original design in 2008 uses very little code and most of that appears to be concerned with (almost literally) "bells and whistles" rather than the diesel sound itself. The code from 2011 seems much more sophisticated and probably more has been done since, but now it has become a commercial product so the code is not published. However, it does appear from some of Alan's comments that the sound is still synthesised (i.e. the micro is not replaying a "recording"), but does it still use a PICaxe? I guess RevEd might know, as it appears that over 1,000 units of the commercial product have now been sold. ;)

If anybody still wants to use and understand the 2008 version of the software, then post in that thread and I'll try to explain the behaviour of the SFR.

Cheers, Alan.
 

the old fart

Senior Member
the 1uF in series (in which case it appears redundant
the 1 uF is in series, without it the sound doesn't work.

Alan posted some code on the Solent club pages, which I have downloaded but still to read.

I'll see if I can find the 2008 & 2011 threads.

TOF
 

geezer88

Senior Member
Playing with synthesizers over the years, I've been disappointed with the difficulty of getting something to sound "right".

Then I found samplers that run on a pc. You could record the real sound, and play it back at any pitch. Pretty much what you would expect as you rev up an engine.

Now, you don't want a pc strapped to your model, so I'd look for something a little more portable. One thing that comes to mind is the old Casio sampling keyboards my kids had. It was a small keyboard that would allow you to take a sample. Farts seemed to amuse the kids the most. Then depending on which key you pressed, it would come back a lower or higher pitch. Maybe you could find an old SK series Casio at a thrift store or auction. Then, record a real diesel, and wire outputs to as many keys as you want steps in rpm. The Casio would have the power amp and speaker, all ready to go.

tom (another old fart)
 
Last edited:

AllyCat

Senior Member
Hi TOF,

Re; #24: There are (!00 nF) capacitors on the other side of the resistors, so theoretically the electrolytic could be replaced by a short-circuit (a link). But perhaps the electrolytic is not completely redundant, there's a slight chance that the input impedance of any test gear (e.g. the DP Scope) attached to the resistors might otherwise slightly upset the input bias conditions of the amplifier. BTW, I noted this comment from Alan in the "discussion" comments following one of the youtube links:

"... you DON'T have to house this speaker cabinet in your boat - the hull and deck of your boat will more than likely create a far superior bass reflex cabinet for the recommended 75mm 10W 8 ohm loudspeaker."

Looking again at the dates of the software, I see that the original (simple) software was actually written in 2005 (but posted by manuka on this forum in a thread in 2011, #7 here) whilst the later software was written in 2008. So Alan has now had plenty more time to further refine and improve the software in the "commercial" version. And even in 2010 it appears that he had graduated to a 20X2 development platform to allow him to "tweak" the synthesiser parameters (using pots to ADC inputs).

Do you know if the waveforms in #17 come from a "recent" design by Alan (i.e. Technobots), or from somehere else?

Re: #26: I'm not sure where I saw the later software, but it was from one of thie links posted by others in this thread (I'll try to find it again). Certainly there are some excellent links in hippy's post #19. EDIT: Yes it is here. It's in a .PDF but can be cut-and-pasted into the PE.

Cheers, Alan.
 
Last edited:

the old fart

Senior Member
Thank you for the link.

The waveforms were taken from an 'Action' unit which I built for a fellow model maker.

The speaker is a 3" waterproof speaker, mounted in a cut down Pringles tube.
Amplifier is a tda7052, which is only 1 watt, but can be heard at 50 yards across the boating pond.

looks like I have enough to keep me experimenting for weeks.

TOF
 
Top