PWM serial audio transmission

100 views
Skip to first unread message

hans

unread,
Feb 23, 2022, 2:53:32 AM2/23/22
to jallib
Hello everyone,
I have been trying for a long time to place a serial signal on one track of an audio recording which I can read afterwards. To make all kinds of things happen at the same time as the audio is played. I have now tried to do this with the old modem system ( TCM3105) but it failed hopelessly. I read that there are also systems to do this using PWM. Does anyone have an idea?
regards
Hans

Oliver Seitz

unread,
Feb 23, 2022, 3:58:53 AM2/23/22
to jal...@googlegroups.com
Hi Hans,

20 years ago I would have suggested using DTMF, but the decoder chips are rare these days...

PIC controllers include various peripherals which can be used to encode and decode DC-free signals (which, apart from the frequency below, say, 10kHz, is the requirement to be recorded as audio). On/off keying or frequency shift keying are the easiest, I think. Which chips are you going to use?

Greets,
Kiste

Am Mittwoch, 23. Februar 2022, 09:15:43 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/773ca37b-9bed-4349-a8eb-32a5d8973df6n%40googlegroups.com.

Rob CJ

unread,
Feb 23, 2022, 1:30:37 PM2/23/22
to jal...@googlegroups.com
Hi Hans, Kiste,

You can still by DTMF decoders and I assume also DTMF encoders. Just look at for example Aliexpress and type DTMF.

But another suggestion. Many, many years ago I had built an Apple II and  I used cassette tapes to store and load games which was using tones generated by the Apple II itself using two tones, one for high, one for low and one as a lead-in tone (not sure in the lead-in tone was another tone) to synchronze the start of the recorded program. You would not need this lead-in tone in your case

So I think it may not be that complex:
-) For recording on casette, generate this dual tone by the PIC  via PWM or maybe it is also sufficient to generate one tone in case of a 1 and no tone in case of a 0 but I think this will be less reliable.
-) For playback, measure the length of the recorded PWM tone. If is is within a certain range you accept it as a one and in case of two tones the lower tone could be zero and the higher tone is one. 

As long as the tone frequency is not too high, I think this could work.

A more advanced solution would be to use a phase locked loop (PLL) but I am not sure if it will work. The PLL locks to the input signal so the voltage that controls the oscillator goes up and down to follow (lock on to) the input signal and this oscillator voltage signal could then be used by a comparator of the PIC to detect a high or low tone. You can also use the oscillator of the IC to generate the two tones by controlling the oscillator voltage by the PIC. A typical IC for that is the HEF4046. I have used this IC many many years ago too. This solution may be bit over the top since you only want a kind of trigger signal

But maybe the first solution is more doable.  Just give it a try.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: woensdag 23 februari 2022 09:58
Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: Re: [jallib] PWM serial audio transmission
 

hans

unread,
Feb 24, 2022, 10:55:46 AM2/24/22
to jallib
Hey ,
I have tried a circuit with an MT8880 but the ICI has failed. I did hear the 16 tones, but when I wanted to receive them, the chip gave up the ghost.
In theory I understand your suggestions well, but developing something like this is not easy for me. I'm just a LEGO builder.
regards
Hans

Op woensdag 23 februari 2022 om 19:30:37 UTC+1 schreef rob...@hotmail.com:

hans

unread,
Feb 24, 2022, 11:07:17 AM2/24/22
to jallib
Another piece of text:
So far I've done everything with MIDI. I used one midi channel for the actions with a general command type. Then 2 data, one for the device nr (16) and one for the command. (0-128)
This has worked well for years, but it does require a complete MIDI sound package.

Op donderdag 24 februari 2022 om 16:55:46 UTC+1 schreef hans:

Rob CJ

unread,
Feb 24, 2022, 1:56:08 PM2/24/22
to jal...@googlegroups.com
Hi Hans,

If I understand you right the only thing you want to do is to record a signal or a sequence of signals on a casette player  that can be used to trigger something when the recording is played back right?

If my initial suggestion would work - which may work since I have the idea that my Apple II did more ore less the same thing - I could give it a try to do a proof of concept. 

I may have a the problem that I do not have a casette recorder but I could fake it by just connecting two PICs to see if that works. The final test could then be done by you.

Which PIC type are you using?

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens hans <hansvanve...@gmail.com>
Verzonden: donderdag 24 februari 2022 17:07
Aan: jallib <jal...@googlegroups.com>

Oliver Seitz

unread,
Feb 24, 2022, 3:38:36 PM2/24/22
to jal...@googlegroups.com
Hi Rob,

connecting two PICs is not like an audio recording. Better connect the pic to your soundcard to record and then playback, that way you'll get something similar to a tape recorder.

The difficulties when using audio equipment are (at least):

- only alternating current is transmitted
- the volume is never exactly the same
- the frequency range is limited to like 100Hz-10kHz
- the line level voltage is less than 1V

 Reading should be possible by most PICs which have comparators. Only a resistor is needed, then you can detect zero crossings. 

The Sinclair ZX81 used audio equipment as storage. A burst of three oscillations coded a zero, five coded a one. The output was low-pass filtered. You usually had to try loading a program several times, slightly adjusting the volume, until you got lucky.

Greets,
Kiste

Am Donnerstag, 24. Februar 2022, 19:56:01 MEZ hat Rob CJ <rob...@hotmail.com> Folgendes geschrieben:


hans

