1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
rem SimpleSetup.bas
rem
rem last revision 2004 June 23
rem

rem simple macro for DI50T
rem one input only, no scrolling texts in menus

rem Interface:
rem   - PROG for 4 secs: two point calibration of input
rem   - PROG+UP        : adjust brightness
rem   - PROG+DOWN      : adjust setpoint values
rem   - UP+DOWN        : custom menu (Freq/DecimalPoint/ScaleAnalog/ZeroWindow)
rem   - HOLD pin       : set Tare
rem   - LOCK pin       : clear Tare
rem   - CAPTURE pin    : manual zero

CONST PROG_TIMEOUT = 30

MEM &CODE_BLANKING = 0          // hide all codes (brightness cannot be hidden)
MEM &VIEW_MODE_BLANKING = 0     // we don't need view mode
MEM &SETPOINT_BLANKING = 0x007e // change only setpoint values (PROG+DOWN)
                                // (disabled setpoints will not be displayed)

/////////////////////////////////////////////////
// calibration and code settings
CONST CODE2_60 = 0270 // 60 Hz mains, fast output rate, CH1 gets averaged data
CONST CODE2_50 = 0370 // 50 Hz mains, fast output rate, CH1 gets averaged data

MEM &CAL = 0031   // dual point calibration for CH1 (PROG for 4 secs)
MEM &CODE1 = 0020 // fast update
MEM &CODE2 = CODE2_60
MEM &CODE3 [] = [ 0000, 0000, 0000, 0000, 0000, 0000 ] // no other channels or datalogging
MEM &CODE9 = 0065 // Set/Clear Tare with HOLD/LOCK

/////////////////////////////////////////////////
// setpoint defaults (only SP1-4 are used)
MEM &SP1_DATA_SOURCE [] = [ addr(&CH1), addr(&CH1), addr(&CH1), addr(&CH1), 0, 0 ]
MEM &Setpoint1_Text = "Hi 1 "
MEM &Setpoint2_Text = "Lo 1 "
MEM &Setpoint3_Text = "Hi 2 "
MEM &Setpoint4_Text = "Lo 2 "
MEM &SETPOINT1 []       = [ 1000, -2000, 3000, -4000, 5000, 6000 ] // setpoint values
MEM &SP1_CONTROL []     = [ 0, 0100, 0, 0100, 0, 0 ] // energize above/below/above/below
MEM &SP1_HYST []        = [ 0, 0, 0, 0, 0, 0 ] // no hysteresis/PID
MEM &SP1_DELAY_TYPE []  = [ 0, 0, 0, 0, 0, 0 ] // disable all setpoint timers/delays
MEM &SP1_TRIGGER []     = [ 0, 0, 0, 0, 0, 0 ] // disable all setpoint triggers

/////////////////////////////////////////////////
// analog output
MEM &DATA_SOURCE_ANALOG1 = addr(&CH1)
MEM &D2A_AOP1_ZERO = 0            // output low end calibration if source equals ZERO
MEM &D2A_AOP1_FULL_SCALE = 99999  // output high end calibration if source equals FULL_SCALE

/////////////////////////////////////////////////
// manual zero
MEM &AZ_CAPTURE_BAND_CH1 = 255  // manual zero with CAPTURE pin
MEM &AZ_APERTURE_BAND_CH1 = 200 // maximum zero offset

/////////////////////////////////////////////////
// text arrays for menus
DIM SkipEnter[] = [ "Skip", "Enter" ]
CONST SKIP = 0
CONST ENTER = 1

DIM MainsFrequency[] = [ "60 Hz", "50 Hz" ]
CONST MAINS_60 = 0
CONST MAINS_50 = 1

MEM &DISPLAY_FORMAT_CH1 = 0  // no decimal point as default
DIM Decimal[] = [ "No Dp", " .1", " .12", " .123", " .1234" ]
DIM Point[] = [ 0, 6, 5, 4, 3 ]

/////////////////////////////////////////////////
// edit menu modes
CONST eENTER_SETUP = 1
CONST eMAINS_FREQUENCY = 2
CONST eDECIMAL_POINT = 3
CONST eSCALE_ANALOG_OUTPUT = 4
CONST eANALOG_ZERO = 5
CONST eANALOG_FULL_SCALE = 6
CONST eZERO_WINDOW = 7

