Re: Haven't done anything real with OOP yet.

From: Gregory L. Hansen (glhansen_at_steel.ucs.indiana.edu)
Date: 11/05/04


Date: Fri, 5 Nov 2004 03:20:11 +0000 (UTC)

In article <KWxid.1850$Re1.752@trndny05>,
H. S. Lahman <hsl@pathfindermda.com> wrote:
>Responding to Hansen...
>
>We are now mostly in the realm of satisfying my personal curiosity about
>the curiosity, so feel free to bail at any time.
>
>>>You are already committed to a
>>>7/60th second frequency (or whatever parameter the user supplies) for
>>>computing the beam values. You also have to employ a finer granularity
>>>for the heat flow calculations for whatever reasons.
>>
>>
>> Sampling time for the controller. The beam turns on and off on the order
>> of ten minutes or half an hour. The sampling time could in principle be
>> anything, but 7/60 reduces cross-talk with power lines.
>
>Wow, I really misunderstood that. I had the impression that this was a
>very small scale system and it was the beam {V, dt} that was being
>computed every 7/60th s in the Computer hardware element. [Tens of
>minutes as a time scale for photoemission spectroscopy just doesn't
>compute well for me. Last time I used a spectroscope the total "burn"
>was on the order of seconds. But that was a different context (petrology).]
>
>So now I am thoroughly confused about the sampling. Does this mean the
>Thermometer digitizes N error values per every 7/60th second? You also
>indicated that the filter's "out" is also digitized in Controller. Is
>that to a different frequency than Thermometer?
>
>I am also curious about the beam turning on/off every 600-1800 seconds
>when the sampling is done 3+ orders of magnitude faster. That seems
>like overkill. What am I missing?

Hmm... you seemed to talk a little funny about it, but I though I could
mostly catch what you were saying about the design, so I passed it off as
a difference in vocabulary.

The neutron beam is turned on and off with a Li-6 loaded shutter with a
period that's much longer than it takes the target to stabilize after a
change in state. Which was about ten minutes on, ten minutes off for the
solid target, 30 minutes for the liquid He-3 filled target. The power
required to keep the target temperature constant in both states is
measured, and the difference is the power that the beam deposits into the
target.

That's one user-adjustable time constant. The temperatures of both the
target and heatsink are monitored continuously by lock-in amplifiers. The
lock-ins have filters built in. The inputs are around 750 and 900 Hz AC
provided by a separate power supply. The lock-ins get reference signals
from the power supply and are, well, locked to the frequency, and invert
the amplification every half-cycle. So on the first half cycle the gain
might be G, on the second half-cycle -G, then G again. So the voltage
measured across the thermometer looks like abs(sin(wt)), always positive,
while the voltage from any other source-- noise-- is sometimes positive
and sometimes negative. (Across the bridge circuit, actually, so the sign
can change, but that's a refinement.) At that point it's still not very
useful. But averaging the signal will make the noise go away because of
the cancellation between positive and negative. That's done by the
filter; you don't have a lock-in amplifier unless you have a filter. The
filter time constant can be set on the panel, we typically use 3 seconds,
which is much longer than 1/750 seconds, and gives a clean DC output.
The filter time constant is user-adjustable by pushing buttons on the
front panel.

I don't know at what rate the lock-in can digitize and refresh its
output, but it's much faster than we'll ever need it. The computer reads
that voltage through a GPIB interface.

The sampling time is the rate at which the controller receives an error
signal from the lock-in, calculates a control action, and signals a DC
power supply to change its voltage, which goes to the heater resistor.
That's essentially where we go from continuous to discrete (barring the
much faster digitization of the lock-in). A four-lead measurement is
made to find the voltage across the heater, and also through a precision
resistor in series to determine the current, since I=V/R. Then the power
delivered is calculated as P=IV.

In an ideal world, the sampling time would be dag-nabbit fast. A coarse
sampling time tends to drive the system towards instability because the
state of the target could change between one sample and the next. That
has to be balanced against computing resources and (in the case of 7/60
seconds) sources of noise like 60 Hz power lines. But the thermal time
constant of the target is a few minutes, which spans hundreds of samples,
so that's a pretty good approximation to continuous control. If the
target's thermal time constant were one second, a sampling rate of 7/60
seconds could cause problems.

The control logic is PID-- terms Proportional to the error, the Integral
of the error, and the Derivative of the error are added up to determine
the control action. The control logic runs the proportional and
derivative terms through a digital filter to smooth out changes in the
output. The integral term is like an uber filter all by itself, and
doesn't need to be filtered again. So that's another filter, separate
from the one in the lock-in.

If you're highly motivated, I wrote it up.

  http://www.iucf.indiana.edu/~glhansen/smallthesis.pdf