unread,
Feb 24, 2022, 3:46:30 PM2/24/22
to jallib
Hi Rob an Kiste,
I'm glad you want to help me. To be clear, except that my aging body is also slowing down, the gray knit from above is not so easy anymore. Besides the little ones I still have the 16F15325, 18F4455, 18F4550 and 18F4520.
Attached is the program I had made for the DTMF of which the MT8880 was killed for info.
regards
Hans

Op donderdag 24 februari 2022 om 21:38:36 UTC+1 schreef Kiste:
DTMF_6.jal

Rob CJ

unread,
Feb 24, 2022, 4:25:17 PM2/24/22
to jallib
Hi Hans,

I wrote a transmitter and receiver program for the PIC12F615 since for the transmitter is has a hardware PWM output. For the receiver I use timer 1.

The code is quite simpel and only took about an hour to write but I need to finetune it (and maybe it does not work at all ....).

It of course takes time to measure and so detect the signal. What is the maximum allowable delay after a signal is played back and the actual trigger?

It is only one tone that I need to detect, right?

Thanks.

Kind regards,

Rob


Verzonden: donderdag 24 februari 2022 21:46

vsurducan

unread,
Feb 25, 2022, 12:58:52 AM2/25/22
to jal...@googlegroups.com
Kiste, not only the ZX81 but Sinclair Spectrum and most of it's clones did the same.
The biggest problem was the tape speed variation (among the volume variation which was corrected in romanian clones -and we had more than any, I recall 5 different types).

Hans, on the actual PIC18 series on which JAL works ( presuming you will do with JAL) you might have some sampling speed issues. You need at least 7.5us for an ADC sample and according to Nyquist theorem you need not 2x ( which is pure theoretical) but at least 4x faster sampling than maximum frequency you are recording.
After your AD is sampled, the PWM is not an issue, but you might experience a small delay between real recorded speech and the PWM filtered one.
If you plan to add voice for your puppet, then limiting to 4KHz may be a good choice.

best wishes,
hopefully not WW III, but in pace for playing nice...

hans

unread,
Feb 25, 2022, 3:16:48 AM2/25/22
to jallib
Hi Vasiele and others.
I was born before the last world war and I suspect most of you after it.
 I hope it stays that way!!
Great, I can study today again. Thank you.

Op vrijdag 25 februari 2022 om 06:58:52 UTC+1 schreef vasile:

hans

unread,
Feb 25, 2022, 3:52:57 AM2/25/22
to jallib
Hi Rob, I usually always use the classic Serial method so I think two tones are needed. The time between the commands is not short because they are handcrafted.

Op vrijdag 25 februari 2022 om 09:16:48 UTC+1 schreef hans:

vsurducan

unread,
Feb 25, 2022, 7:34:14 AM2/25/22
to jal...@googlegroups.com
Hi Hans. Congratulations for your young mind! There aren't many people programming at your age.
You are a great example!

Message has been deleted

hans

unread,
Feb 25, 2022, 10:20:56 AM2/25/22
to jallib

Hi Vasile, 

In my time a birth was still followed by a placenta, nowadays an iphone comes after.

A long time ago I was infected by Wouter, Jal is even more persistent than corona, see http://www.voti.nl/setalk/n_index.html

 

regards Hans


Op vrijdag 25 februari 2022 om 13:34:14 UTC+1 schreef vasile:

Rob CJ

unread,
Feb 25, 2022, 12:58:11 PM2/25/22
to jal...@googlegroups.com
Hi Kiste,

The reason that I think it still might work is because - what I mentioned previously - is that my Apple II I had built in the past also just worked with tones to store data (at that time only games 🙂).

I copied a pice of the casette interface of the Apple II schematic diagram I found on the internet. What you see is that with an opamp the audio is input signal is converted to a digital signal and the rest of the processing is done in software. There is no special chip on the board to process this data stream.

Also the data out is just a direct output of a flip-flop with some resistors to reduce the signal outpt but not even a low pass filter.

The variations in cassette speed will result in a variation of the tone so if I use a tone range to detect the right tone it might work.

Kind regards,

Rob




Verzonden: vrijdag 25 februari 2022 16:20

vsurducan

unread,
Feb 26, 2022, 1:41:46 AM2/26/22
to jal...@googlegroups.com
Rob, obviously will work. :) But it would be weird to use a bunch of external analog electronics.
BTW, with a PIC you can do a class D amplifier...  what perhaps Hans wanted is not far away: sampling and then digitizing via PWM.
Other choices are possible as well.  Success on any variant you'll choose!

hans

unread,
Feb 26, 2022, 2:40:03 AM2/26/22
to jallib
Hey,
I get the impression that my question has not come across properly. I will use a regular stereo audio signal. One track contains music, speech and other normal sounds. The other track I want to use to record commands with which I can move servos, lights, etc. At first I thought to do this with DTMF but the MT8880 has died. Then I fiddled with the TCM3105, an old-fashioned modem chip, but that didn't work either. I then read something about PW application and hence my question.
I've been messing around with PICs for a long time, but because I'm purely mechanical by nature, I have to limit myself to what I called LEGO work. You make the stones and I make grateful use of them.
regards
Hans

Op zaterdag 26 februari 2022 om 07:41:46 UTC+1 schreef vasile:

Oliver Seitz

unread,
Feb 26, 2022, 3:21:27 AM2/26/22
to jal...@googlegroups.com
Hi Rob,

for a change, this time I didn't say it wouldn't work ;-)

Thanks for the scematics. The input stage is a Schmitt trigger with hysteresis. Did you notice that the op-amp is powered by +/- 5V? Today, noone would use symmetric power for only such an input stage.

