By turns: tinker, engineer, husband, author, amateur raconteur, recumbent cyclist, father, ham radio geek. So many projects, so little time!
DDS frequency: 180000000.0000000 Hz epsilon: 0.0000001 Hz step: 0.0419095 Hz Center frequency: 146520000.0000000 Hz 146520000.0000001 Hz 146520000.0000002 Hz 146520000.0000003 Hz 146520000.0000004 Hz 146520000.0000004 Hz 146520000.0000005 Hz 146520000.0000006 Hz 146520000.0000007 Hz 146520000.0000008 Hz 146520000.0000009 Hz 146520000.0000010 Hz ... snippage ... 146520000.0000099 Hz 146520000.0000100 Hz 146520000.0419195 Hz 146520000.0838290 Hz 146520000.1257386 Hz 146520000.1676481 Hz 146520000.2095576 Hz 146520000.2514671 Hz 146520000.2933766 Hz 146520000.3352861 Hz 146520000.3771957 Hz 146520000.4191052 Hz 146520000.4610147 Hz 146520000.5029242 Hz 146520000.5448337 Hz 146520000.5867432 Hz 146520000.6286528 Hz 146520000.6705623 Hz 146520000.7124718 Hz 146520000.7543813 Hz 146520000.7962908 Hz 146520000.8382003 Hz 146520000.8801098 Hz 146520000.9220194 Hz 146520000.9639289 Hz 146520001.0058384 Hz 146520001.0477479 Hz 146520001.0896574 Hz 146520001.1315669 Hz 146520001.1734765 Hz
Which comes from a PJRC Teensy 3.6 running this code:
double DDSFreq, EpsilonFreq, DDSStepFreq; double CenterFreq, TestFreq; ... in setup() ... DDSFreq = 180.0e6; EpsilonFreq = 1.0e-7; DDSStepFreq = DDSFreq / (1LL << 32); Serial.printf("DDS frequency: %18.7f Hz\n",DDSFreq); Serial.printf(" epsilon: %18.7f Hz\n",EpsilonFreq); Serial.printf(" step: %18.7f Hz\n\n",DDSStepFreq); CenterFreq = 146520000.0; TestFreq = CenterFreq; Serial.printf("Center frequency: %18.7f Hz\n",CenterFreq); ... in loop() ... if (TestFreq < (CenterFreq + 100*EpsilonFreq)) TestFreq += EpsilonFreq; else TestFreq += DDSStepFreq; Serial.printf(" %18.7f Hz\n",TestFreq);
The IEEE-754 spec says a
double floating-point variable carries about 15.9 decimal digits, which agrees with the 9 integer + 7 fraction digits. The
highlight lowlight (gray bar) in the first figure shows the slight stumble where adding 1e-7 changes the sum, but not quite enough to affect the displayed fraction.
In round numbers, an increment of 1e-5 would work just fine:
146520000.0000100 Hz 146520000.0000200 Hz 146520000.0000300 Hz 146520000.0000401 Hz 146520000.0000501 Hz 146520000.0000601 Hz 146520000.0000701 Hz 146520000.0000801 Hz 146520000.0000901 Hz 146520000.0001001 Hz 146520000.0001101 Hz 146520000.0001202 Hz 146520000.0001302 Hz 146520000.0001402 Hz 146520000.0001502 Hz 146520000.0001602 Hz 146520000.0001702 Hz 146520000.0001802 Hz 146520000.0001903 Hz 146520000.0002003 Hz 146520000.0002103 Hz 146520000.0002203 Hz 146520000.0002303 Hz
You’d use the “smallest of all”
epsilon in a multiplied increment, perhaps to tick a value based on a knob or some such. Fine-tuning a VHF frequency with millihertz steps probably doesn’t make much practical sense.
Posted in Machine Shop on 2018-04-18
Drilling a pair of holes into a length of ground steel shaft turned it into a holder for a Sakura Micron pen:
The aluminum ring epoxied to the top keeps it from falling completely through the linear bearing.
The hole sizes are the nearest inch drills matching the pen’s hard metric sizes:
While I was at the lathe, I turned another layer of epoxy on the printed holder down to a consistent 11.95+ OD. It fits the bearing nearly as well as the steel shaft, although it’s not quite as smooth.
The steel version weighs about 20 g with the pen, so it applies about the same downforce on the pen nib as the HP 7475A plotter. The force varies from about 19 g as the Z axis moves upward to 23 g as it move downward, so the stiction amounts to less than 10% of the weight:
However, the more I ponder this setup, the less I like it.
When the Z-axis moves downward and the nib hits the paper, it must decelerate the weight of the pen + holder + ballast within a fraction of a millimeter, without crushing the nib. If the pen moves downward at 3000 mm/min = 50 mm/s, stopping in 0.3 mm requires an acceleration of 4.2 m/s² and a 20 g = 2/3 oz mass will apply 0.08 N = 0.3 oz to the nib. Seems survivable, but smashing the tip a few hundred times while drawing the legends can’t possibly be good for it.
Also, the tool length probe switch trips at 60 (-ish) g, which means the pen can’t activate the switch. Adding a manual latch seems absurd, but you can get used to anything if you do it enough.
Smoking bacon during the winter months brought the third tank into play, requiring the POL-to-QD adapter I’d had in the drawer for just such an occasion. Not much to my surprise, the old PLA fitting adapter snapped along the layers near the outside end of the triangular snout:
So I ran off the two orange ones in PETG with six perimeter layers and 50% infill density:
Those should last roughly forever …
The OpenSCAD source code as a GitHub Gist:
Adding delays around the SPI control signal changes reduced the OLED glitch rate from maybe a few a week to once a week, but didn’t completely solve the problem.
However, (nearly) all the remaining glitches seem to occur while writing a single row of pixels, which trashes the rest of the display and resolves on the next track update. That suggests slowing the timing during the initial hardware setup did change the results.
Another look at the Luma code showed I missed the Chip Enable (a.k.a. Chip Select in the SH1106 doc) change in
def _write_bytes(self, data): gpio = self._gpio if self._CE: time.sleep(1.0e-3) gpio.output(self._CE, gpio.LOW) # Active low time.sleep(1.0e-3) for byte in data: for _ in range(8): gpio.output(self._SDA, byte & 0x80) gpio.output(self._SCLK, gpio.HIGH) byte <<= 1 gpio.output(self._SCLK, gpio.LOW) if self._CE: time.sleep(1.0e-3) gpio.output(self._CE, gpio.HIGH)
What remains unclear (to me, anyway) is how the code in Luma's
bitbang class interacts with the hardware-based SPI code in Python’s underlying
spidev library. I think what I just changed shouldn’t make any difference, because the code should be using the hardware driver, but the failure rate is now low enough I can’t be sure for another few weeks (and maybe not even then).
All this boils down to the Pi’s SPI hardware interface, which changes the CS output with setup / hold times measured in a few “core clock cycles”, which is way too fast for the SH1106. It seems there’s no control over CS timing, other than by changing the kernel’s bcm2708 driver code, which ain’t happening.
The Python library includes a
no_cs option, with the caveat it will “disable use of the chip select (although the driver may still own the CS pin)”.
Forcibly insisting on using Luma’s bitbang routine may be the only way to make this work, but I don’t yet know how to do that.
Obviously, I should code up a testcase to hammer the OLED and peer at the results on the oscilloscope: one careful observation outweighs a thousand opinions.
I have often kvetched about Amazon’s casual approach to packaging, so this took me completely by surprise:
There’s a 500 mm length of 16 mm round linear motion rod / shaft inside the small blue-and-white box. Previous shipments of similar rod have arrived in a lightly padded envelope or rattling loose in a box of other stuff.
The small blue-and-white corrugated cardboard box contains a bag protecting the well-oiled shaft, with padded end caps preventing the shaft from escaping or whacking against anything.
The middle box is made from two U-shaped sheets of molded (not corrugated) fiberboard, with one rigid U stapled into those wood end caps, the other U fitting over the assembly, and plenty of packing tape securing the two. Enough bubble wrap fills the cavity to surround and completely immobilize the inner box.
FedEx carried the armored box from Thomson to an Amazon warehouse in February, so it wasn’t packed specifically for me.
The upper box is a standard Amazon corrugated carton, with slightly more than a token amount of paper packed around the fiberboard box. The paper didn’t completely immobilize the middle box, but did serve to keep it from rattling loose.
I paid twenty bucks for the rod, with “free” Amazon Prime shipping, and UPS delivered it in the usual two days.
The whole affair weighs 7 pounds. If I were to reship it to somebody using UPS 2nd Day, they’d charge me $39 just for the shipping.
I felt unworthy …
On the other paw, Amazon recently sent a dozen LED lights with a casual disregard for protection:
Both ends of the carton were shredded, although all of the cardboard tubes and LED lamps remained still inside. Not all the tube end caps completed the journey, however.
The carton didn’t sport the usual Box Certificate mark found on all Amazon cartons and was made of brittle Chinese cardboard, so it was intended for protected shipping, perhaps inside a freight container, not as a business-to-consumer shipping box.
Somewhat to my surprise, all the LED lights worked, including several that shrugged off their tube caps, as in the upper right, or broke their white cardboard end plates, as in the rest. The plastic protectors on the LED pins served their purpose!
Amazon provided a partial refund when I filed Package Feedback, so they’re paying attention to damages.
Five pounds of granular erythritol fared better, with a token air pillow contributing nothing:
It makes ya wonder, it does …
Posted in Oddities on 2018-04-14
This one took us by surprise:
“As Advertised”, indeed, although the flyer got it right.
We mentioned it at the Meat Department and discovered they don’t print the signs, so Mary reported it to The Front Office.
It’s not as if I’ve never run afoul of a heterograph or perpetrated the occasional typo …
A control head from an ancient Brother BAS-311 sewing machine emerged from a recent Squidwrench clearing-out session:
The sturdy metal enclosure ought to be good for something, I thought, so I rescued it from the trash.
One of the ten button-head screws galled in place and resisted a few days of penetrating oil, so I drilled it out:
The PCB has no ICs! It simply routes all the LED and button pins through the pillar into the sewing machine controller:
The ribbon cable alternates the usual flat strip with sections of split conductors:
The split segments let it roll up into the pillar, with enough flexibility to allow rotating the head. I’ve seen segmented twisted-pair ribbon cable, but never just flat conductors.
Maybe the control head can become Art in its next life?