WC8 doing PWM with TTL and PLC, is it possible?

Any ideas on code that could maybe produce a TTL out PWM frequency 50 to 100Hz with adjustable duty cycles 0 to 100%? 
 
Freq50hz-DC50%:
     Delay 20                        # set 50Hz loop
     Set OP1[10] 1               # on 50%
     Goto Freq50hz    
 
But lots of other PLC logic will need to be added and that might effect the entire PLC loop times? Something like this could be checked on a scope. Are these small delay times reasonable or in noise for WC8?         
 
Could you please elaborate what do you plan to do?  We may be able to do something to provide some kind of PWM output.
Is that just short burst of pulses, or it will be required to run all the time?  Using PLC to generate pulses are not very reliable, since its frequency and duty cycle are not very accurate.  We could do the PWM on a spare pin, if we know what the purpose. It is likely we have to cut some other features, since 50Hz is pretty low frequency, require a 16 bit counter, that may not available if we do not cut some other feature.
 
Since WebControl allows firmware update, if what you want is something we can arrange, we can make a version with this special feature and cut some features out. Then you update the firmware to load this special firmware for PWM output.
 
I want to use the WC8 to control a PWM Battery charger circuit.  So I would vary the duty cycle depending on battery charge (Bulk, Absorb, Float, Off).
Not sure what the optimum PWM frequency is for solar battery charging but Ive seen some above 100Hz. I plan to purchase an new WC8 for this project. My other boards are to old to update or in use already.
 
CAI_Support said:
Could you please elaborate what do you plan to do?  We may be able to do something to provide some kind of PWM output.
Is that just short burst of pulses, or it will be required to run all the time?  Using PLC to generate pulses are not very reliable, since its frequency and duty cycle are not very accurate.  We could do the PWM on a spare pin, if we know what the purpose. It is likely we have to cut some other features, since 50Hz is pretty low frequency, require a 16 bit counter, that may not available if we do not cut some other feature.
 
Since WebControl allows firmware update, if what you want is something we can arrange, we can make a version with this special feature and cut some features out. Then you update the firmware to load this special firmware for PWM output.
 
that would be great. cheap end edges should be interface rich, whilst user near devices should host readable master logic....
 
Machineman said:
So is PWM with variable duty cycle and fixed frequency possible on WC8?
 
Depends on your frequency requirements!
You can make a semi-usable PWM that runs at a few Hz using logic...
 
output on OP1, assume var1 has the percentage PWM required (0-100), ram1 is used as a counter.
 

    tstlt ram1 var1 op1
    nop
    inc ram1
    tstge ram1 100
    set ram1 0

 
Depending on how much other code you have, it can execute fairly quickly. Obviously, avoid blocking delays in the other code!!
 
I hooked up a O-scope to one of the DO's and wrote a simple on-off PLC, 50ms on and 50ms off.   It worked and was clean.  However when I added a bunch of other dummy code things weren't so smooth. And when I connected via Ethernet to monitor the system it was all over the place. Seems that Tx and Rx will interrupt the square wave of my PWM attempts. It becomes erratic and unpredictable.  I have an Adruino UNO board that has several PWM outs, will fire that up.
 
Back
Top