Unfortunately, none of Hans' controllers has a data signal modulator (DSM) as peripheral, it would very easily do a two-tone-encoding (I called that "frequency shift keying") in pure hardware directly from the USART. It could also produce one-tone-encoding (which I called "on-off-keying").

But, what the 16F15325 has are comparators with hyseresis (max. 0,035V), FVR and DAC (which can supply a reference voltage of, say, 0,13V). So, almost the whole input stage of that schematics is already built-in.

Using that input circuitry, you could even try baseband transmission, that is no carrier frequency at all, just connect the USART output (attenuated and filtered) to the audio input, select a resonable baud rate (1200?) and specially crafted data. For example, a lead-in string like "UUUUUUUUUU" will charge all high pass filters to the middle point. If you then send a byte, and the inverse of that byte, you're still DC-free. Like now send 255, then 0 to make sure the RX module will catch the start bit, and then send repeatedly a certain code (different from "U") and the inverse of that code, like 10 times. On the receiving side, only act if you read three times a valid code within a short period.

The 16F15325 also has four configurable logic cells (CLC). They are a bit complex to configure, but I presume they can, combined with one or two PWMs, act as a hardware decoder for many carrier frequency signals. 

You can, of course, detect tones in software, even sampled by the ADC, but that's a lot of computation and hard to do "in the background". Your Apple II probably couldn't do anything else while loading from cassette. The ZX81 couldn't even keep text visible on the screen. 

Neither Comparator nor CLC have internal connection to USART RX, but modern chips have peripheral pin select (PPS). So you can set the output of a comparator or of a CLC to an unused pin, and configure that very pin as the USART RX input. 

For the filtering: The Apple II used cassettes as digital medium. Here, it's a mixed analog/digital medium. Magnetic recordings, especially on narrow tapes, suffer from crosstalk. If you listen carefully, you will hear the digital signals on the audio track. You would prefer that tone not to be too much rectangular.


If I had to do it today, I would ask the artist if using magnetic tape was integral part of the artwork. If it wasn't, I would use a raspberry pi as audio player, which is at least in the same price region as a cassette player, and can easily transmit the playing time via USART. 

Greets,
Kiste

Am Freitag, 25. Februar 2022, 18:58:13 MEZ hat Rob CJ <rob...@hotmail.com> Folgendes geschrieben:


Oliver Seitz

unread,
Feb 26, 2022, 3:34:33 AM2/26/22
to jal...@googlegroups.com
Hi Hans,

that's about what I thought. I'm quite sure it can be done with a pic, one or two capacitors and three to five resistors (or two resistors and potentiometers). I'm just not sure yet what the best way would be.

To keep things simple, you would probably want to build a transmitter with manual controls, and a receiver which controls the actual "show". That way, you can connect both modules to the tape recorder, and really see what the output does from tape, while recording the show.

Greets,
Kiste

Am Samstag, 26. Februar 2022, 09:04:29 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


hans

unread,
Feb 26, 2022, 5:37:18 AM2/26/22
to jallib
Hi, I'm using a 16f1827 with 8 ADC inputs that transmits the position of the elements with the help of a potentiometer via the uart and performs the movements. The audio track is recorded first and plays normally. At the same time, the control signals on the other track are sent via the ???????????? included. Afterwards I combine both tracks into a stereo signal, moving the playback position of the signals forward a bit to compensate for my reaction slowness. When played afterwards, the normal audio track goes to the amplifier and the other track to the ??????????? which then performs the movements.

Op zaterdag 26 februari 2022 om 09:34:33 UTC+1 schreef Kiste:

Oliver Seitz

unread,
Feb 26, 2022, 6:01:50 AM2/26/22
to jal...@googlegroups.com
Ok, that is at least 80 bits, with, say ten updates a second, makes almost one kbit per second. That is doable, but a very different requirement than triggering the projector on a slide show with commentary.

For everyone thinking about different techniques: Tape has dropouts. That's not too bad, as the final output is mostly not-so-fast mechanics. If  a data packet is missed, it will be corrected soon in the next packet. But, with such a constant data stream, syncing and re-syncing is needed. Pure data will not do the job, a proocol with sync and error detection is needed.

Greets,
Kiste

Am Samstag, 26. Februar 2022, 11:43:31 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


Rob CJ

unread,
Feb 26, 2022, 6:02:49 AM2/26/22
to jal...@googlegroups.com
Hi Hans,

I tested my proof of concept. I also attached the programs I used. In the given  video you see the results.

This is how it works and what the video shows:
  • The PIC on the left is the transmitter. It uses two inputs (via the wires that I connect to VCC or GND). One input enables the transmitter (orange wire), that is it starts sending a tone. With the second input (green wire) I can switch between a low tone and a high tone. 
  • The PWM output of the transmitter (PIC on the left) is connected to the timer/counter input of timer 1 of the receiver PIC (PIC on the right).
  • The PIC on the right resets timer 1 then it starts a measurement for 100 ms after which it stops the measurement. Then it checks the value of timer 1 (which in fact counts the number of 'ticks' generated by the PWM frequency on its input) within a certain range. If this range is within the range of the low frequency, it will light up the yellow LED. If this range is within the range of the high frequence it will light up the green LED. If the counter value is outside these ranges (e.g. when there is no signal) both LEDs will be off.
I am not sure if this is what you are looking for. I do not know if it also works if you would record the transmitted signal to a casette tape.

For more information on JAL, visit: http://justanotherlanguage.org/


Kind regards,

Rob

