Ramblings
Building without structure - HP-41CV
Problem statement
Part of the process in an industrial company that I worked for inolved converting the crystalline state, A, of a chemical compound to another state, R, through a process known as calcination. Calcination involved heating the compound to temperatures in excess of 800°C.
The final product needed to be approximately 95% in state R. More than this would result in a compound that was too hard to be used by downstream manufacturers, while less than this meant the compound lost its required properties. The temperature during calcination was therefore critical.
The temperature of the calciner was controlled largely by guesswork, based on the operator's experience. A poor decision could result in losses of millions of rands by the company.
Samples from the output of the calciner were taken at regular intervals. Using X-ray spectroscopy, the proportion of the material in crystalline state R could be determined. Based on this result, the operator would decide whether to adjust the calciner temperature using a graph of %R versus temperature as a guide.
A sketch graph showing the change in %R with increasing temperature (sketch courtesy of Francois)
The biggest problem with this process was the human element. Aware of the potentially severe cost implications, the operator could panic and either over- or under-compensate when adjusting the fuel input to the calciner, often worsening the situation rather than correcting it.
Although feedback loops for the process had already been defined in theory, implementing them at the time was neither simple nor inexpensive.
I was given the task of creating an algorithmic approach to solving this problem, which the plant operators could understand. One of the conditions was that the feedback loop should be included.
Solving the problem
The biggest difficulty was trying to create a paper-based solution that plant operators could understand and use within their own frame of reference. Having worked with them, in their environment, it was immediately clear that expecting someone to follow a book of instructions - particularly under pressure - was unrealistic. Something simpler was needed.
I knew that that my manager, who had passed the task on to me, had an HP-41CV programmable calculator as part of his perks. From earlier work using an HP67 to solve least squares fitting problems, I thought his HP-41CV could be put to better use than just a calculator. I just had to convince him that it could be useful fo this project.
The core of the problem was how to represent the curve shown above within the calculator. There was insufficient storage to hold a point-by-point data structure, and I did not know the formula for the partial sigmoid function that described the curve.
The simplest practical approach was therefore to approximate the curve using a series of straight-line segments. For each segment, the slope and y-intercept could be calculated in advance. These values could then be stored in a small look-up table, allowing either %R or temperature to be determined using the appropriate linear equation for the relevant segment.
The calculator was more than capable handling this relatively simple task.
Surprisingly few line segments were necessary to represent the curve, with the bulk of them being in the vicinity of the asymptote where the curve began to flatten, as this region was critical for controlling the calciner.
Input to the program consisted of the current calciner temperature and the measured value of %R. The feedback calculation used these values, in conjunction with previous values, to determine the appropriate temperature adjustment. Previously predicted changes were also considered to assess their effect on the current temperature.
Testing was difficult as management were not keen on using this system based on predictions from a calculator to control the calciner. What we did, was to offer the operator suggestions as to what temperature changes to make. This worked successfully, and the operators began trusting the recommended changes. After a week of testing, management made the decision that one of the two calciners should be fully controlled using predictions from the HP-41CV.
This was so successful, that management decided to purchase a second HP-41CV for the second calciner within a month of the project going on-line. They also approved the purchase of a card reader attachment so that the program could be transferred between the two calculators.
What was satisfying was that the program worked, out-the-box, with no debugging once it got to the plant floor.
Some reflections
- The HP-41C family of programmable calculators was remarkably capable for its time;
- The alphanumeric display could be used to prompt the operator for specific inputs, reducing ambiguity and error;
- Although the programming model was closer to assembler than to modern high-level languages, it nevertheless supported procedural decomposition;
- The ability to structure the program into procedures changed how I approached the problem, encouraging a far more disciplined and systematic solution than the title might suggest.
What surprised me most was not what the calculator could do, but how much discipline it demanded in return.
Useful reading
- An overview of the HP-41 series programmable calculators
- Information on programming the HP-41 series.
(6 January 2026)
Back to the Accidental Programmer
