170
Analogramp:AQ
PIcontroller:AQ
Analogmath:AQ
Datalatchingrelay:AQ
Up/Downcounter:Cnt
Parameterp(numberofdecimals)
ParameterpappliesonlytothedisplayoftheAxvalueinamessagetext.
Descriptionofthefunction
ThefunctionreadsthevalueofthesignalattheanaloginputAx.
ThisvalueismultipliedbythevalueofparameterA(gain).ParameterB(offset)isaddedtotheproduct,
asfollows:
(Ax*Gain)+Offset=ActualvalueAx
ThefunctionblockcalculatestheproportionofthevalueAxtotherange.Theblocksetsthedigitaloutput
QhighforthesameproportionofthePT(periodictime)parameter,andsetsQlowfortheremainderof
thetimeperiod.
ExampleswithTimingDiagrams
ThefollowingexamplesshowhowthePWMinstructionmodulatesadigitaloutputsignalfromtheanalog
inputvalue:
Example1
Analoginputvalue:500(range0...1000)
PeriodictimeT:4seconds
ThedigitaloutputofthePWMfunctionis2secondshigh,2secondslow,2secondshigh,2secondslow
andcontinuesinthatpatternaslongasparameter"En"=high.
Example2
Analoginputvalue:300(range0...1000)
PeriodictimeT:10seconds
ThedigitaloutputofthePWMfunctionis3secondshigh,7secondslow,3secondshigh,7secondslow
andcontinuesinthatpatternaslongasparameter"En"=high.