etisserant@0: FUNCTION WEIGH : WORD (* BCD encoded *) etisserant@0: VAR_INPUT (* "EN" input is used to indicate "scale ready" *) etisserant@0: weigh_command : BOOL; etisserant@0: gross_weight : WORD ; (* BCD encoded *) etisserant@0: tare_weight : INT ; etisserant@0: END_VAR etisserant@0: (* Function Body *) etisserant@0: LD weigh_command etisserant@0: JMPC WEIGH_NOW etisserant@0: ST ENO (* No weighing, 0 to "ENO" *) etisserant@0: RET etisserant@0: WEIGH_NOW: LD gross_weight etisserant@0: BCD_TO_INT etisserant@0: SUB tare_weight etisserant@0: INT_TO_BCD (* Return evaluated weight *) etisserant@0: ST WEIGH etisserant@0: etisserant@0: END_FUNCTION (* Implicit "ENO" *)