Need some Costas Loop questions answered - Page 1
Forum section: electronics / rf-microwave

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 25, 2021, 11:43:00 pm
content: I have been reading a lot about BPSK Costas loop circuits. Everything I find on the web that explains how they operate is math and block diagrams. I haven't found an actual schematic of a Costas loop in operation. Does anyone have a link to a schematic? Frequency and symbol rate doesn't matter.I think I have enough information to begin experimenting. But I have questions about the attached block diagram. For the sake of discussion assume I am generating a 100 kHz sine wave as the input signal and toggling the phase between 0 degrees and 180 degrees once per second. My AWG is capable of doing this so that would be my starting point.For the first two mixers I was thinking about using a DG419LED SPDT switch or two sections of a CD4066. Or should I use a doubly balanced mixer such as the SA612?Next question concerns the lowpass filters. Since the symbol rate is only 1 Hz could the lowpass filters simply be a 1st order R-C circuit? What should the cutoff point be, 2 Hz, 5 Hz, 10 Hz or something else?For the phase detector would an XOR such as the CD4070 or 74HC86 be sufficient? Or would I need something more complex? I haven't been able to decipher the loop filter but I read somewhere the cutoff frequency needs to be 4-8 times the lowpass filters cutoff frequency.For the 100 kHz VCO I will use a crystal oscillator with a varicap diode followed by a buffer stage(s). To generate the 0 degree and 90 degree signals I will have the VCO drive a 74HC74. I will put everything together dead bug style for my testing.Please point out any errors in my (mis)understanding of the Costas loop.

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 26, 2021, 06:15:32 am
content: Attachment shows how I plan to use the DG419 as a mixer. I believe it should work. If not I could go the the SA612 solution.

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 26, 2021, 03:10:44 pm
content: No Costas knowledge here?

author: David Hess
author_rank: Super Contributor
timestamp: February 27, 2021, 01:40:25 pm
content: Check out the end of National Semiconductor application note 38 where a practical Costas loop circuit using a VFO, discrete logic (3 flip-flops to generate the in-phase and quadrature clocks), and analog switches to simultaneously demodulate AM and FM is discussed.

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 27, 2021, 09:09:27 pm
content: David, thanks for the response. I looked at the AN. Really old 1980s technology with unobtainium parts but I think the idea is the same.I breadboarded a circuit to test my idea but I am not getting the results I expected. The schematic and output screen shots are attached.For the One_Two picture I am feeding a 1 kHz signal into the input of the op amp. The output of the first stage is fed to the NC contact of the switch. The inverted output of the second stage is fed to the NO contact of the switch. The switch is toggled at 1 kHz by the second channel of my AWG.I expected to see a 2 kHz signal at the common contact of the switch. I somewhat do see the 2 kHz signal but the 1 kHz signal dominates. If you look at the rising edge of the 1 kHz signal you also see a large 2 kHz rising edge. Looking at the falling edge of the 1 kHz signal you see the rising edge of the 2 kHz signal but it is being pulled back down by the falling edge 1 kHz signal.The 1 kHz signal is the square wave I am using to toggle the switch at the 1 kHz rate. It is a 3V Pk-Pk signal because the switch requires a minimum of 2.4V to turn it on. The op amp is being driven by a 2V Pk-Pk signal. So I think I am going to have to use an active mixer such as the SA612 if I expect the Costas circuit to work.As a test I fed a 60 kHz signal into the op amp. I toggled the switch with a 50 kHz square wave expecting to get a 10 kHz signal out. There was a very ugly output so I put a 1st order RC low pass filter at the output with a cutoff frequency of 10 kHz. The Sixty_Fifty picture shows that I do get 10 kHz out but it is being modulated by the 50 kHz square wave. That tells me that the signal being fed to the "mixer" switch would need to have a much greater level than the signal being used to toggle the mixer. The only way around that would be to use an active circuit doubly balance mixer which would reduce RF and LO signal feed through.Costas Loops are described as being simple in theory but apparently real life application is different. I still don't know what the signal from the low pass filters feeding the phase detector is supposed to be. Would it be double the incoming signal frequency or the same as the incoming frequency? For the VCO to lock to the incoming signal it would have to be the same frequency wouldn't it? Are the lowpass filters designed to eliminate the double frequency signal?

