This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How feasible is to use PWM for one minute interval for each high and low pulse?

Hello,

I am experimenting with PWM for time, I have a setup where I am using three sensor which gives analogue output. 

I am using a mux which has two control pins, so I am controlling control pins with PWM, now I am experimenting with time, how it is possible to make a PWM signal of 1 minute at high level and 1 minute at low level? how do I change prescaler in nRF52dk to create such a slow clock.

regards,

Jaydip

  • Hello,

    Since the period of the signal is so long, 2 minutes, you can either implement this using the app_pwm library, or you may set up a timer to toggle the pin directly as its callback handler.
    Will you need to change the period / duty cycle of this PWM, or will it always be 1 minute off 1 minute on? If this is the case then I would suggest using the timer approach, but if you are going to change the duty cycle etc, then I suggest using the PWM library.
    You can see the usage of the PWM library demonstrated in the PWM Library example in the nRF5 SDK.
    The timer toggling pin functionality is demonstrated in the timer example where a timer is set to toggle a LED every 500 ms.

    Please do not hesitate to let me know if anything still should be unclear, or if you have any other questions.

    Best regards,
    Karl

     

  • Thanks karl for replying,

    I will change duty cycle for different use cases so I think I will use PWM instead of timer.

    I will check the link you've suggested and let you know if something still unclear.

    regards,

    Jaydip

  • Hello Jaydip,

    Jaydipsinh440 said:
    Thanks karl for replying,

    No problem at all, I am happy to help!

    Jaydipsinh440 said:

    I will change duty cycle for different use cases so I think I will use PWM instead of timer.

    I will check the link you've suggested and let you know if something still unclear.

    Great! I then think the PWM library example would be the best place for you to start.

    Please do not hesitate to let me know if you should encounter any other issues or questions.

    Best regards,
    Karl

  • Hi Karl,

    I have used the example PWM drivers which shows the different demo, Now with respect to that demo how do I calculate top value and what is the maximum top value? Can you explain more?

    regards,

    Jaydipsinh 

  • Hello Jaydipsinh,

    Jaydipsinh440 said:
    I have used the example PWM drivers which shows the different demo, Now with respect to that demo how do I calculate top value and what is the maximum top value? Can you explain more?

    I think you might have an easier timer if you take a look at the PWM Library example instead, since the PWM library uses the PWM driver, to create another level of abstraction - that way you will have to do considerably less low-level work.
    The PWM Library for example lets you set the duty cycle with a number between 0 - 100 using the _duty_set function.

    Please let me know if you still would like to rather use the PWM Driver, then I can provide explanations for how you may use the driver directly.

    Best regards,
    Karl

Related