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

Signal Jittering on the Output of Raspberry PI for Scan Cycle less than 1ms

Kalyani-K
2019-04-03
2019-06-15
  • Kalyani-K - 2019-04-03

    Hello all,

    Following is the description of the task that I am performing on Raspberry PI via CodeSYS environment, and the corresponding results of the operation:

    Task:
    To generate output signals whose lengths are in multiples of 500us (500us, 1000us, 1500us, 2000us, and 2500us), which is further used to signal servo motors.

    How did I do that:
    1. I set the scan cycle of CodeSYS to 500us in the 'Main Task' window.
    2. Next, I composed the code in terms of state machines, such that if State :=1, the output signal at the GPIO should be of length 500us, with 20ms of delay between 2
    signals.
    If State := 2, the output signal at the GPIO should be of the length 1000us, with 20ms of delay between two signals.
    So on and so forth.

    Result:
    The output signal was observed via an oscilloscope.
    The signal is stable for any scan cycle above 1ms.
    However, the signal starts jittering, for as much as 100us-150us, which indeed causes jittering at the servo motors, thereby not rotating it to the desired position when the signal is supplied to it.

    Can anyone please help me understand the root cause of this issue?
    And, possible approaches to it?

    Many thanks in advance!
    Kalyani

     
  • lbabycl-88 - 2019-04-03

    It's not suitable for real time applications, I dont remember the exact sources but if you research real time kernels for raspberry you may see some answers, from memory it it can have a few milliseconds of delays depending on workload of CPU, you can apply a real time kernel to get the delay between cycles down but I think only to 1 or 2 ms between cycles and it comes with a cost, it reduces CPU performance and may cause issues with drivers I'll try to get the links for you

    Sent from my SM-N9500 using Tapatalk

     
  • lbabycl-88 - 2019-04-03

    Google preempt rt

    Also its performance

    U get up almost 400 us latency on stock kernel depending on load

    U can bring that down to 100 + with rt preempt but at a cost

    Sent from my SM-N9500 using Tapatalk

     
  • lbabycl-88 - 2019-04-03

    Ingo I have a project soon to implement but I'm wondering if preempt rt is feasible, what problems do you find with.it if any? USB drives ethernet drivers etc

    Sent from my SM-N9500 using Tapatalk

     
  • Ingo

    Ingo - 2019-04-03

    I didn't have so bad problems with it until now. Just starting on a RPI3 with Multicore causes some problems from time to time. Seems like a timing issue. At some boots, the kernel can't start all cores and panics.

    But when it booted up, it works for me.

    Gesendet von meinem LG-H870 mit Tapatalk

     
  • lbabycl-88 - 2019-05-29

    hi im trying to log into the debian distro found on the link you posted whats the login and password? the regular raspbery pi does not work for password

     
  • dkugler - 2019-05-29

    Originally created by: D. Kugler

    I would use the Adafruit 16 channel PWM board for such application. The example is in the Raspberry Pi Examples. i tried this example with such a cheap board and works fine with several servos and without any jitter problems and you don't have to stress the Pi with 500Β΅s cycletime?!?! An you have 4096 steps for the range of servo movement and not 4 steps only. Maybe that's an alternative solution for you?

     
  • lbabycl-88 - 2019-06-15

    Ingo hello, I am on the rt preempt with multicore and have the issue you mentioned with CPU, did you ever find a solution ?

    Sent from my SM-N9500 using Tapatalk

     

Log in to post a comment.