Icon

USC Config - q. Adder with Peak Output and Reset

This exercise will take the previous input adder example and adda a peak measurement output that is reset to a minimum output level when a digital input is active.

Create some program documentation.
  1. Enter the equation screen and click on the 'Show/Edit user description' option.
  2. In the 'Helper' window type in following information to describe the variable use in the equation to be written.
    Adder with Peak Output And Reset
    Mem 4 = Adder Output
    Mem 5 = Peak Output
    Const b = Reset Value
    P2 = reset the peak output to Const b
Create a block of commands that saves memory 4 in memory 5.
  1. In 'Edit' mode click on the <End> label, click 'Branch' on the keypad and insert an 'Exit' command.
  2. While still on the <End> label, click 'Branch' on the keypad and insert a 'Line Label'. When prompted enter the name of the line label as "SavePk".
  3. While still on the <End> label, click 'Read' on the keypad and insert a 'Read M4' command.
  4. While still on the <End> label, click 'Save' on the keypad and insert a 'Save M5' command.
  5. While still on the <End> label, click 'Send M?' on the keypad and insert a 'Send M5' command.
Create a block that saves constant 'b' in memory 5.
  1. While still on the <End> label, click 'Branch' on the keypad and insert an 'Exit' command.
  2. While still on the <End> label, click 'Branch' on the keypad and insert a 'Line Label'. When prompted enter the name of the line label as "ResetPk".
  3. While still on the <End> label, (shift button up click the 'Constant' button on the keypad and insert 'Constant b'.
    When prompted enter the value as 0 and the name as "ResetVal".
  4. While still on the <End> label, click 'Save' on the keypad and insert a 'Save M5' command.
  5. While still on the <End> label, click 'Send M?' on the keypad and insert a 'Send M5' command.
Insert a branch that saves constant b in memory 5 when P2 is pressed.
  1. Click on the first exit command in the program list.
  2. Click 'Branch' on the keypad and insert 'If P2 Goto' command. Select line "ResetPk" when prompted.
Insert a branch that saves memory 4 in memory 5 when memory 4 is greater than memory 5.
  1. Click on the first exit command in the program list.
  2. Click 'Read' on the keypad and insert a 'Read M5' command.
  3. Click on the keypad.
  4. Click 'Branch' on the keypad and insert 'If > 0 Goto' command. Select line "SavePk" when prompted.
Save results so far.
  1. Press 'Ok' to exit then 'Ok' to close and save changes, the following message will appear.
    P2 has been used in the equation editor but it has not been enabled for use.
    Please enable when the 'modify wizard' opens.
    Pressing cancel will disable all further checks of the equation in this pass.
  2. Press 'Ok', when the P2 not set screen appears press the small range button 'r' and select 'Logical' then 'Settings' on the change range wizard. Press Next to return to the modify wizard.
  3. Select 'Contact' from the list. Change the trigger to 'High' so that the P2 function occurs when the button is pressed.
  4. Press Next then Finish. When the 'USC Properties' screen appears press 'Configure' to re-enter the special function equation editor.
  5. In 'Simulation Options' select step.
  6. Progressively press the 'Step >' (step next) button. The function of the equation will be simulated as shown in figure 34.

Adder with Peak Output and Low Limit Equation List

Program List Calculator Stack Memory Results
Read CH1 S(1)=CH1
Read CH2 S(2)=CH2
S(1)=CH1
Add S(1)=(CH1 + CH2)
Save Mem4 S(1)=(CH1 + CH2) M(4)=(CH1 + CH2)
Send Mem4 S(1)=(CH1 + CH2) M(4)=(CH1 + CH2)
If P2 Goto ResetPk S(1)=(CH1 + CH2) M(4)=(CH1 + CH2)
Read Mem5 S(2)=(MEM5)
S(1)=(CH1 + CH2)
M(4)=(CH1 + CH2)
Subtract S(1)=(CH1 + CH2)-MEM5 M(4)=(CH1 + CH2)
If>0 Goto SavePk S(1)=(CH1 + CH2)-MEM5 M(4)=(CH1 + CH2)
Exit M5 remains the same
LAB: SavePk S(1)=(CH1 + CH2)-MEM5 M(4)=(CH1 + CH2)
Read Mem4 S(2)=MEM4
S(1)=(CH1 + CH2)-MEM5
M(4)=(CH1 + CH2)
Save Mem5 S(2)=MEM4
S(1)=(CH1 + CH2)-MEM5
M(5)=MEM4
M(4)=(CH1 + CH2)
Exit
LAB: ResetPk S(1)=(CH1 + CH2) M(4)=(CH1 + CH2)
Con_b S(2)=Con_b
S(1)=(CH1 + CH2)
M(4)=(CH1 + CH2)
Save Mem5 S(2)=Con_b
S(1)=(CH1 + CH2)
M(4)=(CH1 + CH2)
M(5)=Con_b
Send M5 S(2)=Con_b
S(1)=(CH1 + CH2)
M(4)=(CH1 + CH2)
M(5)=Con_b
Exit