Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

PWM To analog

JAPIB
2018-06-14
2024-01-12
  • JAPIB

    JAPIB - 2018-06-14

    Hello,

    Has anyone ever written a program to convert PWM pulses to analog value?
    If yes can you explain to me the principle.
    I looked at OSCAT, but I did not find !

    Thank you in advance
    Best regard

     
  • somlioy - 2018-06-14

    You have a constant frequency usually, then you know the total time between first rising edge to second rising edge:

    T = 1/f.

    Period can also be calculated and averaged in software if frequency is not known.

    Then you check the length of the on-pulse and then for example get the percentage on-time from total periode-time.

    Or even easier, use a first or second order low-pass filter and get an analog voltage.

     
  • JAPIB

    JAPIB - 2018-06-15

    Thanks a lot somlioy , I'll try this soon.

     
  • anderson - 2024-01-12

    ja aproveitando a discussão, eu estou com um problema relacionado ao uso da biblioteca OSCAT. estou tentando usar o bloco pwm, porém nao consigo executar.nao tem uma entrada para a função execute

     

Log in to post a comment.