Minimum "on-time" for hal toggle pin
15 Jul 2023 01:53 - 15 Jul 2023 01:53 #275476
by beefy
Minimum "on-time" for hal toggle pin was created by beefy
I'm using a microcontroller to send signals to my 7i96 and onto Qtplasmac external hal pins.
Some of these pins are toggle type so they will only need a momentary high state before going low again.
A microcontroller operates at Mhz so I have to ensure the on time of the signal will be there for a minimum time for hal to acknowledge it.
If my thread ran every 1 millisecond, then would the hal signal being high for 3 milliseconds be reliable enough
Some of these pins are toggle type so they will only need a momentary high state before going low again.
A microcontroller operates at Mhz so I have to ensure the on time of the signal will be there for a minimum time for hal to acknowledge it.
If my thread ran every 1 millisecond, then would the hal signal being high for 3 milliseconds be reliable enough
Last edit: 15 Jul 2023 01:53 by beefy.
Please Log in or Create an account to join the conversation.
15 Jul 2023 02:19 #275477
by PCW
Replied by PCW on topic Minimum "on-time" for hal toggle pin
As long as the pulse width is > 2 servo thread periods you should be fine
Please Log in or Create an account to join the conversation.
15 Jul 2023 03:04 #275478
by beefy
Replied by beefy on topic Minimum "on-time" for hal toggle pin
Awesome, thanks Pete, I'll make it at least 3x
Please Log in or Create an account to join the conversation.
15 Jul 2023 03:12 #275479
by zdenek
Replied by zdenek on topic Minimum "on-time" for hal toggle pin
Why > 2 and not > 1 ?
Please Log in or Create an account to join the conversation.
15 Jul 2023 06:23 #275490
by rodw
Replied by rodw on topic Minimum "on-time" for hal toggle pin
@beefy, be careful there. The external pins are part of qtplasmac screen (in user space) so they are not real time so timings are not guaranteed
It would be better to connect to motion pins direct or use your new found skills to write a custom component in C.
@zendenek if the thread is firing every 1 Ms, one cycle will see it turn it on and another cycle will turn it off. But then it needs to be left on for another cycle or 2. The external signal won't be synced with the servo thread so some overlap is needed.
It would be better to connect to motion pins direct or use your new found skills to write a custom component in C.
@zendenek if the thread is firing every 1 Ms, one cycle will see it turn it on and another cycle will turn it off. But then it needs to be left on for another cycle or 2. The external signal won't be synced with the servo thread so some overlap is needed.
Please Log in or Create an account to join the conversation.
15 Jul 2023 07:26 #275492
by zdenek
Replied by zdenek on topic Minimum "on-time" for hal toggle pin
@rodw Do you believe that a 1 ms periodic thread will not see a 1.5 ms wide pulse?
Please Log in or Create an account to join the conversation.
15 Jul 2023 07:54 - 15 Jul 2023 08:11 #275494
by beefy
Replied by beefy on topic Minimum "on-time" for hal toggle pin
Hi Rod,
nothing motion related or real time with what I'm doing. It's just hooking up all the Qtplasmac external hal pins to the outside world (my pendant).
All signals are coming from a microcontroller so I'll just make the pulse time as long as is needed to guarantee the servo thread and Qtplasmac picks it up.
I can really lengthen the pulse duration if necessary.
@zdenek
I think Rod is saying the servo period time of Qtplasmac may be longer. I know what my servo period is for my custom component but I'm not sure how long the servo period(s) for Qtplasmac external hal pins are. It's possible they may be longer.
nothing motion related or real time with what I'm doing. It's just hooking up all the Qtplasmac external hal pins to the outside world (my pendant).
All signals are coming from a microcontroller so I'll just make the pulse time as long as is needed to guarantee the servo thread and Qtplasmac picks it up.
I can really lengthen the pulse duration if necessary.
@zdenek
I think Rod is saying the servo period time of Qtplasmac may be longer. I know what my servo period is for my custom component but I'm not sure how long the servo period(s) for Qtplasmac external hal pins are. It's possible they may be longer.
Last edit: 15 Jul 2023 08:11 by beefy.
Please Log in or Create an account to join the conversation.
15 Jul 2023 08:59 #275496
by rodw
@Beefy, there is no such thing as a timing thread on the real time side. It just gets done when it gets done.
The 7i73 you have on the either hand is real time.
But having said that, if ts just a pendant, it won't matter
Replied by rodw on topic Minimum "on-time" for hal toggle pin
I don't think it can be guaranteed but I've done no testing.@rodw Do you believe that a 1 ms periodic thread will not see a 1.5 ms wide pulse?
@Beefy, there is no such thing as a timing thread on the real time side. It just gets done when it gets done.
The 7i73 you have on the either hand is real time.
But having said that, if ts just a pendant, it won't matter
Please Log in or Create an account to join the conversation.
15 Jul 2023 10:14 #275498
by rmu
Replied by rmu on topic Minimum "on-time" for hal toggle pin
you have to allow for some jitter on the µC and the PC side, >=2 periods is the safe bet.@rodw Do you believe that a 1 ms periodic thread will not see a 1.5 ms wide pulse?
Please Log in or Create an account to join the conversation.
15 Jul 2023 17:50 #275520
by zdenek
Replied by zdenek on topic Minimum "on-time" for hal toggle pin
@rmu Indeed, you have to consider jitter (as you need to consider tolerances in every physical/real world case). When we say 1ms we really mean 1ms +/- epsilon, a jitter inherent to the system design. The ">" inequality sign implicitly covers that jitter. It is true that >=2T would be a safe bet, as would, e.g., >=7T be. My point was that >T && <2T would also suffice.
@beefy said : "If my thread ran every 1 millisecond, then would the hal signal being high for 3 milliseconds be reliable enough?"
I interpreted the question as "is there any special magic to be considered here, above and beyond the obvious?". And my answer is no, there is nothing special here, and common sense applies. If you want to check if your favorite 4:15 long song was being played on the radio on a given day, all you had to do was to turn the radio on and check every four minutes and you would not miss it. No need to check it more frequently.
When it comes to sampling signals in general there indeed are properties to be considered and possibly concerned about. There is latency (delay) due to the discrete nature of sampling (1ms here), there is hardware synchronizer latency due to the sampler being asynchronous with respect to its input (not applicable here), there is sampling with the intent to reconstruct the sampled signal where >2f is required per Shannon-Nyquist (also not applicable here as we just want a boolean status), but I can't think of anything that would need to be considered here given @beefy question.
All that said, pragmatically and defensively speaking, you do have to be aware of the jitter. Linuxcnc is not a hard real time system -- you could see an occasional surprising departure from the 1ms nominal time. Consequently, a 1.2T pulse would be statistically better than a 1.1T pulse and of course a 2T pulse would improve the chances further, but so would 2.5T and my point was that the 2 factor appeared rather arbitrary. More importantly, I wanted to observe that I don't see anything algorithmic or design-based implying [precisely] 2 over any other factor greater than 1.
If I misinterpreted the question, and @beefy was concerned about the soft real time nature of Linuxcnc and the unpredictable jitter, then I'd say his original suggestion for a 3ms pulse was as good as any.
Finally, not knowing how the Qtplasmac module exactly fits in, and what "my thread" really means leaves even more room for an interesting discussion .
Cheers
@beefy said : "If my thread ran every 1 millisecond, then would the hal signal being high for 3 milliseconds be reliable enough?"
I interpreted the question as "is there any special magic to be considered here, above and beyond the obvious?". And my answer is no, there is nothing special here, and common sense applies. If you want to check if your favorite 4:15 long song was being played on the radio on a given day, all you had to do was to turn the radio on and check every four minutes and you would not miss it. No need to check it more frequently.
When it comes to sampling signals in general there indeed are properties to be considered and possibly concerned about. There is latency (delay) due to the discrete nature of sampling (1ms here), there is hardware synchronizer latency due to the sampler being asynchronous with respect to its input (not applicable here), there is sampling with the intent to reconstruct the sampled signal where >2f is required per Shannon-Nyquist (also not applicable here as we just want a boolean status), but I can't think of anything that would need to be considered here given @beefy question.
All that said, pragmatically and defensively speaking, you do have to be aware of the jitter. Linuxcnc is not a hard real time system -- you could see an occasional surprising departure from the 1ms nominal time. Consequently, a 1.2T pulse would be statistically better than a 1.1T pulse and of course a 2T pulse would improve the chances further, but so would 2.5T and my point was that the 2 factor appeared rather arbitrary. More importantly, I wanted to observe that I don't see anything algorithmic or design-based implying [precisely] 2 over any other factor greater than 1.
If I misinterpreted the question, and @beefy was concerned about the soft real time nature of Linuxcnc and the unpredictable jitter, then I'd say his original suggestion for a 3ms pulse was as good as any.
Finally, not knowing how the Qtplasmac module exactly fits in, and what "my thread" really means leaves even more room for an interesting discussion .
Cheers
Please Log in or Create an account to join the conversation.
Time to create page: 0.140 seconds