PWM serial audio transmission

67 views
Skip to first unread message

hans

unread,
Feb 23, 2022, 2:53:32 AMFeb 23
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 AMFeb 23
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 PMFeb 23
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 AMFeb 24
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 AMFeb 24
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 PMFeb 24
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 PMFeb 24
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 PMFeb 24
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 PMFeb 24
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 AMFeb 25
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 AMFeb 25
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 AMFeb 25
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 AMFeb 25
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 AMFeb 25
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 PMFeb 25
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 AMFeb 26
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 PMFeb 26
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 AMFeb 27
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 AMFeb 27
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 AMFeb 27
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 AMFeb 27
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 AMMar 16
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 PMMar 16
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 AMMar 17
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 AMMar 17
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 PMMar 17
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 AMMar 18
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 AMMar 18
to jal...@googlegroups.com

Rob CJ

unread,
Mar 19, 2022, 12:38:16 PMMar 19
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 AMMar 20
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 AMMar 20
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 AMMar 20
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 AMMar 20
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 PMMar 23
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 PMMar 23
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 AMMar 24
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 AMMar 24
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 PMMar 26
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 AMApr 3
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 AMApr 3
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 AMApr 5
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 PMApr 5