Verzonden: zaterdag 26 februari 2022 11:37
12f615_signal_receiver.jal
12f615_signal_transmitter.jal

hans

unread,
Feb 26, 2022, 9:30:00 AM2/26/22
to jallib
Here I am again. I don't use a cassette deck. After I have finished the audio/command files I just put them in MP3 on the well-known player.
Wow, now trying Rob's test, but it will take me some time. Anyway fantastic again!!
regards
Hans

Op zaterdag 26 februari 2022 om 12:02:49 UTC+1 schreef rob...@hotmail.com:

Oliver Seitz

unread,
Feb 26, 2022, 9:43:26 AM2/26/22
to jal...@googlegroups.com
Oh... MP3 is terrible for digital data. If you can't use wav or another lossless format, make sure to use the highest possible bitrate. Also, that's another point not to record square waves, sine waves go through mp3 far better.

However, crosstalk is less of a problem then :-)

Greets,
Kiste

Am Samstag, 26. Februar 2022, 15:30:03 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


hans

unread,
Feb 26, 2022, 10:39:17 AM2/26/22
to jallib
Hi,
I can try it right? Otherwise I can also take another player that can handle WAV.
Unfortunately I only have some 12F683 lying around, the 12f615  which Rob used I do not know..
regards
hans

Op zaterdag 26 februari 2022 om 15:43:26 UTC+1 schreef Kiste:

Oliver Seitz

unread,
Feb 26, 2022, 11:22:57 AM2/26/22
to jal...@googlegroups.com
Hi Hans,

of course you can try, and it will work up to a certain speed.

The 12F683 should work quite the same, but the oscillator speed setting is different. So you would have to...

- include the correct device file.
- comment out the line "pragma target IOSCFS   F8MHZ ..."
- add a line "OSCCON_IRCF=0b111"

Then, the input of Timer1 needs a voltage that goes higher than 2/3 of the supply voltage. With audio equipment, you'll need a speaker output to reach such levels. Use a resistor (about 1k to 10k) between (+) of the speaker output and the chip's input pin. (-) of the speaker output must be connected to GND of the PIC. Be careful *NOT* to power the amplifier and the PIC from the same power supply device! The amplifier must be linear, a class-D amp will not work.

Greets,
Kiste


Am Samstag, 26. Februar 2022, 16:39:20 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


hans

