So, I’ve probably learned everything I can about electronics from this particular TTL build. For example, I now know what TTL stands for, what 5 volts tastes like, and what a pull-up resistor is. Mat knows that explaining things to a non-expert is haaaaard and that left alone I will do crazy things. So we’ve both learned.
The main board of Sparky is a horror of add-ons, re-mapping, remaking and coloured wires. At least the coloured wires are consistent. Orange for one side of the level we want, green for the other. However, I need to replace most of the bits of the main board with the Arduino.
The step-down needs to be done in hardware. I’m not running 40 volts through an Arduino, even to see what happens. The level comparisons can be done at 5 volts, and indeed it’ll be easier to do that then to twiddle analogue knobs. The first thing we’ll be finding out is whether we’re grounded. If the probe is touching the material, we want to move up. (If we can’t move up, for example because we just hit a switch and the material fell over on the probe, we probably want to cut off the spark circuit, but I’m not building relays into this.)
We want to avoid false positives, so we check a smoothed version of LVL. That smoothing is also done in hardware, with a capacitor.
If the probe isn’t touching the material, then we test to see if the smoothed LVL (see, we’re using the function, or at least a value we passed along) is 0. If so, we move down.
If neither of those things is the case, we leave well alone for Tau, where Tau is the period of the spark capacitor charging. Then we loop again.
‘move’ here is a function, which tells the stepper chip DIR, and then hits the STEP pin. I’m guessing we can do that in two lines of code, and the pause between them will be enough, but DIR might take a moment to wake up, and if that happens it can be dealt with.
So, the shape of it:
LVL + | +--Check not grounded -- if grounded move up then start loop again. | + Check not high -- if high, move down then start loop again. | + If nothing else, stay where you are for Tau then start loop again.
Things I’ll need:
- LVL measurement – this will expand the timing loop if we end up sampling repeatedly
- comparator function – /U and /D variables, vs LVL. Check that /U and /D are different and in the correct order – if no space between them, abort and complain.
- spark delay calculator/outer timing loop
- movement function
On the wishlist:
- Serial.print output in various formats
- M0 M1 M2 pins to be isolated with dipswitches. Whatever they are.
- more tea
 If I were going to be doing that, I’d use considerably higher voltage.