Friday, July 19, 2013

Multiple ADC Readings

Heated Bed Working

It turns out the BeagleBone ADC "helper" kernel drivers are very particular about exactly how you talk to them.  If you try to read from them too fast, or even worse have two threads trying to read ADC values at the same time, Bad Things happen.  What exactly?  You can get illegal values (outside the 0-4095 range of the ADC), values from the wrong analog input channel, or have your program crash with access errors.  This has been preventing me from getting the heated bed working on my printer, since I initially coded the ADC thermistor HAL component with the idea that each thermistor would be read by it's own thread.

I have re-worked the python code to support reading more than one thermistor, and it seems to be working well.  I managed to finish a print that took a couple hours, and I left the system running overnight and it is still working as expected this morning.  For comparison, with two threads reading thermistor values, one of the threads would die within a couple of minutes.

Configuration should be fairly obvious, refer to the example BeBoPr and BeBoPr-Bridge configurations.  There is a new --num_chan parameter, and the existing --adc and --therm parameters now take a list of values, one for each analog input channel.  Also added is a short-hand notion for the thermistor table, so you can now use "1" (the equivalent Marlin thermistor table number) instead of "epcos_B57560G1104".  Handy if you have 3 thermistors attached!


  1. The link is dead. I'm having trouble with this as well, how did you solve it?

    1. In a horribly grotesque and hackish manner. Basically, I just put exception handling around the ADC reading code and live with the fact that every N samples will fail. Code is in github: