{"id":12590,"date":"2025-12-27T19:42:52","date_gmt":"2025-12-28T00:42:52","guid":{"rendered":"https:\/\/jeremyclark.ca\/wp\/?p=12590"},"modified":"2025-12-28T07:10:18","modified_gmt":"2025-12-28T12:10:18","slug":"carrier-synchronization-with-costas-squaring-loops-simulation","status":"publish","type":"post","link":"https:\/\/jeremyclark.ca\/wp\/telecom\/carrier-synchronization-with-costas-squaring-loops-simulation\/","title":{"rendered":"Carrier Synchronization with Costas &amp; Squaring Loops -Simulation"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Costas &amp; Squaring Loops are key components in reception of Telecommunication Signals. They are used to synchronize a local generated carrier with an incoming received carrier. We can simulate and study their operation using Scicos (<a href=\"https:\/\/www.clarktelecommunications.com\/simulation.htm\">Ref.1<\/a>). First we generate a BPSK waveform at R=100bit\/sec to use with our two Demodulators (<a href=\"https:\/\/jeremyclark.ca\/wp\/telecom\/satellite-qpsk-oqpsk-simulation\/\">Ref.2<\/a>).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BPSK Waveform Generation<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1004\" height=\"827\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk.jpg\" alt=\"\" class=\"wp-image-12684\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk.jpg 1004w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk-300x247.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk-768x633.jpg 768w\" sizes=\"auto, (max-width: 1004px) 100vw, 1004px\" \/><figcaption class=\"wp-element-caption\">FIg.1 Scicos Schematic for BPSK Generation PN Data Source R=100bit\/sec Fc=1KHz<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"607\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_data_100bps-1024x607.jpg\" alt=\"\" class=\"wp-image-12689\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_data_100bps-1024x607.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_data_100bps-300x178.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_data_100bps-768x455.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_data_100bps.jpg 1526w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.2 A=BPSK PN Data 2^5-1=31bit R=100bit\/sec<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"505\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_spec_100bps-1024x505.jpg\" alt=\"\" class=\"wp-image-12615\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_spec_100bps-1024x505.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_spec_100bps-300x148.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_spec_100bps-768x379.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_spec_100bps-1536x758.jpg 1536w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/bpsk_spec_100bps.jpg 1560w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.3 Spectrum of BPSK PN Data Fc=1KHz +\/- 100Hz<\/figcaption><\/figure>\n\n\n\n<p>Figure 1 shows a Scicos Schematic that can be used to generate BPSK at R=100bit\/sec with carrier Fc=1KHz. This is identical to the schematic used in <a href=\"https:\/\/jeremyclark.ca\/wp\/telecom\/satellite-qpsk-oqpsk-simulation\/\">Ref.2<\/a> for QPSK by just removing the Demux &amp; Q branch. Figure 2 shows the PN data waveform repeating every 31bits=31*0.01sec=310msec. Figure 3 shows the output spectrum centered at Fc=1KHz +\/-100Hz to first nulls. Notice the absence of a discrete line at Fc that a receiver could lock on!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Costas Loop Scicos Simulation<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"495\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop-1024x495.jpg\" alt=\"\" class=\"wp-image-12691\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop-1024x495.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop-300x145.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop-768x371.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop-1536x742.jpg 1536w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop-1568x757.jpg 1568w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_loop.jpg 1592w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.4 Scicos Schematic for Costas Loop Demodulation BPSK PN Data A<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"613\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_data1-1024x613.jpg\" alt=\"\" class=\"wp-image-12694\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_data1-1024x613.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_data1-300x180.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_data1-768x460.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_data1.jpg 1524w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.5 Costas Loop Demodulated PN Data<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"619\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_dataa-1024x619.jpg\" alt=\"\" class=\"wp-image-12675\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_dataa-1024x619.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_dataa-300x181.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_dataa-768x464.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/costas_dataa.jpg 1517w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.6 Close Up Costas Demodulated PN Data<\/figcaption><\/figure>\n\n\n\n<p>Figure 4 shows a Scicos Schematic for a Costas Loop BPSK demodulator. Following the derivation in <a href=\"https:\/\/www.amazon.ca\/dp\/0071412018\/\">Ref.3<\/a>, assume that the VCO is almost locked to the incoming carrier with a small phase error of e. On the I branch:<br>m(t)cos(wct)*cos(wct+e)=0.5m(t)[cos(e)+cos(2wct+e)] <br>After the LPF (removes 2wct component):<br>m(t)cos(wct)*cos(wct+e)=0.5*m(t), (cos(e)=1 for small e)<br>On the Q branch:<br>m(t)cos(wct)*sin(wct)=0.5m(t)[sin(e)+sin(2wct+e)]<br>After the LPF (removes the 2wct component):<br>m(t)cos(wct)*sin(wct+e)=0.5m(t)sin(e)<br>On the VCO branch:<br>0.5m(t)cos(e)*0.5m(t)sin(e)=0.25(m(t)^2)sin(2e)<br>The VCO LPF picks out the DC component to drive the VCO. <br>Figures 5 &amp; 6 show the demodulated BPSK data waveform identical to what was sent. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Squaring Loop Scicos Simulation<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"308\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop-1024x308.jpg\" alt=\"\" class=\"wp-image-12703\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop-1024x308.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop-300x90.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop-768x231.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop-1536x463.jpg 1536w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop-1568x472.jpg 1568w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop.jpg 1892w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.7 Squaring Loop for Carrier Recovery &amp; Data Demodulation<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"625\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop_data_demod-1024x625.jpg\" alt=\"\" class=\"wp-image-12704\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop_data_demod-1024x625.jpg 1024w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop_data_demod-300x183.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop_data_demod-768x469.jpg 768w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/squaring_loop_data_demod.jpg 1521w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig.8 Squaring Loop Demodulation PN Data<\/figcaption><\/figure>\n\n\n\n<p>Figure 7 shows the Squaring Loop used for carrier recovery and data demodulation. The input signal is first squared:<br>[m(t)*coswct]^2=0.5*([m(t)]^2 + cos(2wct))<br>Thus this gives a low frequency component plus a perfect carrier at twice wc. This is then Band Pass Filtered to give just the carrier component at 2wc. Finally this is divided by 2 (not so easy!!!!) to yield a perfect version of the received carrier. Recall that the transmit spectrum had no discrete line at Fc! This recovered carrier now multiplies the input received signal and Low Pass Filtered to remove m(t)\/2 as in the Costas Loop I Branch. Figure 8 shows the data recovery identical to what was transmitted.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Carrier Synchronization with Costas &amp; Squaring Loops - Simulation\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/bCFfBecBG18?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">Fig.9 YouTube Video Carrier Sync with Costas &amp; Squaring Loops &#8211; Simulation<\/figcaption><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/jeremyclark.ca\/wp\/blog-topics\/\"><img loading=\"lazy\" decoding=\"async\" width=\"928\" height=\"360\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/scicos.jpg\" alt=\"\" class=\"wp-image-12710\" style=\"aspect-ratio:2.577827885242728;width:486px;height:auto\" srcset=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/scicos.jpg 928w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/scicos-300x116.jpg 300w, https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2025\/12\/scicos-768x298.jpg 768w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><\/a><figcaption class=\"wp-element-caption\">ScicosLab\/Scicos Blog Topics<\/figcaption><\/figure>\n<\/div>\n\n\n<p><a href=\"https:\/\/www.clarktelecommunications.com\/simulation.htm\">Learn Telecommunications by Simulation<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.clarktelecommunications.com\/simulation.htm\">HF Radio Telecommunications Learn by Simulation<\/a><\/p>\n\n\n\n<p>Please send your comments, questions and suggestions to:<br><a href=\"https:\/\/jeremyclark.ca\/wp\/contact\">contact:<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.youtube.com\/user\/clarktelecom\"><img loading=\"lazy\" decoding=\"async\" width=\"93\" height=\"98\" src=\"https:\/\/jeremyclark.ca\/wp\/wp-content\/uploads\/2020\/01\/youtube.jpg\" alt=\"YouTube Channel\" class=\"wp-image-687\"\/><\/a><figcaption class=\"wp-element-caption\">YouTube Channel<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<p>#1. &#8211; &#8220;HF High Frequency Radio Telecommunications Learn by Simulation&#8221;<br><a href=\"https:\/\/www.clarktelecommunications.com\/simulation.htm\">https:\/\/www.clarktelecommunications.com\/simulation.htm<\/a><br><br>#2. &#8211; &#8220;Satellite QPSK\/OQPSK Simulation &#8220;<br><a href=\"https:\/\/jeremyclark.ca\/wp\/telecom\/satellite-qpsk-oqpsk-simulation\/\">https:\/\/jeremyclark.ca\/wp\/telecom\/satellite-qpsk-oqpsk-simulation\/<\/a><br><br>#3. &#8211; &#8220;Phase-Locked Loops Design &amp; Applications&#8221;, 5th Edition, Roland E. Best<br><a href=\"https:\/\/www.amazon.ca\/Phase-Locked-Loops-Roland-Best\/dp\/0071412018\/ref=sr_1_7?dib=eyJ2IjoiMSJ9.7mMBrmqtE3fISp84n4MU5hlid0HidCe8yv4-KiMdczxFGqhluOzwY7RCVbSEf10vcdO3q8AkditIy8XqKyJhfQ.3hurebhWGKAU6tiRkEptqBZiVmYoPoaoWpHVr3ohm5A&amp;dib_tag=se&amp;keywords=Roland+E.+Best&amp;qid=1766350121&amp;sr=8-7\">https:\/\/www.amazon.ca\/dp\/0071412018\/<\/a><br><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Costas &amp; Squaring Loops are key components in reception of Telecommunication Signals. They are used to synchronize a local generated carrier with an incoming received carrier. We can simulate and study their operation using Scicos (Ref.1). First we generate a BPSK waveform at R=100bit\/sec to use with our two Demodulators (Ref.2). BPSK Waveform Generation&hellip; <a class=\"more-link\" href=\"https:\/\/jeremyclark.ca\/wp\/telecom\/carrier-synchronization-with-costas-squaring-loops-simulation\/\">Continue reading <span class=\"screen-reader-text\">Carrier Synchronization with Costas &amp; Squaring Loops -Simulation<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":12638,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4],"tags":[],"class_list":["post-12590","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-elec","category-telecom","entry"],"_links":{"self":[{"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/posts\/12590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/comments?post=12590"}],"version-history":[{"count":36,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/posts\/12590\/revisions"}],"predecessor-version":[{"id":12713,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/posts\/12590\/revisions\/12713"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/media\/12638"}],"wp:attachment":[{"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/media?parent=12590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/categories?post=12590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremyclark.ca\/wp\/wp-json\/wp\/v2\/tags?post=12590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}