Stereo Coder using Walsh Function

Everything technical about radio can be discussed here, whether it's transmitting or receiving. Guides, charts, diagrams, etc. are all welcome.
Post Reply
Albert H
proppa neck!
proppa neck!
Posts: 2778
Joined: Tue Apr 05, 2016 1:23 am

Stereo Coder using Walsh Function

Post by Albert H » Fri Mar 03, 2023 2:46 pm

Looking back to my Electronic Theory, I remembered Walsh Function and Rademacher synthesis. This is a cheap and simple method of generating clean waveforms with a minimum of hardware.....

A little while with a breadboard, and this is what Bob and I came up with. This is the third iteration of the circuit, and gives pretty good 19kHz sine purity, and subjectively good stereo separation:
Walsh Synthesis Stereo Coder++.png
There's still work to be done, but a board layout will follow when we're totally happy with the results. As usual, we've avoided exotic components as far as possible, and it runs from a single supply rail, making it easy to use.

The tweakable 3.3mH inductor came from a scrapped tape recorder - I'm trying to find a reliable source for this. The 2mH choke was actually two 1mH parts in series...
You do not have the required permissions to view the files attached to this post.
"Why is my rig humming?"
"Because it doesn't know the words!"
;)

jvok
no manz can test innit
no manz can test innit
Posts: 220
Joined: Sun Aug 16, 2020 2:44 pm

Re: Stereo Coder using Walsh Function

Post by jvok » Sat Mar 04, 2023 4:45 pm

