Advertisements

Ed

By turns: tinker, engineer, husband, author, amateur raconteur, recumbent cyclist, father, ham radio geek. So many projects, so little time!

Homepage: http://softsolder.com

Teensy 3.6 Double Precision Floats

Having spent a bit of effort wringing enough precision from an Arduino to make the 60 kHz quartz resonator tester, this came as a relief:

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.

The DDS frequency increment works out to 41.9095 mHz, slightly larger than with the Arduino, because it’s fot a cheap DDS eBay module with an AD9851 running a 180 MHz (6 × 30 MHz ) clock.

Advertisements

,

3 Comments

MPCNC: Ground Shaft Pen Holder

Drilling a pair of holes into a length of ground steel shaft turned it into a holder for a Sakura Micron pen:

DW660 Pen Holder - printed plastic vs ground steel

DW660 Pen Holder – printed plastic vs ground steel

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:

Ground 12 mm rod - Sakura pen drill diameters

Ground 12 mm rod – Sakura pen drill diameters

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:

DW660 Pen Holder - ground shaft

DW660 Pen Holder – ground shaft

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.

, , ,

6 Comments

Propane Tank QD Fitting Adapter, PETG Edition

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:

IMG_20180408_125018

IMG_20180408_125018

So I ran off the two orange ones in PETG with six perimeter layers and 50% infill density:

Propane QD Adapter Tool - Slic3r

Propane QD Adapter Tool – Slic3r

Those should last roughly forever …

The OpenSCAD source code as a GitHub Gist:

,

Leave a comment

Streaming Radio Player: CE Timing Tweak

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 serial.py:

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)”.

Running vcgencmd measure_clock core (usage and some commands) returns frequency(1)=250000000, which says a “core clock cycle” amounts to a whopping 4 ns.

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.

,

Leave a comment

Monthly Image: Amazon Packing

I have often kvetched about Amazon’s casual approach to packaging, so this took me completely by surprise:

Amazon packaging - 16 mm linear motion rod

Amazon packaging – 16 mm linear motion rod

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:

Amazon packaging - shredded LED lamp carton

Amazon packaging – shredded LED lamp carton

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:

Amazon packaging - 5 lb bag

Amazon packaging – 5 lb bag

It makes ya wonder, it does …

Leave a comment

Fresh … Foul?

This one took us by surprise:

Fresh Foul Meat

Fresh Foul Meat

“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 …

2 Comments

Brother BAS-311 Control Head Salvage

A control head from an ancient Brother BAS-311 sewing machine emerged from a recent Squidwrench clearing-out session:

Brother BAS-311 Control Head

Brother BAS-311 Control Head

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:

Drilled-out button screw head

Drilled-out button screw head

The PCB has no ICs! It simply routes all the LED and button pins through the pillar into the sewing machine controller:

Brother BAS-311 Control Head - interior

Brother BAS-311 Control Head – interior

The ribbon cable alternates the usual flat strip with sections of split conductors:

Segmented ribbon cable

Segmented ribbon cable

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?

Leave a comment