unread,
Feb 26, 2022, 1:32:07 PM2/26/22
to jallib
Hi Kiste, Rob,
I did en compiled the programs. Now`the next days ( inspite of carnaval) at work hans. Great

Op zaterdag 26 februari 2022 om 17:22:57 UTC+1 schreef Kiste:

Oliver Seitz

unread,
Feb 27, 2022, 2:45:40 AM2/27/22
to jal...@googlegroups.com
Hi Hans,

sorry for chiming in again with another warning: Rob called the set of programs a "proof of concept", that is, it is not fit yet for your original idea. The design of the receiving program is *guaranteed*not*to*work* at a speed faster than 5 baud. I'd estimate, you could have serial data at 1 or 2 baud. That is five to ten seconds for one byte.

Good thing is: You don't have to worry about mp3 at such a speed. The compression will not interfere with data sent that slow.

Greets,
Kiste

Am Samstag, 26. Februar 2022, 19:32:09 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


hans

unread,
Feb 27, 2022, 4:43:03 AM2/27/22
to jallib
HI Kiste
Unfortunately that is way too slow. I need to send and read a set of at least 9 bytes with an interval of no more than 3 seconds.

regards
Hans

Op zondag 27 februari 2022 om 08:45:40 UTC+1 schreef Kiste:

Oliver Seitz

unread,
Feb 27, 2022, 5:15:32 AM2/27/22
to jal...@googlegroups.com
Sure, it is a proof-of-concept, not a product. I'm quite sure that 100, maybe 500 bytes per second are possible, but the firmware needs to use a diferent approach. 

This list is about libraries, and what you need is not easily or efficiently realised as a library, it's a project. I have some ideas how the coding and decoding could be done efficiently, but I presume I wouldn't use any library for that at all. So it wouldn't even make a good example for jallib ;-)

Let me think a bit about designing the 8 pin encoder and decoder...

Greets,
Kiste

Am Sonntag, 27. Februar 2022, 10:43:06 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


Rob CJ

unread,
Feb 27, 2022, 7:22:35 AM2/27/22
to jal...@googlegroups.com
Hi Hans, Kiste,

The POC (proof of concept) was just to create a trigger signal based on an audio tone. It was not meant as a way to store data with a certain bitrate.

As I mentioned earlier, it measures the tone for 100 ms to determine if the tone is there (in my example I detect two different tones but that was just to see if that worked too) so the delay between the recording and the actual trigger (the detection of the tone) is at least (and more or less at most) 100 ms.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: zondag 27 februari 2022 11:16

hans

unread,
Mar 16, 2022, 4:33:41 AM3/16/22
to jallib
Hi Rob, Kiste
For now I'll stick with the old MIDI approach. I really hope there will be another audio option because with midi I can combine all kinds of music with actions but no speech.
regards
Hans

Op zondag 27 februari 2022 om 13:22:35 UTC+1 schreef rob...@hotmail.com:

Rob CJ

unread,
Mar 16, 2022, 2:09:43 PM3/16/22
to jal...@googlegroups.com
Hi Hans,

Did I understand it right that it did work with DTMF tones and that you used a DTMF decoder?


I still have a fixed telephone line next to my mobile number and I was thinking of using such a device to get rid of these fake call centers that call 'from Windows'  to tell me that I have problems with my computer. I thought that if I receive a number from abroad I could detect that with DTMF and pick up the phone and keep the line busy (or hang up). But I never started working on such a project but I did look for DTMF decoders.

And if I would have purchased it, I could have made a JAL library out of it .... but no plans for now.  So as we say in Dutch "I am making you happy with a dead sparrow"

Kind regards,

Rob


Verzonden: woensdag 16 maart 2022 09:33

hans

unread,
Mar 17, 2022, 2:13:36 AM3/17/22
to jallib

Hi all,

I tried the MT8870 a few years ago. I need to send data packets of 4 bytes, a start byte, a device byte and a high and low nibble. I used tone 15 as start byte, the second tone as device byte (0-15) 15 then two tones for the nibbles. That worked well but a DTMF tone should be 40 ms with a 20 ms delay.!!!!!

If I compare that with the baud rate of MIDI (31250) which I use so far, then DTMF is much too slow.

I then tried the TCM3105. Worked well but they are no longer made. A handful I've had from China were all broken.

So… I'll keep controlling my puppets on MIDI for the time being and if spoken text is needed I'll control the MP3 player

. I still hope one of you comes up with something different.

Rregards

Hans


Op woensdag 16 maart 2022 om 19:09:43 UTC+1 schreef rob...@hotmail.com:

vsurducan

unread,
Mar 17, 2022, 9:07:42 AM3/17/22
to jal...@googlegroups.com
Rochester Electronics offers obsolete parts, however TCM3105 has an exorbitant price...:) If you sell your puppets, it might still be ok...an MP3 player with card is still less expensive.
Best wishes,

Rob CJ

unread,
Mar 17, 2022, 2:23:05 PM3/17/22
to jal...@googlegroups.com
Hi Hans,

Maybe you should give my first suggestion a try. What you have been using with the modem IC was frequency shift keying (FSK), which was the same that I did with the PIC by generating a different frequency when a 0 or 1 is transmitted.

So for decoding you can use the very inexpensive HEF4046 or 74HC4046 (costs less than 1 Euro). I found an application note where they use this for FSK Demodulation and Modulation. I do not know how fast it will respond to in frequency changes but my assumption is that it may be fast enough for your application. The IC does not need many external components.

As I mentiond earlier, you can use the input voltage of the VCO of this IC on a comparator of the PIC to determine if a 0 or 1 is received. 

What this Phase Locked Loop IC does is that tries to lock onto the input signal by in increasing or decreasing its osciliator frequency. This increase or decrease is done by raising or lowering the VCO input signal (VCO stands for Voltage Controlled Oscillator). So by looking at the level of this VCO input signal you can determine if a 0 or 1 is received.

In the attached application note you also see that when the input signal raises in frequency that the VCO input voltage goes up to follow that higher input frequency.

You could still use the PIC for generating the FSK signal and use this IC for the demodulation of that signal.

The frequency used in this application note it quite high but you can change that by using other values for the VCO by using a different capacitor. I also attached the datasheet of a HEF4046 so that you can see for which values which frequency is generated also known as center frequency.

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens vsurducan <vsur...@gmail.com>
Verzonden: donderdag 17 maart 2022 14:07
slaa618.pdf
HEF4046B.pdf

hans

unread,
Mar 18, 2022, 3:29:50 AM3/18/22
to jallib
Hi Rob,
I have some    HEF4046's  .( remaining stock from a friend who died too early)  So i have to start study our advice. The more advices the better !!
Thanks, Hans

Op donderdag 17 maart 2022 om 19:23:05 UTC+1 schreef rob...@hotmail.com:

vsurducan

unread,
Mar 18, 2022, 4:15:12 AM3/18/22
to jal...@googlegroups.com

Rob CJ

unread,
Mar 19, 2022, 12:38:16 PM3/19/22
to jal...@googlegroups.com
Hi Hans,

I did a short test. Luckily I had one CD4046 laying around. I did not have the right capacitors but I managed to build something.

This is what I did (not all the details):
-) Connect the PIC that generates the frequency to the input of the CD4046
-) Connect the VCO voltage of the CD4046 to an LM358. I use the LM358 as a comparator. On the other pin of the LM358 I connected a potentiometer so that I could set it just to the value that it does not go on when the low frequency from the PIC is received.
-) I changed the PIC software slightly so that the frequencies are closer to each other. The frequencies where just a lucky shot.

I attached 4 screenshots:
-) Switching the PIC to the high frequency (blue line going low). You see that the response (output of the LM358, the yellow line)  is within 100 us which is quite fast
-) Switching the PIC to the low frequency. Here you see that first some pulses are generated before the output of the comparator is low and it takes some time. This can be handeld in software if you would use a PIC with a comparator for the reception. I had a capacitor connected to the input pin of the transmitting PIC. That did not help either but that can be fixed in the transmitting PIC too.
-) The low frequency of 7.27 kHz
-) The high frequency of 8.45 kHz

I did not do much calculation, only used components that I had. What I could see is that the CD4046 nicely locked to the incoming signal.

So it seems that this might work but no guarantee 🙂.

Kind regards,

Rob


Verzonden: vrijdag 18 maart 2022 09:09
High_frequency.bmp
Low_frequency.bmp
Switching_to_high.bmp
Switching_to_low.bmp

vsurducan

unread,
Mar 20, 2022, 1:56:38 AM3/20/22
to jal...@googlegroups.com
Congrats Rob, it looks good. :) Perhaps you need a positive feedback to the comparator ( resistor between comp output to + input) to kill the oscilations during falling edge? I assumed the yelow trace is the comparator output...

Rob CJ

unread,
Mar 20, 2022, 4:54:31 AM3/20/22
to jal...@googlegroups.com
Hi Vasile,

Thanks, yes I think that would help. Since I thought the comparator would be in a PIC, you could also fix it in software.

And correct, the yellow is the comparator output.

Kind regards,

Rob




Verzonden: zondag 20 maart 2022 06:56

Oliver Seitz

unread,
Mar 20, 2022, 8:22:10 AM3/20/22
to 'Oliver Seitz' via jallib
Hi all,

here's my encoder. I looked for something similar to the 12F683 which Hans has in stock, and found some 12F629, which should be quite compatible.


C1: minimum 1µF, no need to be polarized
R1:680R..1k
C2: 100nF
R2:1k..4k7
D1=D2: 1N4148, 1N4001 or similar, silicon, not schottky

This gives a frequency which a line (AUX) audio input should be able to handle. The receiver will be the same kind of chip, but it must have a comparator and a reference voltage module. TMR0 will be used.

The transmitter will work on any 6 or 8 pin controller, as it doesn't use any peripherals.

Greets,
Kiste


Seriaudial-T.jal

Rob CJ

unread,
Mar 20, 2022, 9:23:21 AM3/20/22
to jal...@googlegroups.com
Hi Oliver,

Nice, you do not need a PIC with a PWM for your solution.

I did some final measurements and attached all my info in the attached zip file, containing:
-) The program I used or the transmitter using PWM. I added some debounce after changing the frequency (instead of a capacitor on the input pin).
-) The screenshots of some more measurements. I also measured the VCO free running frequency (when there is no signal) and that is around 7.4 kHz. The low frequency of the transmitter is 7.23 kHz (screenshot low locked), where the high frequency is 8.4 kHz (screenshot high locked) where the yellow is the VCO frequency and the blue is the transmitted frequency by the PIC. I think is it best to always use a signal. I also added the VCO voltage when going from high to low which explains the pulses on the output.
-) The schematic diagram of the POC. I connected the output of the PIC directly to the input of the CD4046.

I have no idea how this behaves when you record the signal.  I also did not test other frequencies. Maybe it is more stable if the frequencies are a bit more apart. Nice for Hans to try out 🙂.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: zondag 20 maart 2022 13:21
Aan: 'Oliver Seitz' via jallib <jal...@googlegroups.com>

Onderwerp: Re: [jallib] PWM serial audio transmission
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
Audio_Signal_Trigger_POC.zip

Oliver Seitz

unread,
Mar 23, 2022, 12:22:42 PM3/23/22
to 'Oliver Seitz' via jallib
And here's the receiver, and a sample file. Mp3 does work at 1200baud, but you shouldn't use less than 128kbit for encoding. At 80kbit I only got garbage. Volume must be reasonably high, slowly turn louder until the error LED is constantly off.

Don't send too much data back-to-back, have pauses of like 10 ms every second (but keep the tone on all the time)

Don't assume error-free transmission, send data multiple times and check when receiving.

Greets,
Kiste



Am Sonntag, 20. März 2022, 13:22:14 MEZ hat 'Oliver Seitz' via jallib <jal...@googlegroups.com> Folgendes geschrieben:


--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
JAL-1200baud.mp3
Seriaudial-R.jal

hans

unread,
Mar 23, 2022, 4:30:25 PM3/23/22
to jallib

Hello everyone,

My grandfather Hans has only one usable eye and has got an infection on it. We have read your contributions and he is very happy with them. Sorry but he can't work with it right now.

Regards Marieke


Op woensdag 23 maart 2022 om 17:22:42 UTC+1 schreef Kiste:

Oliver Seitz

unread,
Mar 24, 2022, 2:37:45 AM3/24/22
to jal...@googlegroups.com
Altijd met Rust...

It took me two weeks to think, code and test, and it will take more weeks for proper documentation. So no need for you to hurry ;-)

Greets,
Kiste

Am Mittwoch, 23. März 2022, 22:36:19 MEZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


Rob CJ

unread,
Mar 24, 2022, 7:47:49 AM3/24/22
to jal...@googlegroups.com
Hi Marieke,

Thanks for the update. Let's hope Hans recovers soon.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: donderdag 24 maart 2022 07:37

Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: Re: [jallib] PWM serial audio transmission

rob...@hotmail.com

unread,
Mar 26, 2022, 3:05:55 PM3/26/22
to jallib
Hi Hans,

I hope you are getting well soon. Last update. I recorded the audio and played it back to see if it works.

And it seems to work but may need some fine tuning. In this video you see the device in operation: https://youtu.be/w-j0ekk975g

The yellow line on the oscilloscope is the audio signal and the blue line the trigger signal. This trigger signal is also visible by the Amber LED on the top right of the breadboard.

I recorded the low tone (it is a video recording but I am only using the audio) and switched from low tone to the high tone frequently. What you see is that the signal of the high tone is smaller but it still works. You also see that the refresh of the oscilloscope is a bit behind so the LED on the breadboard shows the real trigger. I also attached two screenshots. You see that the trigger response is quite fast (zoomed in) but with a high tone it is not constant (see zoomed out) but that can be solved in software and could be because the signal is smaller. Also I noticed that when no signal is present the output is also high but that stops as soon as the low tone is detected.

So still a proof of concept but seems to do something. I also attached the audio tone. Maybe lower tones would be better.

For recording I just used the output of the PIC using a resistor divider of 10 k with 100 Ohm and connecting that to the line in of my computer. For playback I added an LM358 to amplify the input signal and I used the headphone output.

Kind regards,

Rob


Op donderdag 24 maart 2022 om 12:47:49 UTC+1 schreef rob...@hotmail.com:
Playback_to_high_zoomed_in.bmp
Playback_to_high_zoomed_out.bmp
Recorded_audio.mkv

hans

unread,
Apr 3, 2022, 9:11:50 AM4/3/22
to jallib
Still foggy, just wait a little longer with this case.

Op zaterdag 26 maart 2022 om 20:05:55 UTC+1 schreef rob...@hotmail.com:

Rob CJ

unread,
Apr 3, 2022, 9:57:03 AM4/3/22
to jal...@googlegroups.com
Hi Hans,

I also tried it with a lower frequency, 3330 Hz for the low tone and 4030 Hz for the high tone so that the signal is strong enough when you record it.

If you want to know more, let me know.

Kind regards,

Rob


Verzonden: zondag 3 april 2022 15:11
Aan: jallib <jal...@googlegroups.com>
You received this message because you are subscribed to a topic in the Google Groups "jallib" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jallib/46GAtaPeJ_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/bac9ec42-c8a3-4f2f-82b1-16b63d06b6f6n%40googlegroups.com.

hans

unread,
Apr 5, 2022, 5:58:13 AM4/5/22
to jallib
Hello Rob and Kiste,
The next days i have a friend who can assist me. So (beside his AC project) we might find time to continue with this . So please give us the last info.
Thanks again
hans 

Op zondag 3 april 2022 om 15:57:03 UTC+2 schreef rob...@hotmail.com:

Rob CJ

unread,
Apr 5, 2022, 1:06:34 PM4/5/22
to jallib
Hi Hans,

The results of the second POC attempt. I changed the low and high frequency to 3330 Hz and 4030 Hz. The PLL free running frequency is around 3730 Hz so somewhere in the middle.

I attached the audio to this e-mail (sorry is video with audio) so you can hear the tone changes.
I uploaded a second video with the results based on this test: https://youtu.be/SLbV4Fko94c The LED on the top right of the video shows the exact response. The oscilloscope is a bit behind since it wants to trigger on the low to high transition (blue line). Sometimes I use short pulse and then you see that going from low to high on the oscilloscope is not going in one step. 
For more information on JAL, visit: http://justanotherlanguage.org/
I attached the software of the transmiter to this e-mail and the hardware schematic diagram of the transmitter and the receiver.

I used two tones on purpose that that there is a bigger 'gap' in the VCO voltage between the low and high frequency. I do not know if it would also work with one tone and let the PLL run free when there is no tone. It also might work and makes it even simpler.

I also attached some measurements. Going from a high tone to a low tone is detected within 460 us. From low to high takes 5.6 ms. At least that is the first time it can be detected since the transition is not direct but oscillates before it stabilizes. You need some kind of 'one-shot' trigger to stabilize that.

Kind regards,

Rob



Verzonden: dinsdag 5 april 2022 11:58
Recorded_audio_v2.mkv
High_to_low_v2.bmp
Low_to_high_v2.bmp
12f615_signal_transmitter_V2.jal
12f615_audio_signal_transmitter.pdf
Audio_signal_receiver.pdf

Oliver Seitz

unread,
Apr 5, 2022, 1:13:01 PM4/5/22
to jal...@googlegroups.com
I have only made small changes in the code and improved the comments. I did not try this version, but I'm quite sure it should work. You only need a PIC, a resistor, a TTL-Serial converter with a computer and the sample audio file which i posted earlier to see it working.

(You can even omit the resistor, but you could fry the PIC then. Especially if you don't use the error LED and have no idea about what volume to set)

Greets,
Kiste

Am Dienstag, 5. April 2022, 12:05:59 MESZ hat hans <hansvanve...@gmail.com> Folgendes geschrieben:


Seriaudial-R.jal

Rob CJ

unread,
Apr 5, 2022, 1:57:25 PM4/5/22
to jal...@googlegroups.com
Hi Kiste,

Nice solution. Hans has options to select from 🙂.

BTW. @hans. I made as small error in  my hardware receiver solution. Capacitor C3 should be 2nF (two 1nF in parallel) but if I where you I would try Kiste's solution first. If that works you are done.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: dinsdag 5 april 2022 19:12

hans

unread,
Jun 19, 2022, 6:46:36 AM6/19/22
to jallib
Hello all,
I've tried many things, but I always had problems. I have now received a handful of MT8880 from china and this time they all worked. Even when I apply this I regularly have malfunctions, but if I repeat every command 3 times and check then it works. I'm a bit further, only the person I was working for has unfortunately chosen something else. So this will go in the "you can't know box" for now.
We continue happily, it remains fun.
regards
Hans

Op dinsdag 5 april 2022 om 19:57:25 UTC+2 schreef rob...@hotmail.com:

hans

unread,
Nov 14, 2022, 3:19:26 PM11/14/22
to jallib

Hi Kiste,

Sometimes I have to push things aside. So is this topic. I have taken up the matter again and on my pin board both the transmitter and the receiver work with a 12F683 at 1200 baud. I did put a 100nF in series at the output according to your diagram. I also put a similar filter in the input of the receiver. Identical to your proposal but because I know absolutely nothing about filter matters I don't know if I did this right.

I feed a separate uart signal as input and read out another uart with the receiver.

I recorded the signal with audicity and saved it as WAV. When playing back to the receiver I do get responses but there is quite a bit of junk.

My question : what should the inlet filter to the receiver look like.

I know your box of thanks is already full, but I'll add another one.

regards

Hans


Op zondag 19 juni 2022 om 12:46:36 UTC+2 schreef hans:

hans

unread,
Nov 16, 2022, 3:20:58 AM11/16/22
to jallib

Hello highly honored public,

I did some research in low/high pass filter science and found a lot of calculation programs.

In the contribution of Kiste 20 Mar. 2022 13:22:10 an R value of 680 .. 1 K is indicated and a C value of 1uF. The system works with 5 and 8 kHz. When I run the found calculation tool on it, I get very different values. I must be completely wrong again, but the transmitter and receiver do work, only with glitches.

My question is outside the JALLIB world but I'll try anyway.

regards

Hans


Op maandag 14 november 2022 om 21:19:26 UTC+1 schreef hans:

Oliver Seitz

unread,
Nov 16, 2022, 7:08:59 AM11/16/22
to jal...@googlegroups.com
Hi Hans, sorry for being late...

I had to find the drawings back, didn't know what I designed back then. The filtering of the sender is a ugly hack. C1 removes DC, so the voltage will swing form -2,5 to +2,5V. R1/C2 is a low pass filter which has a frequency well below the transmitted frequencies and shapes the square wave from the PIC to something similar to a triangle of about +/-1V. R2 sets the output impedance and limits the load on the filter. The two antiparallel diodes clip the triangle wave with their exponential characteristics to a voltage of about +/- 0,7V with round tops, that way it is on a level which a line-in audio input can handle and it roughly resembles a sine wave.

For the receiver, if I do remember it right, I did not use any filters, I just recommended a resistor to protect both audio equipment and PIC.

Greets,
Kiste

Am Mittwoch, 16. November 2022 um 09:21:00 MEZ hat hans <hanz...@zeelandnet.nl> Folgendes geschrieben:


hans

unread,
Nov 16, 2022, 10:35:29 AM11/16/22
to jallib
Hi Kiste, 
Thank you for your comment. I now understand why. I do see a rounding on my scope. If I replace C2 with an electrolytic capacitor of 1 uF, I see an even better analog signal. Would that make sense to get less clutter?
I'm going to solder everything on pcb in the next few days and see if the practice is also good.
So far everything seems much better.
thank you
Hans

Op woensdag 16 november 2022 om 13:08:59 UTC+1 schreef Kiste:

vsurducan

unread,
Nov 16, 2022, 1:41:34 PM11/16/22
to jal...@googlegroups.com
Hello senior contributor,
there are at least two serious software for filter computing named Filterpro from TI and Elsie from Tone software,  both free at the time I've work with. Each is excellent just for a segment of filters...not for everything.


hans

unread,
Nov 16, 2022, 3:00:02 PM11/16/22
to jallib
Whoeps Vasile, that looks great.......... now see what and how........ iThanks 

Op woensdag 16 november 2022 om 19:41:34 UTC+1 schreef vasile:

hans

unread,
Nov 17, 2022, 7:33:35 AM11/17/22
to jallib
The never ending story.
Now put the case on pcb and tested. Recorded signal looks strange. Directly coupled transmitter and receiver with audio works, but when the audio signal is branched off to audio-in PC it no longer works. The recording is made and then playback gives the receiver a good result.
SUGGESTIONS???
thanks

Op woensdag 16 november 2022 om 21:00:02 UTC+1 schreef hans:
audio_test.jpg

Oliver Seitz

unread,
Nov 17, 2022, 8:20:51 AM11/17/22
to jal...@googlegroups.com
On 2022-03-23 I've sent a sample file which i could read without error. Did you try that? It contains a few lines of text. 
I think, too low of playback volume might lead to read errors, or too long strings without pause. Or, of course, using mp3 or the like at too low bitrate.

Greets,
Kiste


Am Donnerstag, 17. November 2022 um 13:33:39 MEZ hat hans <hanz...@zeelandnet.nl> Folgendes geschrieben:


Oliver Seitz

unread,
Nov 18, 2022, 2:33:26 AM11/18/22
to jal...@googlegroups.com
Oh, do I understand that right, that only the direct transmission from sender Pic to receiver Pic does not work while simultaneously recording audio? In that case, connect the receiver directly to the sender's output pin, no filter is needed here. Only a resistor in case the receiver runs on a lower voltage than the sender.

If the filter is loaded with an audio input, levels may go too low for the receiver. The receiver does not need any filtering at all, that's only for audio compatibility.

Greets,
Kiste 


Am Do., Nov. 17, 2022 at 13:33 schrieb hans

hans

unread,
Nov 18, 2022, 6:46:48 AM11/18/22
to jallib
https://youtu.be/ujfMYD5zXNU
Hi Kiste,

I am glad that you were able to understand my story well. Direct transfer of the commands outside of the audio gives me no assurance that the thing will also work via the audio afterwards. Audicity has the option to output the signal during recording and I have now connected the receiver to it via a C of 0.1 uF. That works fine. Now I'm going to try everything in practice on my new friend Chucky
.( Looks like Mariek https://youtu.be/ujfMYD5zXNU  I made years ago but she worked on MIDI and that has no sstem capability. Chucky should be able to do it all.)
greetings and thanks again
Hans
Op vrijdag 18 november 2022 om 08:33:26 UTC+1 schreef Kiste:
Reply all
Reply to author
Forward
0 new messages