// triggered by PROG+UP+DOWN
////////////////////////////////////////////////////////////////////////////////
CUSTOMER_ID_MACRO:
////////////////////////////////////////////////////////////////////////////////
write "     Simple Setup     "
END

////////////////////////////////////////////////////////////////////////////////
RESET_MACRO:
////////////////////////////////////////////////////////////////////////////////
#TEMP = 0
END

////////////////////////////////////////////////////////////////////////////////
MAIN_MACRO:
////////////////////////////////////////////////////////////////////////////////
// currently in standard display mode
if &STATE = 0 and &EDIT_STATE = 0 then
  // only UP+DOWN pressed (PROG+UP+DOWN triggers Customer_ID_Macro)
  if |PROG_BUTTON = off and |UP_BUTTON = on and |DOWN_BUTTON = on then
    EDIT SKIP
    &EDIT_MIN = SKIP
    &EDIT_MAX = ENTER
    EDIT_TEXT SkipEnter[]
    write "Setup"
    &STATE = eENTER_SETUP
  endif
endif
END

////////////////////////////////////////////////////////////////////////////////
EDIT_MACRO:
////////////////////////////////////////////////////////////////////////////////
select &STATE
case eENTER_SETUP:
  EXIT_EDIT
  if &EDIT_VALUE = ENTER then
    #TEMP = (&CODE2 and 0x00000040) / 0x40 // get bit 6 of CODE2
    EDIT #TEMP
    &EDIT_MIN = MAINS_60
    &EDIT_MAX = MAINS_50
    EDIT_TEXT MainsFrequency[]
    &STATE = eMAINS_FREQUENCY
    write "FREQ "
  endif
case eMAINS_FREQUENCY:
  EXIT_EDIT
  if &EDIT_VALUE = MAINS_60 then
    |NON_VOLATILE_WRITE = on
    &CODE2 = CODE2_60
  else
    |NON_VOLATILE_WRITE = on
    &CODE2 = CODE2_50
  endif

  #TEMP = 7 - &DISPLAY_FORMAT_CH1  // decimal display, no rounding => #TEMP > 0
  if #TEMP > 4 then                // invalid options or no decimal point
    #TEMP = 0
  endif
  EDIT #TEMP
  &EDIT_MIN = 0
  &EDIT_MAX = 4
  &EDIT_DEF = 2
  EDIT_TEXT Decimal[]
  &STATE = eDECIMAL_POINT
  write "DP   "

case eDECIMAL_POINT:
  EXIT_EDIT
  |NON_VOLATILE_WRITE = on
  &DISPLAY_FORMAT_CH1 = Point[&EDIT_VALUE]

  EDIT SKIP
  &EDIT_MIN = SKIP
  &EDIT_MAX = ENTER
  EDIT_TEXT SkipEnter[]
  &STATE = eSCALE_ANALOG_OUTPUT
  write "Sca_A"
  
case eSCALE_ANALOG_OUTPUT:
  EXIT_EDIT
  if &EDIT_VALUE = ENTER then
    EDIT &D2A_AOP1_ZERO      // 32bit signed, setup restricted by display width
    &EDIT_MIN = -19999
    &EDIT_MAX = 99999
    &EDIT_DEF = 0
    &STATE= eANALOG_ZERO
    write "A_ZER"
  else
    goto edit_zero_window
  endif
case eANALOG_ZERO:
  |NON_VOLATILE_WRITE = on
  EXIT_EDIT &D2A_AOP1_ZERO
  EDIT &D2A_AOP1_FULL_SCALE  // 32bit signed, setup restricted by display width
  &EDIT_MIN = -19999
  &EDIT_MAX = 99999
  &EDIT_DEF = 99999
  &STATE= eANALOG_FULL_SCALE
  write "A_FSC"
  
case eANALOG_FULL_SCALE:
  |NON_VOLATILE_WRITE = on
  EXIT_EDIT &D2A_AOP1_FULL_SCALE
edit_zero_window:
  EDIT &AZ_APERTURE_BAND_CH1 // 16bit unsigned
  &EDIT_MIN = 0
  &EDIT_MAX = 65535
  &EDIT_DEF = 200
  &STATE = eZERO_WINDOW
  write "ZERO "

case eZERO_WINDOW:
  |NON_VOLATILE_WRITE = on
  EXIT_EDIT &AZ_APERTURE_BAND_CH1
endsel
END

Download SimpleSetup.bas
(6.0 KB , Aug. 26, 2008)