Very clever design, I've never seen a stereo coder done like that before. I'd never heard of walsh functions or rademacher synthesis til you mentioned them in the other thread (but if youve got any references I can read I'm interested) so this is me talking as a circuit designer not a mathematician.

If I understand it right its doing 8x oversampling for both the MPX and the pilot. U3 (along with R3/R4) is selecting between 4 possible states:

0: Mostly right (X=L and Y=R)
1: Mostly left (X=R and Y=L)
2: Fully right (X=R and Y=R)
3: Fully left (X=L and Y=L)

R3 and R4 add the X and Y outputs with the correct weights so Y is higher-weighted than X.

The job of the XOR gates (U2.2 and U2.3) is to turn the count sequence from U1 into a sequence that goes 0-2-2-0-1-3-3-1 which will select between the 4 the states in the right order.

The pilot tone generator is mostly the same thing except you don't need the 4051 because your inputs are just DC levels (HIGH or LOW) rather than left/right audio signals, so you can just feed the gate outputs directly to the resistors. In this case the sequence counts 0-0-1-1-2-2-3-3-3-3-2-2-1-1-0-0 so will output half the frequency of the subcarrier.

Finally U5.2 adds in some extra (adjustable) mono component to correct the stereo width, and U5.1 mixes everything together. Also because U5.1 is inverting you have to:
  • Invert the L and R inputs (U4.1 and U4.2)
  • Invert the pilot tone which is done through the logic, i.e. states 0/1 are "negative" (below half rail) and 2/3 are "positive" (above half rail)
  • Reverse the logic sequence for the MPX generator, i.e. it starts on the right channel and moves towards left. Whereas most coders start from left and move towards right
Anyway really cool design. I particularly like how you avoided the big resistor strings you get in most oversampling coders and also how the pilot generator doesn't use another mux.

User avatar
3metrejim
no manz can test innit
no manz can test innit
Posts: 147
Joined: Wed Feb 22, 2017 3:00 pm

Re: Stereo Coder using Walsh Function

Post by 3metrejim » Sat Mar 04, 2023 5:57 pm

jvok, that is the same sequence that you get from a 'walking ring' generator, and has also been used in encoders. The BEXT XT150 encoder uses the same principle. There is a link to it's schematic elsewhere on this site. It's on amateur radio YO4HFU's site (along with details of other switching encoders)

https://www.qsl.net/yo4hfu/Stereo_coder_sampling.html

(right at the bottom of the page)

User avatar
3metrejim
no manz can test innit
no manz can test innit
Posts: 147
Joined: Wed Feb 22, 2017 3:00 pm

Re: Stereo Coder using Walsh Function

Post by 3metrejim » Sat Mar 04, 2023 6:04 pm

Albert H, It might be a good idea to class high value inductors as 'exotic components' in this day and age, especially the variable types (19kHz phase shift).

jvok
no manz can test innit
no manz can test innit
Posts: 220
Joined: Sun Aug 16, 2020 2:44 pm

Re: Stereo Coder using Walsh Function

Post by jvok » Sat Mar 04, 2023 7:33 pm

Hmm so that circuit is pretty much a direct copy of the russian walsh coder from the YO4HFU site, except for changing the 2.432MHz crystal to 4.864MHz site: https://www.qsl.net/yo4hfu/Files/STEREO ... Stereo.pdf

"this is what Bob and I came up with" my arse

User avatar
3metrejim
no manz can test innit
no manz can test innit
Posts: 147
Joined: Wed Feb 22, 2017 3:00 pm

Re: Stereo Coder using Walsh Function

Post by 3metrejim » Sat Mar 04, 2023 7:43 pm

jvok wrote: Sat Mar 04, 2023 7:33 pm Hmm so that circuit is pretty much a direct copy of the russian walsh coder from the YO4HFU site, except for changing the 2.432MHz crystal to 4.864MHz site: https://www.qsl.net/yo4hfu/Files/STEREO ... Stereo.pdf

"this is what Bob and I came up with" my arse
I guess you can only implement the method one way, but each design will likely use differing components unless some copying goes on.

Some good information of creating sinewaves from digital ICs can be found in this ancient article from Don Lancaster:

https://www.tinaja.com/glib/rad_elec/di ... _11_76.pdf

There is also the 'complement counter' version, does a count up then down by inverting a count with xor gates, then uses resistors in a fashion similar to an A2D with the values 'bent' to create a sine wave:

http://zpostbox.ru/digital_sine_wave_oscillator.html

All good to add to the knowledge base, and faster than a lookup table in a small PIC micro - one counter with a conditional inversion rather than a table lookup.

Albert H
proppa neck!
proppa neck!
Posts: 2778
Joined: Tue Apr 05, 2016 1:23 am

Re: Stereo Coder using Walsh Function

Post by Albert H » Sat Mar 04, 2023 9:54 pm

jvok wrote: Sat Mar 04, 2023 7:33 pm Hmm so that circuit is pretty much a direct copy of the russian walsh coder from the YO4HFU site, except for changing the 2.432MHz crystal to 4.864MHz site: https://www.qsl.net/yo4hfu/Files/STEREO ... Stereo.pdf

"this is what Bob and I came up with" my arse
It's remarkably similar - I never claimed that there was no "prior art"! Bob did the diagrams and has been laying out a PCB. Looking through my manuals, I find that the BBC MPX5 coder uses exactly the same Walsh function - done almost the same way. I've subsequently found a way of getting rid of the tweakable choke, and - with the addition of just three ICs - I can get up to 24 or even 32-step sampling on both audio and pilot.

The basic problem of harmonic crap still remains, and I don't like the lowpass filter on the output - the filter phase shifts degrade the stereo separation. We've got a breadboarded circuit (nine of those plug-in breadboards) with a second modulator running at 114kHz. This is attenuated, inverted, and put into the main multiplex at the right level to null out the third harmonic (the predominant one) of the main multiplexer. The fifth harmonic is far enough away (and small enough) that a 150 kHz lowpass filter gets rid of it without affecting the S component.

Another change to the circuit was to use a phase-locked loop to generate the various signals from a 4.332MHz rock, so that it's all inherently locked to the 57kHz RDS subcarrier as well. The 150kHz lowpass also eliminates the (admittedly minuscule) third harmonic of the RDS. The use of the PLL is probably overkill - it adds five ICs - so I'm just coding a 16F628 to give all the frequencies I need out of just one chip and one crystal. Keeping everything phase coherent is mostly a question of counting out the right number of NOPs between switching events for each output (or group of outputs).

My very first commercial stereo coder (back in the 70s) used MC1496s for the "S" component and to double the 19kHz pilot (sin²x identity) for the 38kHz subcarrier. My aim was to be "all analogue". Around the same time, Trevor Brooks (Surrey Electronics) published a similar design in "Wireless World". He used a 19kHz crystal for his pilot oscillator. I can't imagine what one of those would cost!

My big problem was generating a good, stable 19kHz sinewave, and it was pointed out to me (by one of my University lecturers) that Walsh synthesis could be a way to go, generating it digitally from TTL logic. It worked, but was rather too jagged for the use I was going to put it to, even after filtering. In the end, I used a Wien Bridge oscillator phase-locked to a crystal. The Wien Bridge was dimensioned for 19kHz, and the two frequency-determining resistors were partially replaced by LDRs (light-dependent resistors). There was a little incandescent torch lamp illuminating the LDRs, and the current through the bulb was varied by the output of the PLL loop filter!

A temperature-compensated Wien Bridge oscillator gives very low distortion, and the 19kHz pilot was the purest I'd ever seen. When precisely aligned, the coder would give around 52dB stereo separation, which was world-leading in 1975. Unfortunately, it was somewhat temperature sensitive, and alignment was tricky.

Cheap, fast enough CMOS soon came along, and I started designing crystal-derived switching coders - you can see some of my early CMOS circuits in Elektuur from the early 80s. A friend of mine published a simple switching coder in FRM in the Netherlands, and every local pirate station went stereo - seemingly overnight!

I the 90s, I redesigned Stephen Moss' re-design of one of mine from the 80s. His version didn't know left from right (it would start in random phase), and when the grief with H******s first blew up, I added a monostable to the 4013 (using its redundant half) so that it always started in the right phase. That meant that the input sockets could be confidently labelled "Left" and "Right". I also added three diodes to enable mono / stereo switching - when the diode anodes are taken high, both of the CMOS switches are turned hard on simultaneously, letting both channels through, and the output of the 19kHz filter is forced to the positive rail by the third diode, effectively switching off the pilot tone. With the addition of two LEDs and some resistors, we got mono / stereo indication as well - all controlled from just one switch contact! This meant that the NRG product was substantially different from the "other" one. Incidentally, the poor layout of the H******s "Veronica" coder means that there are all sorts of spurs put out from the thing which make the rig appear all over the band! And it still doesn't know its Right from its Left.....

The next coder I did for Steve (the Pro IV) used really low noise op-amps and oversampling. The audio quality from that coder still stands up against anything available today, and has been used by many commercial stations. The Pro V coder was in development at the time of Steve's death. It was to include a three-band stereo limiter, active 15kHz filters, and even better performance. I'd gone back to Walsh synthesis for the subcarrier generation, and was going to use PWM for the limiter attenuators (since the coder filters would remove the switching residuals.... It was loosely based on some of the work done for the "David" airchain boxes. I found some of the circuit sketches when I was cleaning out my old office last year - I'll scan them and put them up here at some point soon.

The "Walsh" coder was an attempt to get reasonable results with minimal resources - just like most pirates! I'm still not happy with it - there's a lot of work to do to it.....
"Why is my rig humming?"
"Because it doesn't know the words!"
;)

User avatar
3metrejim
no manz can test innit
no manz can test innit
Posts: 147
Joined: Wed Feb 22, 2017 3:00 pm

Re: Stereo Coder using Walsh Function

Post by 3metrejim » Sat Mar 04, 2023 11:50 pm

I'm thinking that the up-down counter type with a 4053 might get you x16, with only 3 resistors. Coupling one channel to the X inputs and the other to the _X inputs. Not sure, but at least the Russian site had a bonus of having most of the CMOS 4xxx series library for LT spice so it's possible to test the theory without the sometimes tedious pen and paper work through.

Krakatoa
big in da game.. trust
big in da game.. trust
Posts: 87
Joined: Tue Mar 07, 2017 8:57 pm

Re: Stereo Coder using Walsh Function

Post by Krakatoa » Sun Mar 05, 2023 6:51 pm

3metrejim wrote: Sat Mar 04, 2023 6:04 pm Albert H, It might be a good idea to class high value inductors as 'exotic components' in this day and age, especially the variable types (19kHz phase shift).
Fixed high value inductors are actually no problem, but variable high inductance coils have always been difficult to source because they have been made for specific applications like bias oscillators and filters for tape recorders, or RF circuits for long wave radio tuners.
Luckily, right now you can find them being manufactured again because they are needed for ultrasonic range finders, and here are some examples:

https://www.aliexpress.us/item/22558011 ... _shipto=US

And

https://eu.mouser.com/ProductDetail/Pro ... a4fg%3D%3D

And if you like to experiment, you can wind/unwind them to achive the required nominal inductance.

User avatar
sinus trouble
proppa neck!
proppa neck!
Posts: 1410
Joined: Fri Aug 22, 2014 11:34 pm

Re: Stereo Coder using Walsh Function

Post by sinus trouble » Mon Mar 06, 2023 12:59 am

I couldnt care less who invented what or built it! This is great stuff! :lol:

After reading through whats been posted, I wanna build one of those "Walking Counters" just to play with!! :D
I am as stupid as I look! :|

Albert H
proppa neck!
proppa neck!
Posts: 2778
Joined: Tue Apr 05, 2016 1:23 am

Re: Stereo Coder using Walsh Function

Post by Albert H » Tue Mar 07, 2023 1:27 am

I've found the original Walsh coder notes from the BBC Designs Department paper that I co-wrote (in 1975!!). As usual, I did all the work, and my boss stole half the credit for it! The original notion came from a need to synthesise reasonably low distortion sinewaves for precise speed alignment of tape recorders and turntables (remember them?!). We built a digital sinewave source for that project, then I had the bright idea of extending it to other devices that needed sinewave sources that were pure enough, frequency accurate, and in lock-step phase with one another.

The first Walsh Function coder was in 1974, and remained a laboratory curiosity for several years, until we needed some coders thrown together in a hurry for export.....
"Why is my rig humming?"
"Because it doesn't know the words!"
;)

