Display the Process Variable and Setpoint levels

When using the Pump Control System Application, it is sometimes nice to be able to display the Process Variables and Start and Stop Setpoints for both channels (or control loops) in LEDs.

Since this is a pre-defined System Application in the MIRTOS Operating System, "all" that's needed is to configure one System Variable and the 12-byte Control Structure to which it points. First, set EEbLevels_UVIndex in EEPROM to be the index of the first of the twelve (12) uVars.B[##] BYTEs to use.

The example below configures the BYTEs immediately after the sixteen (16) used by the Pump Control example. That makes EEbLevels_UVIndex = EEbPumpCtrl_UVIndex + 16 = 32 + 16 = 48, or 0x30. The Control Structure then starts at that uVars.B[ EEbLevels_UVIndex ] value in SRAM, which is SRAM address 0x2B0. Given that starting point, the following Control Structure may be configured:

OffsetVariable name  SRAM Address  Value   Description, usage, notes
0wDisplayInterval0x2B0 500Interval between output updates
2wLastUpdateTime0x2B2 mSecTimer starting millisecond value
4bBitmapped0x2B4 0x02Bitmapped, with only 5 bits utilized
BIT_PORT_00x2B4.0 2,
which
means
PORTC
The four (4) Low Order bits specify the
PORT on which to output the LED data:
1=PORTB, 2=PORTC, and 3=PORTD for a 328P
could be 0=PORTA to 10=PORTL for a 2560P
BIT_PORT_10x2B4.1
BIT_PORT_20x2B4.2
BIT_PORT_30x2B4.3
BIT__unused__40x2B4.4 0  These three
  (3) bits are
  not used
BIT__unused__50x2B4.5 0
BIT__unused__60x2B4.6 0
BIT_BOTTOM_UP0x2B4.7 0Display the level BOTTOM-UP, instead of TOP-DOWN
5bOutputPins0x2B5 0x1COutput PINS for the PORT above = B00011100
6bScalar0x2B6 10Divisor = 0-1023 AIn into 102 LEDs -> divide by 10
7bAnalogInput0x2B7 7Select Analog Input index = ADC7
8bOffset0x2B8 12Analog Input adjustment = subtract 12
9bBrightness0x2B9 64LED intensity = 64 (255 is the maximum)
10bPump1SPsIndex0x2BA 0x26Pump #1 Run & Stop Setpoints index = 38
11bPump2SPsIndex0x2BB 0x2CPump #2 Run & Stop Setpoints index = 44

Here again, a script can be used to input this, with explanatory notes:

>E   0x2A  = 48        ; Config starts at uVars.B[ 48 ] = 0x2B0
>ESW 0x2B0 = 500 mSec  ; Interval = 0.500 seconds
>ES  0x2B4 = 0x02      ; Bitmap (Port C) and "top down"
>ES  0x2B5 = 0x1C      ; Bitmap Output pins (B00011100)
>ES  0x2B6 = 10        ; Scalar (10 -> 102 LEDs = 306 bytes)
>ES  0x2B7 = 7         ; Select Analog Input = AIn(7)
>ES  0x2B8 = 12        ; Offset from zero (i.e., subtract 12)
>ES  0x2B9 = 64        ; LED intensity = 64
>ES  0x2BA = 0x26      ; Setpoints #1 begins: WORD at uVars.B[38]
>ES  0x2BB = 0x2C      ; Setpoints #2 begins: WORD at uVars.B[44]
>E   1    |= 8         ; Enable the Level Display System Application
>                                                                               

To enter the same configuration in a little more compact form:

>E 42 = 48
>ESW 0x2B0 = 500 M
>ES 0x2B4 = 2 28 10 7 12 64 38 44
>E 1 |= 8
>DV+
SRAM contents:
0280:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0290:  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
02A0:  FA 00 0E 85 07 00 00 01-70 01 07 01 A0 00 40 01  ........p.....@.
02B0:  F4 01 89 83 02 1C 0A 07-0C 40 26 2C 00 00 00 00  .........@&,....
>                                                                               

The underlined values above are the configuration data. Even without actual WS2812 LEDs connected to be able to view the levels and setpoints, the "P?" command can be used to see the pixel data. Once this Level Display System Application is activated, all of the parameters in SRAM can be adjusted on the fly to tune up the output.

Notes:
   The bScalar value is based on how many LEDs are being used to display the level and setpoints. The formula is: 1023 divided by the number of LEDs. If we had 64 LEDs, for example, 1023 / 64 = 17.05, so the bScalar value to would be 17.
Try toggling BIT_BOTTOM_UP to flip the output end-to-end. For the example configuration above, the toggle command would be "ES 0x2B4 ^= 128".

See also:
    The Pump Control System Application, the pixel command set, and the scripting language.