normal PLC stuff
OSR kind of betrays my AB history
This routine makes a rising edge when a certain position is reached (hyst of 2) and then creates a timed pulse of 25ms and sends it to an output.
(* ##### Trigger printerfunction = output activating output on specific location *)
OSR_Printer.CLK := AxisData[1].rActualPosition_i > diPrinterPosition_gb AND
AxisData[1].rActualPosition_i < (diPrinterPosition_gb + 2);
OSR_Printer();
fbPrint_TP(IN:=OSR_Printer.Q , PT:=t#25ms);
bPrinter_q := bEnable_Printer_gb AND fbPrint_TP.Q;
Timer example where the .IN is defined in a seperate line:
TON_VacumePump.IN := (bMachineProducing_gb OR bMachineJogging_gb OR bMachineParking_gb) AND bEnable_Vacumepump_gb AND bMachineReady_gb;
TON_VacumePump(PT:= UINT_TO_TIME(uiVacumepump_OnDelay_gb * 1000));
The following is a shift register (well, really an array used as a shift reg) that is toggled every cycle of the machine and filled with the appropriate info true/false.
(* #### shiftregister for blow-out of NotCut *)
fb_TRIGGER_shiftNotCut(x:=AxisData[5].rActualPosition_i , position:= rPosition_NotCut_gb, modulo:= 360.0, Q=> );
IF fb_TRIGGER_shiftNotCut.Q THEN
FOR icounter_NotCut_m:=10 TO 1 BY -1 DO
arshift_BlowoutNotCut_gb[icounter_NotCut_m] := arshift_BlowoutNotCut_gb[icounter_NotCut_m - 1];
END_FOR
IF bSensor_NotCut_i THEN
arshift_BlowoutNotCut_gb[0] := TRUE;
ELSE
arshift_BlowoutNotCut_gb[0] := FALSE;
END_IF
END_IF
bBlowout_NotCut_gb := bEnable_NotCut_gb AND arshift_BlowoutNotCut_gb[uiNumberNotCut_gb];
Heres a standard function that changes a variable when you press a button and keep it pressed:
fb_Adjust_Printer(
Enable := TRUE,
Inc := bAdjust_Printer_Up_gb,
Dec := bAdjust_Printer_Down_gb,
ModuloValue := 360,
StepWidth := 1,
StepsPerSecond := 5,
AdjTimeIntervals := strAdjustTimes_m,
AdjWeightFactors := strAdjustFactors_m,
Value := diPrinterPosition_gb);