{"id":770,"date":"2013-02-25T00:39:22","date_gmt":"2013-02-24T23:39:22","guid":{"rendered":"http:\/\/majek.mamy.to\/?p=770"},"modified":"2013-07-02T22:10:15","modified_gmt":"2013-07-02T20:10:15","slug":"logic-analyzer","status":"publish","type":"post","link":"https:\/\/majek.sh\/en\/logic-analyzer\/","title":{"rendered":"Logic analyzer"},"content":{"rendered":"<p>This time there will be a combined article &#8211; something about my new toy: logic analyzer, but also there will be introduction to diversity video receiver.<\/p>\n<h1>Logic analyzer<\/h1>\n<p>If you do anything with digital equipment or diy projects etc, logic analyzer could be very helpful tool for debugging. It&#8217;s great also for reverse engineering \ud83d\ude42<br \/>\nFrom some time I had in my mind <a href=\"http:\/\/tfla-01.berlios.de\/\" target=\"_blank\">The Fabulous Logic Analyzer<\/a> but parallel port is not what is available in modern laptops \ud83d\ude41<br \/>\nThen I saw how <a href=\"http:\/\/www.saleae.com\/logic16\" target=\"_blank\">Saleae Logic16<\/a> works:-) It was impressive, especialy that it works also under Linux. But 100-200 euros are a little over my budget for new toy, so I started searching for affordable alternatives. After some digging on the Internet, I found that old Saleae Logic, CWAV USBee SX and other cheaper logic analyzers are based on Cypress CY7C68013A chip and have almost nothing more than this chip alone. So, I found on Ebay <em>Lcsoft CY7C68013A Mini Board<\/em> prototyping board at less than $12 and now I have one \ud83d\ude42<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer1-640x396.jpg\" alt=\"LCSoft Cypress prototyping board\" width=\"640\" height=\"396\" class=\"alignnone size-medium wp-image-773\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer1-640x396.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer1-150x92.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer1.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>It&#8217;s not compatible with Saleae despite of programmed USB VID\/PID. But because I try to use opensource where possible, so my only choice was <a href=\"http:\/\/sigrok.org\" target=\"_blank\">Sigrok<\/a>.<br \/>\nAfter getting hard time to meet Sigrok dependency (Python3, sdcc and other unusual software), it compiled and started to run. Sigrok comes with it&#8217;s own firmware for Cypress chip, so no pirating here:-) <\/p>\n<p>It&#8217;s even better, because Lcsoft board has jumper to switch between &#8216;Saleae mode&#8217; and &#8216;Cypress Development Kit&#8217;.<br \/>\nIn Saleae compatible mode, Sigrok uploads standard firmware, so only 8 inputs are available at 24MHz sample rate.<br \/>\nBut when we switch to &#8216;native&#8217; mode, we have logic analyzer with 16 inputs \ud83d\ude42 Of course 16 bit sampling is not available at 24MHz but when we narrow count of inputs up to 8, full sample rate is still available.<\/p>\n<p>Sigrok is quite new project, so gui is not it&#8217;s strong side, but at least there is possibility to sample and look at waveforms, and that&#8217;s all &#8211; even saving of sampled data is not available in gui \ud83d\ude41<br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/pulseview.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/pulseview-640x417.png\" alt=\"Sigrok&#039;s Pulseview\" width=\"640\" height=\"417\" class=\"alignnone size-medium wp-image-776\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/pulseview-640x417.png 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/pulseview-150x97.png 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/pulseview.png 889w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>On the contrary, command line <strong>sigrok_cli<\/strong> is quite powerful.<\/p>\n<h1>Analyzing video receiver<\/h1>\n<p>So, it&#8217;s time to analyze something, and standard video receiver which comes with Fox700 transmitter as bundle is ideal for it \ud83d\ude42<br \/>\nI was wondering from some time what exactly happens on i2c bus, ie. how tuner is programmed for specific frequency, and an opportunity to get it known arrived \ud83d\ude42<\/p>\n<p><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/video-receiver.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/video-receiver-640x480.jpg\" alt=\"Standard 1.2GHz video receiver\" width=\"640\" height=\"480\" class=\"alignnone size-medium wp-image-779\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/video-receiver-640x480.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/video-receiver-150x112.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/video-receiver.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><br \/>\n<a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer2-622x480.jpg\" alt=\"Logic analyzer and video receiver\" width=\"622\" height=\"480\" class=\"alignnone size-medium wp-image-782\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer2-622x480.jpg 622w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer2-150x115.jpg 150w, https:\/\/majek.sh\/wp-content\/uploads\/2013\/02\/analyzer2.jpg 1024w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<p>As you can see on the above pictures, I added simple level converters with resistors and Zener diodes. It&#8217;s because logic of video receiver is 5V and Cypress is 3.3V chip. Of course I tried without Zener diodes, but weird things were happening \ud83d\ude42<\/p>\n<p>Sampling with <strong>sigrok_cli<\/strong>:<\/p>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;\"><div class=\"text codecolorer\">$ sigrok-cli --driver fx2lafw --device samplerate=24000000 --time 1s -p 0-7<br \/>\nlibsigrok 0.2.0<br \/>\nAcquisition with 8\/16 probes at 24 MHz<br \/>\n0:00000000 00000000 00000000 00000000<br \/>\n1:00000000 00000000 00000000 00000000<br \/>\n2:00000000 00000000 00000000 00000000<br \/>\n3:11111111 11111111 11111111 11111111<br \/>\n4:11111111 11111111 11111111 11111111<br \/>\n5:11111111 11111111 11111111 11111111<br \/>\n6:11111111 11111111 11111111 11111111<br \/>\n7:11111111 11111111 11111111 11111111<\/div><\/div>\n<p>Ones and zeros are fine, but real power of Sigrok is ability to decode protocols:<\/p>\n<div class=\"codecolorer-container text railscasts\" style=\"overflow:auto;white-space:nowrap;width:550px;height:300px;\"><div class=\"text codecolorer\">$ sigrok-cli --driver fx2lafw --device samplerate=24000000 --time 10s -p 0-7 -o test.sr<br \/>\n$ sigrok-cli -i test.sr -a i2c:sda=0:scl=1<br \/>\ni2c: &quot;START&quot; <br \/>\ni2c: &quot;ADDRESS WRITE&quot; &quot;0x68&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;DATA WRITE&quot; &quot;0x05&quot; <br \/>\ni2c: &quot;NACK&quot; <br \/>\ni2c: &quot;STOP&quot; <br \/>\ni2c: &quot;START&quot; <br \/>\ni2c: &quot;ADDRESS READ&quot; &quot;0x50&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;DATA READ&quot; &quot;0x00&quot; <br \/>\ni2c: &quot;NACK&quot; <br \/>\ni2c: &quot;STOP&quot; <br \/>\ni2c: &quot;START&quot; <br \/>\ni2c: &quot;ADDRESS WRITE&quot; &quot;0x61&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;DATA WRITE&quot; &quot;0x2b&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;DATA WRITE&quot; &quot;0x6c&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;DATA WRITE&quot; &quot;0x8e&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;DATA WRITE&quot; &quot;0xf0&quot; <br \/>\ni2c: &quot;ACK&quot; <br \/>\ni2c: &quot;STOP&quot;<\/div><\/div>\n<p>Initial write and read are some junk, I think that chip used for programming tuner, had originally other purpose and peripherials, but what is really interesting is data written at address 0x61.<br \/>\nAccording to documentation of SP5055 (synthesizer used on most tuners), 0x61 is it&#8217;s &#8216;always valid&#8217; address, despite of signal on address settings pin, so it always works.<br \/>\nDuring that write there are 4 bytes transferred: 2 bytes of divider (unique for each selected channel), and 2 bytes for setting state of chip and external outputs (always the same).<\/p>\n<p>So, let&#8217;s check what tuned frequency should be.<\/p>\n<p>Divisor is 0x2b6c (MSB is transferred first) = 11116<\/p>\n<p>According to datasheet, tuned frequency is:<br \/>\n<em>f = divisor * 16 * Fcomp<\/em><br \/>\nFcomp is frequency of quarz or external generator (typically 4MHz) divided by 512, so:<br \/>\n<em>f = divisor * 16 * 4000000 \/ 512<\/em><\/p>\n<p>In this case synthesizer is tuned to 1389500000Hz = 1389.5MHz<br \/>\nBut that&#8217;s not the end &#8211; we must substract intermediate frequency 479.5MHz of tuner.<br \/>\nSo, in fact we are tuned to 910MHz and this is exactly a <strong>0<\/strong> channel which was set on this receiver during test.<\/p>\n<p>Success! \ud83d\ude42<\/p>\n<p>One thing I&#8217;m missing in <strong>sigrok_cli<\/strong> is lack of timestamps (number of samples could be shown using -v flag), but it&#8217;s open source and everyone could add this (maybe even I) \ud83d\ude09<\/p>\n<p>Right now, when I know how to control tuner in receiver, I could make my own controller.<br \/>\nWhy? Because documentation of SP5055 and some tuners shows that there is possibility to read also some data from tuner. Most interesting is little ADC connected typically to circuit that shows offset between set and receiving frequency. With this information it&#8217;s possible to automatically fine tune to exact frequency. It&#8217;s also possible to follow frequency change while transmitter warms up. And of course it&#8217;s possible to tune to any frequency in tuner range with 125kHz step \ud83d\ude09<br \/>\nTuning multiple tuners at once isn&#8217;t also a problem, so making simple diversity based on video rssi it&#8217;s also possible,<br \/>\n<\/p>","protected":false},"excerpt":{"rendered":"<p>This time there will be a combined article &#8211; something about my new toy: logic analyzer, but also there will be introduction to diversity video receiver. Logic analyzer If you do anything with digital equipment or diy projects etc, logic <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/majek.sh\/en\/logic-analyzer\/\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,5],"tags":[24,11,48,47,46,49],"_links":{"self":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/770"}],"collection":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":46,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/770\/revisions"}],"predecessor-version":[{"id":1073,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/770\/revisions\/1073"}],"wp:attachment":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/categories?post=770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/tags?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}