Difficulties I ran into during development

This is a summary of the most frustrating things I suffered during development of this project. So far. It's all probably just proof that I'm not built for hardware. No, I don't own a real oscilloscope. But I do have a nice soldering iron.

I2C

I started out using an MKR1000, a $40 microcontroller that's quite a bit more capable than the ESP8266. But I had no end of troubles making its I2C work. I could maybe, sometimes, get one device working on the I2C bus, but adding more devices was impossible. Yes, I tried calculating the correct pullup values, I decorated the breadboard with resistors, I tried everything.

It's possible that my MKR board was bad, I dunno.

But the first time I hooked it up with an ESP8266 everything just worked. Didn't even need the pullups. Can't argue with cheaper & easier.

Hall Sensor Interrupts

I originally designed the code to be interrupt-triggered on an edge with the hall sensor. This worked great - but in a quest to accurately calculate BDC I discovered that the window of time that the hall sensor was triggered was substantial - about 5000 ticks of the 32Khz clock. And in order to calculate BDC correctly I needed to take that into account.

                       3
         xxxxxxxxxxxxa
      xx            aaaaa
    xx             aaaaaaa
   x              aaaaaaaaa
  xx            aaaaaaaaaaax  2
  x            aaaaaaaa    x
 xx           aaaaa         x
 x  long      abbb   short  x
 x             bbbbbb       x
 xx             bbbbbbbb    x
  xx             bbbbbbbbbbx
   xx             bbbbbbbbb   1
     xx            bbbbbbb
       xx           bbbbb
         xxxxxxxxxxxxb
                    0
            ---->

In the diagram, I was only detecting 1 and 3. By using CHANGE, I can detect 0 & 2 as well, enabling me to orient myself in the phase diagram and compute BDC (the top of the circle) exactly.

Simple, right? Simply set the interrupt trigger to CHANGE rather than RISING/FALLING, and I'll get an interrupt as it enters the zone, and another when it leaves the zone.

Like the worst of bugs, this almost works. This issue tortured me for about two months. See, it randomly loses interrupts. No idea why. How can it lose an interrupt you say? Doesn't it know when it transitions from HIGH to LOW and vice versa? Well, maybe? It would just randomly drop an interrupt every 100 or so swings.

I tested everything. I turned the wifi radio off. I added capacitors. I removed all the other components. I disconnected the coil. Nothing would make it stop. I'm convinced it's a problem with the ESP8266, or the library code.

I tried writing code to catch these missing interrupts. I measured the value of the pin in the interrupt, and if it didn't make sense I can make a good guess as to which event it lost, and synthesize it in the event stream.

That almost worked. The clock once ran for two weeks with thousands of lost interrupts, and I thought all was good. Then it lost two interrupts in a row. Faced with an ever-increasing tower of stupid compensation I gave up, and returned to using a RISING interrupt.

Rather than calculating BDC directly, I'm using a scheme where I test the response to impulses until I find the right delay that gives me the biggest increase in amplitude. Then I dial down the pulse length to a minimum functional value.

Fritzing

I started with fritzing because it's free, it's cool, and all the breadboard diagrams you see on the net are generated by it.

Once I dug in and learned how to use it, I discovered:

1) not all the common parts are available. 2) learning to make your own parts is harder than learning Rust.

I soldiered on, with a NodeMCU part I found on the net. I sent the board off to manufacturing. It came back, after about a month. Where the microcontroller went, it had tiny little holes. Like, so small the pins would not fit in the holes.

I went back and found the forum thread where I got my NodeMCU part... oooooh, someone else noticed the same problem. Oops, use a newer version. Or rather, scour the net for a completely different version that's known to work well.

Second time was a charm. The newer part worked, and my board is pulsing away as I write this. But - the situation with parts is Not Good.

I've since learned FRIENDS DON'T LET FRIENDS USE FRITZING

... and that I probably need to learn KiCad.

Manufacturing

Another complaint: the associated board printer, the one you get when you click "Manufacture" in Fritzing, is "Aisling", based in Texas. I know most of the cheap/fast PCB outfits are in China, and I was hoping for a faster turnaround.

aside: this is really stupid, I live in San Jose and I know there are hundreds of EMS companies around me - I have T-shirts! - but I've no idea how to get a quick prototype out of them.

Anyway, my complaint is thus: they sent me notifications: that my board was "in manufacturing" in a reasonable number of days - like 5 working days. That's fine. Then they printed a USPS label. Then it sat in that state for a week or two - I have a tracking number, but USPS says they haven't seen it yet. Then, when it got to USPS it sat around for another week before it was actually mailed to me. Total time on the second order: 17 days.

It's as if I chose some kind of 'punitive level' of delivery.