Changing digital outputs when watchdog triggers
- carlos.santos
- Topic Author
- Offline
Less
More
- Posts: 4
- Thank you received: 0
7 years 1 month ago #29531738
by carlos.santos
Changing digital outputs when watchdog triggers was created by carlos.santos
We need to change our digital outputs when our controller ceases to receive any data from the serial port. There are commands and parameters to define the defaults for the channels in case there is a timeout in the watchdog but we couldn't find anything related to the digital outputs.
Any help would be great!
Thank you!
Any help would be great!
Thank you!
Please Log in or Create an account to join the conversation.
7 years 1 month ago #29531742
by niko
Replied by niko on topic Changing digital outputs when watchdog triggers
Hello Carlos,
no there is no such mechanism, but here what you can do. Send periodically via serial a command that fills e.g. VAR 1 with a value (!VAR 1 xx).
On your script check periodically if this value is there, if so set 0 to that value. When you detect 0 will mean that serial connection is lost. An untested example below:
top:
if getvalue(_VAR, 1) = xx then
setcommand(_VAR, 1, 0)
else
print("connection is lost")
end if
wait(yy)
goto top
no there is no such mechanism, but here what you can do. Send periodically via serial a command that fills e.g. VAR 1 with a value (!VAR 1 xx).
On your script check periodically if this value is there, if so set 0 to that value. When you detect 0 will mean that serial connection is lost. An untested example below:
top:
if getvalue(_VAR, 1) = xx then
setcommand(_VAR, 1, 0)
else
print("connection is lost")
end if
wait(yy)
goto top
Please Log in or Create an account to join the conversation.
- carlos.santos
- Topic Author
- Offline
Less
More
- Posts: 4
- Thank you received: 0
7 years 1 month ago #29531746
by carlos.santos
Replied by carlos.santos on topic Changing digital outputs when watchdog triggers
That seems to be a good solution niko, thank you!
But for this to work, the frequency of the serial writing has to be higher than the frequency of the microbasic loop. How can I guarantee that? I probably cannot use timers because I am doing other things in the script, but I can try to break the code into two modes or something, based on some conditions.
But for this to work, the frequency of the serial writing has to be higher than the frequency of the microbasic loop. How can I guarantee that? I probably cannot use timers because I am doing other things in the script, but I can try to break the code into two modes or something, based on some conditions.
Please Log in or Create an account to join the conversation.
7 years 1 month ago #29531748
by niko
Replied by niko on topic Changing digital outputs when watchdog triggers
Look, the biggest frequency you can achieve using script is 1kHz (1ms). Using the wait command you are flexible to adapt the frequency to the desired one, no matter if you do other things in script as well.
Please Log in or Create an account to join the conversation.
Time to create page: 0.057 seconds