Albert H
proppa neck!
proppa neck!
Posts: 2778
Joined: Tue Apr 05, 2016 1:23 am

Re: Stereo Coder using Walsh Function

Post by Albert H » Tue Mar 07, 2023 1:29 am

sinus trouble wrote: Mon Mar 06, 2023 12:59 am After reading through whats been posted, I wanna build one of those "Walking Counters" just to play with!! :D
Build one, buffer its outputs with transistors and you can make a really pretty LED lighting display!
"Why is my rig humming?"
"Because it doesn't know the words!"
;)

User avatar
sinus trouble
proppa neck!
proppa neck!
Posts: 1410
Joined: Fri Aug 22, 2014 11:34 pm

Re: Stereo Coder using Walsh Function

Post by sinus trouble » Wed Mar 08, 2023 1:03 am

Albert H wrote: Tue Mar 07, 2023 1:29 am
sinus trouble wrote: Mon Mar 06, 2023 12:59 am After reading through whats been posted, I wanna build one of those "Walking Counters" just to play with!! :D
Build one, buffer its outputs with transistors and you can make a really pretty LED lighting display!
Haha! Nice one Albert! :lol:

Not quite what i was eluding to? But hey, you cannot beat a great light show! :lol:

After reading through all the comments and documents posted, The resistor array which forms the sinewave is very interesting! I dunno what you would call it? Maybe a "weighted potential array"