author: ogden
author_rank: Super Contributor
timestamp: February 27, 2021, 09:42:31 pm
content: Quote from: rcbuck on February 26, 2021, 03:10:44 pmEverybody but you are building demodulators using DSP today. That's why most likely you are on your own here.Quote from: rcbuck on February 27, 2021, 09:09:27 pmLowpass filter of downconverterseparatesbaseband signal from carrier.https://en.wikipedia.org/wiki/Heterodyne

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 28, 2021, 12:57:12 am
content: QuoteSo I'm the only person anywhere who doesn't know anything about DSP? Is that what you are trying to say? Is there anything wrong with wanting to learn how the Costas loop works with hardware?QuoteThat is why in the first post I asked if the lowpass filter cutoff should be 2 Hz, 5 Hz, 10 Hz, or something else.

author: coppice
author_rank: Super Contributor
timestamp: February 28, 2021, 01:11:08 am
content: Quote from: ogden on February 27, 2021, 09:42:31 pmThe Costas loop is one of the commonest approaches to use in a DSP receiver.

author: ZigmundRat
author_rank: Regular Contributor
timestamp: February 28, 2021, 01:38:22 am
content: I’ve kind of got the same questions. If Costas loop in DSP is such a no brainer, and so easy, where’s the ELI5? Where’s the tutorial for implementing one at say audio frequency?

author: coppice
author_rank: Super Contributor
timestamp: February 28, 2021, 01:56:39 am
content: Quote from: ZigmundRat on February 28, 2021, 01:38:22 amIn your original post you included a clipped out image with some blue lines pointing to all the interesting parts of the loop. I expect the full image had enough explanation at the end of the arrows to show how things operate. Basically, if you want to mix down to baseband and lock the mixing frequency as you do so, you need a complex extension of a basic PLL. That's all a Costas loop is.

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 28, 2021, 02:23:56 am
content: coppice, no there was no explanation. The blue lines were just identifying the parts of the block diagram. Which was kind of funny because all of the blocks are labeled. No mention of what the cutoff frequency of the lowpass filters should be. Since I want to mix down to baseband I guess a 10 Hz cutoff would be perfectly good for a 100 kHz signal??QuoteThat may very well be true. However I have no DSP knowledge and my guess is most embedded programmers also lack DSP knowledge. As ZigmundRat said everybody "talks" about how simple it is. But I've never seen a simple explanation online. The explanations all seem to involve a lot of math. It has been 50 years since I took algebra and trig courses in school and I have pretty much forgotten all of it.

author: ogden
author_rank: Super Contributor
timestamp: February 28, 2021, 06:51:38 am
content: Quote from: rcbuck on February 28, 2021, 12:57:12 amNot choosing DSP for demodulators does not imply lack of DSP knowledge. It is insanely unproductive to learn signal processing using hardware.QuoteRC filter cutoff shall be as close to symbol rate as possible - to filter as much noise off baseband as possible. Thou in your learning exercise any freq you mention will do the job.

author: ogden
author_rank: Super Contributor
timestamp: February 28, 2021, 06:59:31 am
content: Quote from: ZigmundRat on February 28, 2021, 01:38:22 amhttps://dsp.stackexchange.com/questions/22316/simulating-bpsk-costas-loop-in-matlabhttps://se.mathworks.com/matlabcentral/fileexchange/29265-costas-loop-for-bpsk?s_tid=srchtitleSearch terms: "costas loop", "matlab", "octave". Also try "BPSK receiver", "matlab". When you "develop" your solution in Matlab or Octave and actually understand it - then most likely you will have idea how to implement it using real DSP hardware.

author: benkm
author_rank: Newbie
timestamp: February 28, 2021, 10:00:01 am
content: We designed a 1.7 GHz receiver for weathersatellites with a costas-loop (QPSK) in hardware:http://www.alblas.demon.nl/kunstmanen/KM2016_4.pdfhttp://www.kunstmanen.net/index.php/2012-10-01-09-31-09/archeifHere is an example of a BPSK-demodulator:http://s53mv.s56g.net/nbp/ax25/Bpskdem.pdf

author: rcbuck
author_rank: Frequent Contributor
timestamp: February 28, 2021, 07:20:06 pm
content: Quoteogden, thanks. My symbol rate is 1 Hz or less. I will use 10 Hz as a starting point. For my tests all I want to do is light a LED when my AWG changes the 100 kHz signal phase to 180 degrees. When the phase goes back to 0 degrees the LED will go out. I will setup the AWG to toggle once every second or two. According to the site where I got the block diagram I should be able to do that at the output of the upper lowpass filter assuming the VCO is frequency and phase locked to the incoming signal. I will continue experimenting.benkm, the BPSK demodulator circuits in the pdf are interesting. It looks like they have built up a nice packet radio network.