dmadison / ServoInput

Interrupt-driven servo decoder library for Arduino
GNU Lesser General Public License v3.0
22 stars 10 forks source link

Failsafe detection #31

Closed Typ17b closed 1 week ago

Typ17b commented 3 months ago

Hi, Is it possible, to detect the absence of a valid receiver signal within a given resolution? This way it would be possible to realize a Failsafe detection.

Regards Stefan

dmadison commented 3 months ago

Hi Stefan! Could you clarify what "within a given resolution" means?

Typ17b commented 3 months ago

Hi Dave, sorry for my bad english, its not my mother tongue.

With "given resolution" i meant the use of the map function. I just realized, that the absence of the receiver signal generates the lower value of my map function: tiefenruderroh = tiefenr.map(500, 2500); I get 500 in return. Unfortunately, if the RC Signal is switched off from my Pro Micro while using it, the last measured value seems to be stored.

I hope, i could decribe my problem so you understand it.

Regards Stefan

Am 29.05.2024 um 23:25 schrieb Dave Madison:

Hi Stefan! Could you clarify what "within a given resolution" means?

— Reply to this email directly, view it on GitHub https://github.com/dmadison/ServoInput/issues/31#issuecomment-2138289778, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5QSXDELGRLRDIZEYWI36T3ZEZBWJAVCNFSM6AAAAABIPWFEXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZYGI4DSNZXHA. You are receiving this because you authored the thread.Message ID: @.***>

dmadison commented 3 months ago

I think I'm understanding you, feel free to correct me if I'm not.

If the RC receiver is still connected to the board but the RC controller isn't sending it signals, it's up to the RC receiver how to handle that. Some receivers will repeat the last known position (pulse duration), some will send a default position, some will stop sending pulses entirely.

If the controller isn't sending signals and the RC receiver is still sending pulses (whatever they are), there is nothing the library can do one way or the other. It just sees the pulses, and as far as it knows the pulses are valid.

If the controller isn't sending signals and the RC receiver is not sending pulses, the library will report the last known good value it received. If it hasn't ever received a valid signal the initial value is at the bottom of the range (500 in your example) because, well, we have no idea what the initial position is. Some motors (e.g. steering) are 'idle' at center, some motors (e.g. throttle) are 'idle' at low. There's no way of knowing.

The library does have a feature to check if there is a new signal, which is the available() function. If your receivers are of the latter type where they shut off signals when the RC controller drops out of range, you can check if a signal is available() before acting on it, rather than reading continuously:

if(servo.available()) {
    // do something with the data
}

Does that help?

Typ17b commented 3 months ago

Hi Dave, you are 100% correct. Some Receivers keep the last known signal, some make weird stuff and some do nothing. Its impossible to check if the signal is valid for the first two cases. Fortunately i must handle the third case, so i will check available() when i am back home later. I will report if it suits my needs.Thanks again!StefanAm 30.05.2024 00:04 schrieb Dave Madison @.***>: I think I'm understanding you, feel free to correct me if I'm not. If the RC receiver is still connected to the board but the RC controller isn't sending it signals, it's up to the RC receiver how to handle that. Some receivers will repeat the last known position (pulse duration), some will send a default position, some will stop sending pulses entirely. If the controller isn't sending signals and the RC receiver is still sending pulses (whatever they are), there is nothing the library can do one way or the other. It just sees the pulses, and as far as it knows the pulses are valid. If the controller isn't sending signals and the RC receiver is not sending pulses, the library will report the last known good value it received. If it hasn't ever received a valid signal the initial value is at the bottom of the range (500 in your example) because, well, we have no idea what the initial position is. Some motors (e.g. steering) are 'idle' at center, some motors (e.g. throttle) are 'idle' at low. There's no way of knowing. The library does have a feature to check if there is a new signal, which is the available() function. If your receivers are of the latter type where they shut off signals when the RC controller drops out of range, you can check if a signal is available() before acting on it, rather than reading continuously: if(servo.available()) { // do something with the data } Does that help?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

dmadison commented 1 week ago

Hi Stefan, following up on this. Were you able to solve your problem?

Typ17b commented 1 week ago

Hi Dave, this solved my problem. Sorry, i forgot to inform you. I am new to this github stuff, do i have to mark something as solved?

Thanks again for the perfect support!

dmadison commented 1 week ago

If your problem is solved you can close the issue as completed. I can do that for you.

Thanks for following up!