theColonel26
Lifetime Supporting Member
Does anyone else toggle bits, or increment words as a messaging technique?
To start a sequence or process I will hold a bit true (To avoid accidental starts), but usually for statuses and the complete confirmations (Acks) I uses a changing value (toggle a bool) and watch for it to change.
I do this to avoid race conditions, or at least greatly reduce my risk of race conditions.
I know a lot of people just use a timer to hold a bit true for like 5 seconds at the end of sequences for a complete signal, but that to be is not a solution is is just a cheap band-aid.
With toggling bools you can still run in to race conditions but in most situations it is not an issue are fine. I have started using incremented INT/DINTs in some places now. That is the most race condition proof technique I can think off. but it also uses a lot more data.
Lastly I always put timeouts on a sequence to alert the User that something went wrong and then let them reset and try again.
Thoughts?
To start a sequence or process I will hold a bit true (To avoid accidental starts), but usually for statuses and the complete confirmations (Acks) I uses a changing value (toggle a bool) and watch for it to change.
I do this to avoid race conditions, or at least greatly reduce my risk of race conditions.
I know a lot of people just use a timer to hold a bit true for like 5 seconds at the end of sequences for a complete signal, but that to be is not a solution is is just a cheap band-aid.
With toggling bools you can still run in to race conditions but in most situations it is not an issue are fine. I have started using incremented INT/DINTs in some places now. That is the most race condition proof technique I can think off. but it also uses a lot more data.
Lastly I always put timeouts on a sequence to alert the User that something went wrong and then let them reset and try again.
Thoughts?