You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="PWM_DC" Id="{0f59300b-d8c1-494c-88fa-aaf8a563364f}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK PWM_DC
VAR_INPUT
F : REAL;
DC : REAL;
END_VAR
VAR_OUTPUT
Q : BOOL;
END_VAR
VAR
clk: CLK_PRG;
pulse: TP_X;
tmp: REAL;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[(*
version 1.4 11. mar. 2009
programmer oscat
tested BY oscat
this signal generator generates a square wave signal which is specified by the frequency and the duty cycle
*)
(* @END_DECLARATION := '0' *)
IF F > 0.0 THEN
tmp := 1000.0 / F;
CLK(PT := REAL_TO_TIME(tmp));
Pulse(in := clk.Q, pt := REAL_TO_TIME(tmp * DC));
Q := pulse.Q;
END_IF;
(* revision history
hm 25. feb 2007 rev 1.1
recoded in st for better performance and better portability
hm 27. nov 2007 rev 1.2
avoid divide by 0 when F = 0
hm 19. oct. 2008 rev 1.3
changed type TP_R to TP_X because of name change
improved performance
hm 11. mar. 2009 rev 1.4
changed real constants to use dot syntax
*)]]></ST>
</Implementation>
<LineIds Name="PWM_DC">
<LineId Id="21" Count="29" />
<LineId Id="9" Count="0" />
</LineIds>
</POU>
</TcPlcObject>