Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

PWM fails


josean Oct 21, 2014 08:54 AM

Hello again,

I have a problem using PWM instruction and need some recommendations.
The CR1000 program below is an extract of the program I am trying to implement.
It sets 3 pluviometers on ports C6, C7 and C8. 100K pull-up resistors are also connected betwen 12V and these ports. It also provides continuous modulated pulses with 50Hz constant frequency on ports C4 and C5. Modulation changes every 5 seconds as seen in the program.

Everything goes OK while neither of the pluviometer levels tip or pluviometers on C7 and C8 tip. When pluviometer on C6 tips, the pulse signal on C5 changes frequency erroneously and the modulated pulses are not the ones defined in PWM instruction any longer.

Please, can anyone provide some recommendations?


--------------- Program ------------------

SequentialMode

Const ANCHO=20000.0
Const ZetPulseMin=550.0
Const ZetPulseMax=2500.0
Const PhiPulseMin=1220.0
Const PhiPulseMax=2570.0

Public duty
Public PhiPulse, ZetPulse
Public reed(3), Paso(3)

Dim k

BeginProg

PulseCountReset
For k = 1 To 3
Paso(k)=0
Next k
PhiPulse=PhiPulseMin
ZetPulse=ZetPulseMin

Scan (1,Sec,0,0)

PulseCount (reed(),3,16,2,0,1.0,0)
For k = 1 To 3
Paso(k)=Paso(k)+reed(k)
Next k

If TimeIntoInterval(4,5,Sec) Then

duty=PhiPulse/ANCHO
PWM (duty,5,20,mSec)
PhiPulse=PhiPulse+100

duty=ZetPulse/ANCHO
PWM (duty,4,20,mSec)
ZetPulse=ZetPulse+200

If PhiPulse > PhiPulseMax Then PhiPulse=PhiPulseMin
If ZetPulse > ZetPulseMax Then ZetPulse=ZetPulseMin

EndIf

NextScan

EndProg

Log in or register to post/reply in the forum.