How to let RRF know my arduino is still alive
-
Hello,
Normally I search the internet for guidance while I am halfway with a project , this time I thought I will ask around before I start ... so let me start by explaining my setup:
I am running RRF 3.3.0 on an SKR2 board (sorry) and it controlles a SLS 3D printer. The temperature of the powderbed is measured with an IR-sensor that is connected to a Teensy board (=arduino). The Teensy board emulates a max6675 thermocouple, and RRF reads the powderbed via a SPI communication. Meanwhile the Teensy board also needs to check what the set-temperature is. It does that by sending a M409 command over the serial port, and thus checking the Object model tree of RRF 3.3.0
And this work great!
But.... if mid-print the IR-sensor dies, or teensy hangs for whatever reason, and keeps sending the same temperature over SPI, then RRF has no way of knowing this...
So my goal now it to have RRF check if Teensy is still alive.
My initial idea is to have teensy send a G-code to set someting in the object model tree, like switching on a fake fan, and do that every 30 seconds.
Than use Deamon.g to check if the fake fan is on every minute.
If the fake fan is on, deamon.g turns it off
If the fake fan is off, deamon.g will stop the print and turn off the mainheater switch.Now my question is if there is a nicer way of doing this, my methode feels a bit clumsy using a "fake fan" and all...
Any input is welcome!
-
@bitofadummy said in How to let RRF know my arduino is still alive:
β¦ if mid-print the IR-sensor dies, or teensy hangs for whatever reason β¦
Donβt happen to know the Teensy, but with an Arduino, you can use the built-in watchdog to detect a hanging program. However, a controller should not die out of the blue, so you need to look for the reason. In most cases, the controller runs out of RAM or exhausts the stack. I think you will have to rework your sketch.
-
@infiniteloop
Whell the last time it happened the teensy hung mid print was because of af bad solder connection of the IR-sensor, and the library for that melexis sensor makes Teensy hang. So I am looking in on to how to avoid that. But it made me realize that there can be other bugs that makes the teensy stop working...But thank you for the watchdog tip, I will look into that to!
-
the library for that melexis sensor makes Teensy hang.
Do you use the mlx90614? With a quick DuckDuckGo search for "arduino mlx90614", I found at least a second library from Adafruit which you might prefer over the one provided by Melexis. Maybe you find other libraries as well. Generally, you should never use libraries who tend to mess-up your Arduino
-
Different Teensys have differing watchdog timers. The main gotcha I know of is that on Teensy LC if you use the hardware watchdog you're stuck with it - once you set it running you can't switch it off, so you then need to service it indefinitely (until you reset the chip). It also has limited timeout options.
You could use a variable rather than a fake fan, e.g. put
global tick=0
in config.sys and have the teensy sendset global.tick=1
and damon.g canset global.tick=0
.(I haven't tested that the duet responds to meta-gcode on the serial ine, but that's the only thing that would stymie this approach, I think).Yes, it works (at least on RRF 3.4.4). I've put a teensy sendingset global.tick=1
on the serial port every five seconds, and then you can watch the variable in the object model viewer - set it to something else and see it jump back to 1. -
@achrn I like your approach but Iβd probably reverse it. Have daemon.g keep adding to a global timeout variable and have the board keep setting it to zero. If your timeout goes above a threshold you could post a notification
-
@infiniteloop
I agree ! -
@achrn
Wow, that was what I was looking for,
works great thanks! -
@Sindarius
Yes, I added you option as well. It prevents a fals trigger at startup as daemon.g runs every 10 seconds.
Now daemon.g runs 5 times before it is triggered and halts a print.
very nice ! -
well I wanted to end by showing my code, but it gets rejected as spam...
-
@bitofadummy try again, I upvotes a few posts so that might help get it past the spam filters