I want to encode a mono audio signal into a digital squarewave where the repitition frequency is the same as the instantaneous incoming audio, and the pulse width is proportional to the amplitude.
It's easy enough to clip the audio to get the right repitition frequency, but I'm not sure about the amplitude encoding. Something simple with 555s or similar would be great...
Ideas welcome.
Thanks
Mike
Didn't find your answer? Ask the community — no account required.
I'm not clear on your answer. To make sure you understand what I am ...
J
Jan Panteltje
On a sunny day (Thu, 4 Dec 2008 06:10:23 -0800 (PST)) it happened snipped-for-privacy@hotmail.com wrote in :
As Phil mentioned, that will not work. Because if you have a very low freuency, say 100 Hz zero crossing, the waveform will have smaller higher frequency amplitude components. Those need a higher sampling rate, so to speak, so you lose those high frequencies because your PWM repeat will be 100 Hz in that case.
Consider this waveform (fixed font):
. ------ . . . high frequency component . . . ------ zero . . zero
------------- pwm ___| |________
Was that your idea?
M
MooseFET
This almost works:
I assume that this is a one frequency at a time sort of thing. You already know how to make a square wave with a comparator.
(1) Sync rectify the input
(2) Filter the rectified to make smoothish voltage.
(3) Use a few more comparators to make a voltage dependent oneshot.
The pulse width and not the duty cycle is controlled by the signal amplitude.
M
MooseFET
requency component
You are assuming something about the OP's needs that I don't. I assumed that the signal was just one frequency at a time.
J
Jan Panteltje
On a sunny day (Thu, 4 Dec 2008 06:51:39 -0800 (PST)) it happened MooseFET wrote in :
He stated 'audio', both in the subject line and in the article body. So who is assuming ;-)?
O
oopere
This could be FM, if you mean that the repetition frequency is proportional to the instantaneous value of the audio signal...
This could be PWM...
So, you want _simultaneous_ FM and PWM? Why?
It seems your question needs some further clarification.
Pere
M
mdeblis
Good question. The resultant FM & PWM pulse train will be used to gate a high frequency pulse train, probably in the order of 400kHz. I want a recognisable form of the original audio, very much NOT hi-fi but recognisable none-the-less, to be recoverable from the final, gated, high-frequency pulse train.
My bad - I should have been more explicit - part of the issue is that I wasn't too sure of the final requirement myself.
many thanks for all your comments so far - very helpful.
Assuming now that I'm after FM & PWM, and I'm not worried too much about nyquist or hi-fidelity, can anyone recommend a simple approach using say a PWM controller like the TL494 or whatever?
Cheers
B
BobG
You can sort of understand the output of audio fed into a zero referenced comparator... sort of a 1 bit digitizer that roughly follows the zero crossings, so it has a lot of fundamental in it.
D
Doug B.
If you can live with a course-grained view of your audio how about feeding it into a network of comparators similar to the level meter here?
formatting link
er.gif.
Hook each output to a resistor in a voltage divider network and use the resulting voltage to control the PWM function of a 555. See here
formatting link
for an idea.
doug
R
Rich Grise
Boy! You've sure accumulated a bunch of crap anwsers! Ignore them. Send the audio to a zero-crossing detector, and log the time interval between zero crossings.
Send the resulting data stream to any ol' buffer, and it will sound surprisingly accurate, but with a lot of high frequency artifacts, which should be fairly easy to filter out.
Back before the days of sound cards, I heard a herald trumpet fanfare on my computer's own speaker on some vendor's ad CD.
Good Luck! Rich
J
Jamie
SWP/VSM Space width modulation/Variable Space Modulation.
A known trick used in simply things like RC control toys.. some types of remotes etc.
Pulse rate is detected at the receiver to select a channel of control while the duty cycle (width) is used for proportional control of that channel.
for basic application of, use a PIC/AVR or what ever to sample a complete transition onto the start of the next. Sample the time window as the frequency and the duty cycle as the proportional scale.
Have a good day! :)
http://webpages.charter.net/jamie_5"
M
miso
e
nd
y,
5s
d
I think Eeyore had the right answer. You only get one frequency with this scheme.
Probably the PC trumpet sound you heard was done via PWM. The early voice synthesis chips used this technique.
M
mdeblis
d
Thanks for the help. It's appreciated - I'll try this approach and see what happens. Not being an EE, it's sometimes tricky knowing where to start. I'm happier with s/w than h/w...
I've got an AVR in the circuit - I'l also try digitising the stream with a free-running ADC (8 bits would be fine), using the zero crossing to determine the pulse interval, and take the peak amplitude in the interval to determine the pulse length. Though this is crude, it should give me roughly what I need. I could always perform a faily short FFT (say 1024 bit) on the input stream, extract the fundamental/ peak energy frequency and its power, and use that, though in this instance it may be overkill...
Many thanks
J
Jasen Betts
suppose your audio cosists of a 1Khz sine wave as 0.5V superimposed with a 3.141 khz sine wave at 0.321v
Demented ravings of a congenitally autistic, narcissistic freakoid is what it really is.
DO NOT ANSWER THIS TROLL !!
.... Phil
M
mdeblis
You have a good point - I didn't express myself well, and didn't explain the issue properly. I'm hoping that the source with be monophonic, and the various approaches suggested so far have helped me clarify what I need to do. If the source ends up being polyphonic, or the simplistic approaches end up being unsuitable, then I'll move to the FFT one I mentioned elsewhere - I've used that before so already have workable code in GCC...
Thanks for your comment,,,
F
Frank Buss
I think an ADC might be a good idea, some microcontrollers have them integrated, too, so you don't need much external components at all. But a FFT needs quite some processor power, so might be difficult with an AVR. If you need just detect some known frequencies, you can try this algorithm:
formatting link
You can adjust a bit the bandwidth by selecting the right window function. I've used this with a DSP for analyzing sine signals for multiple channels in parallel at 48 kHz and works nice.
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
B
Bob Masta
To get a voltage proportional to amplitude without filtering (which would have time-constant-vs-ripple issues), you could feed the input into both a zero-crossing detector (comparator) and into an op-amp integrator. When the comparator output goes low, it fires a one-shot that samples the integrator. This is just a CMOS switch (CD4016 section) that is closed briefly to charge a cap, whose voltage is monitored by an op-amp buffer. When the one-shot is done, the integrator cap is shorted by another
4016 section for the rest of the half-cycle.
The result if all this is that the buffer output will have a voltage proportional to the integrated amplitude of half the incoming wave. It will hold at that value until completion of the same half-cycle of the following wave cycle, and then it will step crisply to the new voltage.
If you had a fixed-frequency input, then you could just use this voltage to set the duration of a one-shot. But it sounds like what you really want is to control the duty cycle of the output for varying input frequencies (PWM). This would probably be best done with some sort of dual-slope approach, the details of which I haven't worked out yet.
Best regards,
Bob Masta DAQARTA v4.51 Data AcQuisition And Real-Time Analysis
formatting link
Scope, Spectrum, Spectrogram, Sound Level Meter FREE Signal Generator Science with your sound card!
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.