🐛 [BUG] - Thermocouple danger...
Description
The code provided to enable ADS1118 with K-type thermocouple works perfectly to read the values from the ADC differential converter in the ADS... No problem on that part...
Where it is very wrong , and extremely dangerous: is this: If the SPI bus that carry the data is busy when the library tries to read the value, the code returns a "SHADOW VALUE" (last read value) as the current value... That is fantastic....
But to one exception.... If I disconnect the Thermocouple.... the code continues to send me the last read value (ex: 24 celcius ) but in reality, there is no more thermocouple connected, it is not the SPI BUS that is busy, so even if the heater is at 360c, it will only send 24c...
and I have a long list of other problems... if anyone wants to correct them... I can even tell you the exact location of the bugs, and what to do to correct them...
I have decided a few months ago, that I will never touch programming again... 45 years was enough, your turn now...
Reproduction steps
turn on the printer...
wait for firmware to boot and execute...
when reading the value from thermocouple (first hotend)... disconnect the thermocouple from the board...
continue to read the last value read FOREVER
even if you start the heater at 300c (of course !)
Screenshots
Do you really need a screen shot !
Logs
Printer
Dremel 3D20
Marlin Version
FlashForge_Marlin 2.1.x
Marlin Features
No response
I didn't took the tile to add debug code and log everything, or analyze the code manually (follow execution mentally !!!)
But it is surely near of what I think (but I didn't verified it )
but the "bug" should be located in the file
ads1118.cpp
probably in the function:
<<<< int ads1118_read_raw( int ch_id ) >>>>
if( !ads1118_spi.Instance ) return shadow_data[ch_id]; // should return ( no instance error )
if( spi_is_busy() ) return shadow_data[ch_id]; // this is the right use of the shadow data, if the "spi_is_busy()" is returning TRUE only when busy
#if ( USE_POLLING == 0 ) if( (millis()-delay_ms) < 18u ) //... I didn't verify how it handles the "NO TC k-type", return shadow_data[ch_id]; // so it should read 0Volts, and detect the problem... #endif
I have read way too many pages of datasheets in my life, not that I can't, I no longer want to see the start of a page...
Your turn to correct the problem...