A small update. The bugs seem to have been worked out of the output ramping algorithm.



I spent a lot of time tracking down a bug wherein I mixed up the units of two variables. I track output internally as a percentage of max, so that the changes in output are independent of the welder's actual output range. But I also have to keep track of the actual voltage that I'm outputting, and somewhere in there, I mixed up a variable that holds one value for a variable that holds the other. Instead of setting output to 0.1 (10%), I tried to set it to 12 (1200%). Fortunately, my "set output" routine has bounds checking, and any value over 100% gets set to 100%. Any time you're sending voltage directly to hardware, put a lot of error checking in your code, kiddies...

The ramping algorithm takes as an argument two variables: a target percentage to move to, and a time period over which to move. I originally had a start and end value for the "ramp", but I realized that the start value should always be whatever the welder was currently set to. There should never be an abrupt jump in the signal that is being fed to the welder, even though the welder probably would handle such a thing gracefully. If a specific output value is required as a starting point, the right thing to do is to elect to move the welder's output to that value over a chosen, short period of time. Then, you're forced to input the short period of time explicitly; you can never inadvertently move the welder's output without specifying over what time period the move should happen.

Of course, you could always just specify 1 ms if you really wanted to, making the change effectively infinite.

The algorithm you see demonstrated here will form the backbone of the entire program. Every change in welder output will be done via this algorithm: upslope, downslope, pulsing, etc... At least that's the plan so far. So even though it's kind of boring in a way, it's also kind of exciting. It's like looking at the block of an engine and thinking about the car that's going to be built around it.