MagicPhantom
Hello,
 
Can we configure this %QW0 pin to be a logic output pin?
I need the extra pin. (A home PLC as impulse-relay + timer controller, for lighting fixtures, that works perfect with OpenPLC and the RPI.)
 
And is there a simple example of how to configure and use the pin as a PWM output?
I've tried and messed around with blocks, variables... nothing seem to work.
 
A simple LD program would help a lot.
I did not find anything appropriate online...
 
Thank you.
I just started using open plc. Please be patient :-)
Reply 0 0
MagicPhantom
Good news... I got the PWM to to work, I think.
I haven't tested it on hardware.
I also noticed that the output levels only go H/L when changing the button state, but not PWM wise in the debugger.
To clarify: I do not see a PWM signql in the debugger.
 
I'll keep you updated when I can measure it with a scope on the RPI.
 
 
[203128%2F9056896%2Fmceclip0]
Reply 0 0
MagicPhantom
 
PWM value 10000.
 
7.jpg
 
 
PWM value 63000.
 
6.jpg
 
So, this actually works!
Reply 0 0
thiagoralves
OpenPLC treats the PWM pin as an analog output. Analog outputs on OpenPLC are always 16-bit, which means they range from 0 to 65535. So, in summary, if you write 0 to %QW0 you will have your output turned fully off, and if you write 65535 to %QW0 you will have your output turned fully on. Anything in between will generate a PWM signal linearly varying 0-100% duty cycle.
Reply 0 0
MagicPhantom
OpenPLC treats the PWM pin as an analog output. Analog outputs on OpenPLC are always 16-bit, which means they range from 0 to 65535. So, in summary, if you write 0 to %QW0 you will have your output turned fully off, and if you write 65535 to %QW0 you will have your output turned fully on. Anything in between will generate a PWM signal linearly varying 0-100% duty cycle.
Thank you for your reply.
That should be the case, only, loading it with 65535 (2 bytes) does not give you a full high output.
It goes down for 5 µs with these clock settings. I assume the PWM controller needs some time to reload the PWM counter-register...
 
I'll put a small RC filter on the output, that will do the job.
 
Shown on scope image with zoom:
 
10.jpg
 
Kind regards,
Kenneth.
(Disregard Vpp levels: this handheld scope does not remember well it's probe attenuation of 1/10, guess I'll have to find out how to save it :-)
Reply 0 0
Reply