• No results found

f slop chop

7.2 Sensor Controller Software

E~

The software for the sensor controller consists of four functional blocks: the sensor input handling, the position decoding, the weight (data acquisition) and the in previous paragraph described Profibus protocol software. These blocks are all imbedded in the Main routine of the Sensor Controller.

See figure 7.1.

Figure 7.1: Sensor Controller Software

7.2.1 Sensor Input Handling

This part of the software consists of an interrupt-handling routine for the processing of all sensor inputs and encoder indications.

The sensor board can be equipped with up to 8 sensor inputs. These include inputs from the position encoders, proximity sensors for zero-position, stretch, displacement and weight indication.

Whenever an input changes (and the source is not masked) this is signalled by an interrupt from the glue. Also every change will be saved in a so-called 'glitch bitmap', this way every input glitch will be seen.

After the microcontroller receives the interrupt, it has to read the interrupt register in order to determine the interrupt's source. The interrupt is caused either by a change at one of the inputs, or by one of the encoder-counters.

After reading the interrupt register the source is known and either the input register or the counter register must be read. Also the appropriate interrupt flags must be cleared.

The input's information is updated in the SPC4 every time an interrupt from the inputs is received.

An intelligent sensor controller using Profibus

7.2.2 Decoder software

ELLIPS ~

The measurement of the cup-positions with the rotary encoder is done in hardware and in software, the hardware uses a 12 bit counter that indicates an interrupt whenever the defined hysteresis window is left. The real position counter is done in software so its range can be bigger than that of the hardware counter and is always extendible.

The software-part for the decoding of the cup-positions makes use of the interrupt-handling routine of the core software. After the determination of exiting the hysteresis of the counter, both the software-counter and hardware counters have to be adjusted.

Using a 32 bit counter in software should be sufficient for our application (1000 PPR, 100m, 20 cps, 10 cpr) since the total count can be represented by 20 bits.

Whenever the microcontroller receives a window based (upper or lower bound exceeded) interrupt, the software should add or subtract one window to/from the 32 bit counter and initiate the subtraction/addition of the window from/to the hardware counter.

An intelligent sensor controller using Profibus

7.2.3 Data Acquisition Software

E~

The software needed for the static weight measurement consists of procedures to write and read On-chip registers of the ADC. With these the ADC has to be calibrated, the mode of operation can be set and finally the measurement has to be initiated.

A state machine performs the weight acquisition, see figure below:

Figure 7.3: Weight machine

Outline:

The state machine always starts in idle mode and stays here until a 'START' -request for calibration or conversion (Get Samples) is received.

As can be seen the internal calibration is performed in two stages, first full-scale calibration then zero scale calibration is carried out. (This is done because the full-scale calibration alters the offset register.) System calibration is performed either by starting the full scale or the zero scale calibration, and again: after a full-scale calibration a zero scale calibration is needed.

An intelligent sensor controller using Profibus

E~

The ADC can be read out once, in single mode, or a defined number of times, in multiple mode. After the specified number of samples are read the SM goes back into Idle mode where it is ready for the next request. In burnout mode the ADC's internal current sources are applied to the inputs and a single measurement is carried out, this way the transducer can be checked against short-circuit or open circuit failures.

Every time the ADC has finished calibration or a valid conversion result is available the ADC generates an interrupt (RDY) to the microcontroller.

An interrupt handling routine takes care of the appropriate actions at every state of the weight machine and delivers the control signals in order to step through the weight machine.

These control signals are the START- and EO-signals as depicted in figure 7.3.

START indicates the beginning of an action and EO (controlled by interrupt handler) indicates the end of an action.

Table 7.1 summarises all control signals:

StartIntZeroCal EoIntZeroCal StartIntFullCal EoIntFullCal StartSysZeroCal EoSysZeroCal StartSysFullCal EoSysFullCal StartBurnOut

StartGetResults

EoBurnOut EoGetResults

Table 7.1: Control signals for the weight state machine

Next we will describe an implementation of the static weight measurement which can be used as a stand-alone application. We don't need to communicate with the Master computer, so this will relieve the Profibus.

An intelligent sensor controller using Profibus

E~

For the handling of a dedicated static weight measurement a state machine is used that makes use of the Sensor Full input, indicating a full weight-line and the start of measurements.

Next we will give a description of this state machine.

As already mentioned Sensor Full is used to indicate a full weighing-line. This is simply done by checking its pulsing, if the pulsing has stopped for longer than a specified time, the weight line should be full.

The state machine always starts in Idle mode, where it stays until the weighing line is loaded, Sensor Full located at the beginning of the line is interrupted every time a cup comes along. Since the end of the weighing line is closed with a valve, the fruit is lining up before it and in the end the sensor will stop pulsing, indicating a full weight line. Now the lines have to be stopped (delivery-line before weight line, think of fruit just falling of the edge). See figure 7.2.

After a certain debouncing time the weight measurement can be started. The handling of the weights is done by another state machine, see figure 7.3. At the end of each acquisition control is given back to the main state machine, that takes care of emptying the line and start allover again.

Sensor Full StopDeliveryLine StopWeightLine Debouncing=1

...

'.".

Debouncing ••••••••

StartGetResults

EriiPiYiii9

CloseValve SlartDeliveryLine

Figure 7.2: Sensor state machine for weight

An intelligent sensor controller using Profibus

ELLIPS ~

8. CONCLUSIONS & RECOMMENDATIONS