As I was learning about control theory I got a brief introduction to the
Z-transform, which is for discretized math what the Laplace or Fourier
transforms are for continuous systems. And then it becomes possible to
design all manner of digital equivalents to RC filters and other analog
circuit elements. Some day I wanted to figure out how to make noise on my
computer, and play with sound processing.

>Does that range of on/off time refer to how long the beam is on or to
>the frequency at which the on/off decision is made? If the latter, that
>implies the on/off decision is not fixed in time (i.e., it depends upon
>something like the "out" values from the low-pass filter triggering some
>threshold).

The main loop in the data acquisition software looks something like:

  get TickCount
  if TickCount > NextVoltages
    calculate NextVoltages
    read voltages
    compute V and V^2 sums
  if TickCount > NextShutter
    calculate NextShutter
    move shutter
  if TickCount > NextHeater
    calculate NextHeater
    control heater
  if TickCount > NextHeatsink
    calculate NextHeatsink
' control heatsink
  if TickCount > NextCounter
    calculate NextCounter
    read counters
  if TickCount > NextUpdate
    calculate NextUpdate
    compute and save voltage averages and standard deviations
    update screen

I hope my pseudo-code is pretty clear. NextShutter, for instance, will be
the time, in ticks (1/60 seconds) that the state of the shutter will
change (it will be moved up or down, turning the beam on or off). And
calculating the next time to move the shutter is something like
NextShutter=CurrentShutter+ShutterInterval. And the same is true for the
other time constants.

I'm not sure if I remember it all, but there's at least the six time
constants. The thing with the voltages, for instance, is that they're
typically read every second, and the average and standard deviation saved
every minute, in the interest of saving disk space. Or in the recent
runs, every five seconds, since there was unexpected structure. Average
power is <VI> while our calculation of power was <V><I>, so we had to
increase the frequency of saves.

A salient point is that the loop isn't triggered every 60th of a second.
It runs through the loop continuously, as fast as it can. But the
scheduling of events occurs at a 60th second resolution.

>Finally, a thought that should have occurred to me earlier. If the
>filter in Controller is a low pass filter as you indicated, then why
>would 7/60th be relevant? Does this mean the filer inflection point is
>close to or above 60 Hz? My curiosity is that if it is significantly
>below 60 Hz (e.g., >= 60 db attenuation at 60 Hz), then it shouldn't
>matter what the sampling is unless the cables to the beam are really,
>really long or there is a power trunk line outside the window.

I'm not actually sure the 7/60 really does much to reduce talk from power
lines, it's just been the tradition, and there didn't seem to be much
reason to rethink it.

>
>[Back in my formative years I was a geophysicist doing deep crustal EM
>measurements. We were looking for signals ~2 mv on grounded dipoles up
>to two miles long. We laid out the wire on road shoulders, often right
>under power lines. I have measured 60 v of 60 Hz pickup riding on those
>dipoles. (I did that measurement after I spliced a line in the rain one
>day when I forgot my wire cutters and I stripped the wire with my teeth;

Back in those days, geophysicists were REAL men.

>it was a character building experience.) However, we had a very serious
>low pass filter so the 60 Hz pickup wasn't significant. The periods we
>were interested in were 0.000023 to 0.05.
>
>The magnetic side was even worse for noise because that natural magnetic
>field of the Earth is extremely weak. We were looking for ~2 uv
>variations coming out of 60K turns of wire around a Mu-metal core. (Now
>THAT's an inductor!)

Yeah, baby! We use it for magnetic shielding. But if you've ever checked
out the permeabilities on some of the MetGlas alloys... gracious. And the
price.

>We had to bury the rods 3' down because even a
>tiny breeze would drive the amp off scale. We once set up about a mile
>from a railroad line that we thought was no longer being used. About 3
>AM a freight train came through and it looked like we were logging a
>Richter 8.0 earthquake. But I digress...]
...
>>>BTW, are there really two Thermometers? If the feedback for both beam
>>>and pot is driven by cell temperature, wouldn't you only need one
>>>Thermometer? Or is temperature measured on each side of the cell?
>>
>>
>> Target and Heatsink are both seperately temperature controlled so that we
>> know the amount of heat flowing from Target to Heatsink remains constant.
>> That's important.
>
>I take it that means there /are/ two thermometers. B-) (The other
>possibility is that the control hardware/algorithm is different because
>of differences in conductivity, mass, etc. of the heatsink even though
>the computation is based on the same temperature input as the beam.)
>Just out of curiosity, where does the thermometer sense the heatsink
>temperature, on the heatsink itself, on its end of the link, on it side
>of the cell?

The thermometers on the target and heatsink are both right at the thermal
link, which itself is screwed on to the tops of bobbins that the signal
wires are wrapped around for heat sinking. But the weak link is still a
much stronger thermal link than hair-thin monel wires at 1.8 Kelvin.

-- 
"Things should be made as simple as possible -- but no simpler."
  -- Albert Einstein

Loading