The Python side of the project is coming along, with the GUI now able to reliably receive Temperature updates from the µC and plot them in real-time using pyqtgraph. So far the themocouple seems accurate and it is very responsive. I get a 0.25 °C resolution and what seems to be +- 2 or 3 degree accuracy. Overall the MAX31855 has proven to be a pretty reliable thermocouple unit.
For the µC code I have made UART receive interrupt driven and non-blocking so that everything operates more smoothly and there are less bind-ups. The UART receive works by serving an ISR each time a new byte is put into the UART data register on the ATMEGA328p. The ISR puts the byte into a large buffer that is expected to be larger than any anticipated message and then checks if the received character is a newline. If so it raises a global flag saying that a new string is ready to service by the main program logic, and it is read on the next main() loop iteration. This is definitely not the most robust solution, given the buffer could be overflowed, the termination character may not be a newline given some circumstances, etc. I am debating on adding a circular buffer instead of a linear buffer to stop potential overflows. For termination watching I may expand the set of characters it recognizes as termination indicators, such as carriage return and tab for example.
For sending temperature data the main loop is delayed every iteration by a set number of milliseconds, at the moment 250 ms. This more or less sets a constant output rate of temp data. Given that temperature control for such a large thermal mass as a 900W heating element isn't particularly fast, extremely precise timing control is not necessary. As long as messages get to where they need to go within about a second, I should be happy.
One interesting bug I found while programming is that Python multiprocess Pipes seem to need a consumer using the .recv() function to work properly. Ie. if data is being put into the Pipe and not being read, this will go wrong eventually. I discovered this when testing the temperature plotting. I would have 150 sample be plotted, then everything would stop. The program would still be connected to the µC and receiving bytes off the serial port, but they wouldn't go from there to other parts of the program. I finally localized the issue to the where the program put data into the Pipe - the write() function would start blocking after 150 samples and not complete. Putting something on the other end and calling recv() solved the problem. As long as data flows into and then fairly quickly out of the PIpe everything works fine. Perhaps something I will read up more on.
Changing gears from software, I also began work on the actual enclosure for the hot plate. At the moment the plan is to have a wooden inner frame made from 1x2" pine covered in Plexiglas for walls. The whole thing will be a 7x7x7" cube with the heating puck sticking from the top. In addition the top of the cube, but below the heating puck will be a thin piece of metal plate to act as a heat shield and also for a cleaner look. biggest challenges right now are how to get a fan mounted onto the side of the unit and how to provide access through the plexiglas for an AC plug and a micro USB connector. I do not really have the tooling for plexiglas so cutting a slot or such will be difficult. I have half a mind of raising the cube another inch and just dropping cables through the center and out a side. More details on the frame construction will come in future logs.
In the meantime here are some photos of the frame construction:
Measuring plexiglas cuts.
Cutting the plexiglas with good old razor blades.
Crude and fairly dangerous, but a really fast way of getting all the edges to be equal.
So this will be a reference of what the bottom and top wooden frames will look like. Having just pulled this from the clamps I realized I didn't quite make sure everything was flat and true, so it has a horrible...
Read more »