Anyways, from what i gather? It seems the clock speed determines the frequency of the recovered sinewave?

I have some CD4013s lying around somewhere which may work for experimenting? :D
I am as stupid as I look! :|

Albert H
proppa neck!
proppa neck!
Posts: 2778
Joined: Tue Apr 05, 2016 1:23 am

Re: Stereo Coder using Walsh Function

Post by Albert H » Wed Mar 08, 2023 1:38 am

sinus trouble wrote: Wed Mar 08, 2023 1:03 am
Not quite what i was alluding to? But hey, you cannot beat a great light show! :lol:

Anyways, from what i gather? It seems the clock speed determines the frequency of the recovered sinewave?

I have some CD4013s lying around somewhere which may work for experimenting? :D
You'll also need some exclusive-OR gates. You're right - the clock speed determines the output frequency. You can generate almost any repetitive waveshape you want with this kind of counter. I've got one in a Medium Wave "Outphased" transmitter as the carrier source. I wanted to be able to generate good sinewaves on any frequency in the range of interest with reasonable purity and simple frequency selection. The Walsh Function generator worked perfectly, and the carrier (and its complement) are fed to a couple of comparators, and the other inputs of the two comparators are fed with audio and inverse audio. The resultant PDM squarewaves are then amplified in a pair of broadband Class D amplifiers, and fed to an output combining network that mixes the two modulated carriers together for the resultant AM output.

The sine purity is (as always) determined by the number of steps and the accuracy of the relationships in the resistors.
"Why is my rig humming?"
"Because it doesn't know the words!"
;)

User avatar
3metrejim
no manz can test innit
no manz can test innit
Posts: 147
Joined: Wed Feb 22, 2017 3:00 pm

Re: Stereo Coder using Walsh Function

Post by 3metrejim » Fri May 19, 2023 2:30 am

SBS (Sound Broadcast Services) equipment also used the Walsh function, they were the producers of the mpx5. They even have a wikipedia page https://en.wikipedia.org/wiki/Sound_Broadcast_Services , producing stuff for the pirates as 'wavegood' (name missing from wikipedia article).

I'm missing these from the SBS technical manual collection (broadcast radio history preservation), if anyone has them: FM25/RDS RDS encoder, FMB10 RDS encoder, Guardian Audio failure detector (1 & 2), FMLP2 2W FM exciter, PA125 125W FM amplifier, TAConn RS232 remote control for RDS TA flag switching and MicLim Microphone limiter. Wikipedia is missing the CU1000 (combiner unit).

I could swear that SBS had a stand at the Elvaston Castle radio rally, way, way back (was best place to pick up cheap parts in those days), so I probably met the legendary engineer Pyers (one of the directors), without even realising.

Albert H
proppa neck!
proppa neck!
Posts: 2778
Joined: Tue Apr 05, 2016 1:23 am

Re: Stereo Coder using Walsh Function

Post by Albert H » Sat May 20, 2023 12:51 am

I was acquainted with Pyers way before SBS - when he was still at the Lycee in West London, and living with his parents near to Gloucester Road tube. He was a pretty talented engineer - even in those days - and quickly got to the point of building competent rigs powerful enough (in those days) to put a reasonable signal throughout much of London.
"Why is my rig humming?"
"Because it doesn't know the words!"
;)

Post Reply