{"id":6704,"date":"2018-11-04T20:42:17","date_gmt":"2018-11-05T02:42:17","guid":{"rendered":"http:\/\/w0ep.us\/OM\/?p=6704"},"modified":"2018-11-04T20:49:44","modified_gmt":"2018-11-05T02:49:44","slug":"ad9850-vfo-ish","status":"publish","type":"post","link":"http:\/\/w0ep.us\/OM\/?p=6704","title":{"rendered":"AD9850 VFO-ish"},"content":{"rendered":"<p>[Yesterday&#8217;s run: 6 miles]<\/p>\n<p>So!<\/p>\n<p>I had built this little box in 2014.\u00a0 It is an Arduino Nano controlling an ebay AD9850 board.<\/p>\n<p>I didn&#8217;t like it when I built it, so I put it up on the shelf.\u00a0 I took it down recently to use as a signal source to drive the non-working Belar modulation monitor.<\/p>\n<p>I decided to see if I could find newer software or some other thing which might make the signal source box more useful.<\/p>\n<p>The first problem was that my rotary knob was very funky acting.\u00a0 It clicks, and sometimes it would change a number when it clicked and sometimes not.\u00a0 I found a datasheet for exactly that gizmo.\u00a0 The thing is actually kind of pricey, not one of the cheaper on-line maker-store jobbies.\u00a0 It is an optical encoder but feels like a mechanical one.\u00a0 So I dug into the rotary encoder library for the Arduino.\u00a0 It turns out they divide the &#8220;clicks&#8221; by 4 in order to deal with switch bounce, I guess in mechanical encoders.\u00a0 If you have 360 transitions per revolution you can do that kind of thing.\u00a0 But mine is optical and something like 32 transitions per rev.\u00a0 So I was turning all day just to get the numbers to change.<\/p>\n<p>They had some code in the library for divide-by-two, which I tried.\u00a0 A great improvement but still not right, particularly if you change directions: after one click toward left it would take three clicks toward right to change a number.\u00a0 I wrote my own one-to-one section and that really relieved the situation.\u00a0 Now when it clicks the number\u00a0 changes.\u00a0 Much better.<\/p>\n<p>Seeing as how I have a pretty good frequency counter which is pretty well matched with my GPSDO frequency source, I next decided to see if I could measure any discrepancy between what the signal source says it is doing and what it is really doing.\u00a0 Long story short:\u00a0 it stunk!\u00a0 It was all over the place. At the top end of the range of this thing (30 MHz) it was off by tens of Hertz).<\/p>\n<p>Some of that is the fault of the\u00a0 little crystal which drives the chip.\u00a0 The thing says 125.0 MHz, but it isn&#8217;t.\u00a0 I fooled around with a spreadsheet to try to figure out the real crystal value and I made some progress on that.\u00a0 But it just didn&#8217;t seem like it helped as much as I expected it would.<\/p>\n<p>(One of the things one must do with crystal-driven things is let them warm up.\u00a0 So I left the gizmo on overnight.\u00a0 And I left the frequency counter on overnight too.)<\/p>\n<p>I looked at the data sheet for the AD9850.\u00a0 According to the specs, it is supposed to be able to tune small fractions of a Hertz.\u00a0 But the more I played with it, the more I was convinced something was wrong.\u00a0 It was!\u00a0 The Arduino has 32-bit numbers.\u00a0 The math to figure out the frequency &#8220;code-word&#8221; was doing some division and multiplication with very large numbers.\u00a0 A lot of the significant bits were dropping on the floor.\u00a0 That was why I could change the indication by full-Hertz values and nothing comparable would change in the actual output.<\/p>\n<p>I got started this afternoon on a plan.\u00a0 I&#8217;m figuring out by trial and error, with the help of a larger-precision calculator, the correct code-words to make each integer MHz value (1,000,000 Hz; 2,000,000 Hz; etc.) come out of the thing as close as I can get it\u00a0 (and I can usually get it down to a few tenths of a Hz).\u00a0 Then I can add the calculated kHz codeword to the as-figured-out\u00a0 MHz codeword and that should put me within 1 Hz at any place on the dial.\u00a0 I have about half of the 29 values figured out and I&#8217;ve proven the concept.\u00a0 I will have to tighten up my 0.0 &#8211; 1,000,000\u00a0 calculation a bit.\u00a0 But already I&#8217;m much tighter in the working range 1-13 MHz.<\/p>\n<p><a href=\"http:\/\/w0ep.us\/OM\/?attachment_id=6696\" rel=\"attachment wp-att-6696\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-6696\" src=\"http:\/\/w0ep.us\/OM\/wp-content\/uploads\/2018\/10\/signalsource.jpg\" alt=\"\" width=\"652\" height=\"869\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Yesterday&#8217;s run: 6 miles] So! I had built this little box in 2014.\u00a0 It is an Arduino Nano controlling an ebay AD9850 board. I didn&#8217;t like it when I built it, so I put it up on the shelf.\u00a0 I took it down recently to use as a signal source to drive the non-working Belar [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-6704","post","type-post","status-publish","format-standard","hentry","category-ham-radio"],"_links":{"self":[{"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=\/wp\/v2\/posts\/6704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6704"}],"version-history":[{"count":4,"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=\/wp\/v2\/posts\/6704\/revisions"}],"predecessor-version":[{"id":6708,"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=\/wp\/v2\/posts\/6704\/revisions\/6708"}],"wp:attachment":[{"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6704"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/w0ep.us\/OM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}