• Categories
  • Recent
  • Tags
  • Popular
  • Login
REXYGEN Community Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Login

Solved RC Servo PWM control.

Monarco HAT
2
12
1.1k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B
    brunofporto @reitinge
    last edited by brunofporto 18 Nov 2020, 17:23 18 Nov 2020, 17:00

    @reitinge Thank you.

    So, the duty cycle value for 50hz would be from 0.1 to 0.05 (1ms to 2ms pulse width) and for 100Hz would be from 0.2 to 0.1 for example.

    06be03f1-ccc8-43f4-9f65-af646fb00cde-image.png

    But I could not make it work...

    Edit: With 500Hz it moved so... Ok 😄

    Thank you

    1 Reply Last reply Reply Quote 0
    • B
      brunofporto
      last edited by 18 Nov 2020, 17:46

      @reitinge said in RC Servo PWM control.:

      Duty_cycle = pulse_width/period_length

      Period length? 1s/Hz?

      1 Reply Last reply Reply Quote 0
      • R
        reitinge
        last edited by 18 Nov 2020, 20:48

        The length of the period for 50 Hz is 0.02 s.
        For pulse width 0.001 s:
        Duty cycle = 0.001/0.02 = 0.05
        Pulse width 0.002 s:
        Duty cycle = 0.002/0:02 = 0.1

        Are you sure about the frequency and width of the pulses? I would expect a duty cycle range from 0 to 1.

        B 2 Replies Last reply 19 Nov 2020, 10:23 Reply Quote 0
        • B
          brunofporto @reitinge
          last edited by 19 Nov 2020, 10:23

          @reitinge Yes but these values of duty cycle does not work as calculated.

          1 Reply Last reply Reply Quote 0
          • B
            brunofporto @reitinge
            last edited by 19 Nov 2020, 10:26

            @reitinge And I am not sure...

            At 50hz the servo just ignores the DOUT signal. It started working at 500Hz up to 5000Hz.

            And the Duty cycle calculation does not create the expected response from the servo at all. The width I am sure (but it is around 0.8 to 2.2ms)

            So I am confused. I could make the servo works but this formula for the duty cycle and pulse width does not works.

            1 Reply Last reply Reply Quote 0
            • R
              reitinge
              last edited by reitinge 20 Nov 2020, 12:39 20 Nov 2020, 12:38

              Hi Bruno,
              I have connected my Monarco HAT to the oscilloscope and the PWM behaves as expected. I set the frequency to 50 Hz and on the first measurement I set the duty cycle to 0.5 (Figure 1). Figure 2 shows the measurement at a duty cycle = 0.1. Please note that Monarco HAT has open-drain outputs, as shown in Figure 2.
              PWM_fig1_DC_0_5.jpg
              PWM_fig2_DC_0_1.jpg
              Can you send a wiring diagram to your RC servo?

              R B 2 Replies Last reply 23 Nov 2020, 08:42 Reply Quote 0
              • R
                reitinge @reitinge
                last edited by reitinge 23 Nov 2020, 09:11 23 Nov 2020, 08:42

                @reitinge To be more specific, for an open-drain digital output you will need to subtract the calculated duty cycle value from 1:

                Duty_cycle = 1 - Calculated_duty_cycle
                

                For 1 ms width pulse and frequency 50 Hz:

                Duty_cycle = 1 - 0.05 = 0.95
                

                For 2ms width pulse and frequency 50 Hz:

                Duty_cycle = 1 - 0.1 = 0.90
                

                If you are using a DO as an 5V voltage source, see the Using digital outputs in 5V logic circuits chapter here:
                https://support.monarco.io/help/digital-outputs-of-the-monarco-hat
                The logic is "reversed":
                If DOUT=OFF, no connection to ground exists and you will measure 5V at the output. If DOUT=ON, connection to ground is made and there will be 0V at the output. That's how you can control devices which use 5V logic.

                I apologize for the mystification in previous posts.

                B 1 Reply Last reply 8 Jan 2021, 21:24 Reply Quote 0
                • B
                  brunofporto @reitinge
                  last edited by 8 Jan 2021, 20:34

                  @reitinge said in RC Servo PWM control.:

                  Can you send a wiring diagram to your RC servo?

                  The signal wire of the servo is connect to the DOUT1. The servo is powered by a dedicated BEC to provide 6v that have a common ground with the Monarco.

                  1 Reply Last reply Reply Quote 0
                  • B
                    brunofporto @reitinge
                    last edited by 8 Jan 2021, 21:24

                    @reitinge With the "Duty_cycle = 1 - Calculated_duty_cycle" it worked like a charm. THANK YOU!

                    1 Reply Last reply Reply Quote 0
                    • R
                      reitinge
                      last edited by 10 Jan 2021, 07:56

                      You are welcome 🙂

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      This is a community forum for REXYGEN users and fans. Detailed information can be found at REXYGEN homepage.

                      There is also an outdated REXYGEN community forum.

                      Powered by NodeBB.