This was a quick, fun exercise, to build a complete thermal camera using the Beaglebone Black, a small LCD and a thermal array sensor.
It was really more of a consolidation, combining some earlier experiements.
The image here shows the entire assembly, capturing an image of my hand (taken from about 1 foot away. It was hard to take a photo at the same time!).
The final code is attached. The information on each sub-section is at these links:
I2C interface code (either compile it, or just copy the libi2cfunc.a file to /usr/lib, and the i2cfunc.h file to /usr/include )
PRU information (you will need to install the PRU assembler if you want to make changes - if you don't, you can use the pre-assembled .bin file in the zip file).
The attached code is not tidy, but it works. It could be optimised a lot, I made no effort to do this. Currently the image updates at about 1Hz, but this could be improved many times. Many conversions are done that could be simplified.
Edit: It looks like actually the whole process is occurring at many tens of Hz, but the LCD updates at about once per second; this looks like a limitation of the LCD display (the update over the serial interface is occurring rapidly, but internally it presumably only updates once per sec. An alternative display is required!).
Edit 2: It turned out that the LCD was fine; the thermal sensor was set to internally update at 1Hz, regardless of the readout speed. The version 2 code attached has it now set to 16Hz in ir.c, but possibly 4Hz or 8Hz would be sufficient and give higher accuracy.
Compiling and running the code
Here is how to use the code:
First, make sure the I2C library is installed as mentioned above.
Then, copy the attached code into any folder, unzip and then follow one of these two steps:
1. If you have not installed the PRU assembler:
make partclean;make ir_app; make dtfrag
2. If you have installed the PRU assembler:
Copy the generated .dtbo file to the /lib/firmware folder.
Then, type the following (it could be placed in a startup script when the board has booted):
echo cape-bone-lcd18 > $SLOTS
The code can now be run by typing:
To generate video the code was modified (v3 code) to accept a file prefix.
This will generate files beginning with img, i.e.
img00000.png, img00001.png, etc.
Then, they can be converted into a video using:
avconv -i img%05d.png -b:v 1000k test.mp4
Another video (the temperature to color conversion had a bug in the earlier video, fixed in the v3 code):
Here is another photo, this time of a tub of icecream.
This is holding an ice lolly on a stick:
It would be nice to be able to retrieve the images via a PC, either stream the images, or to have a web server to access them, or just dump files in a folder for now. I didn't get a chance to try any of these.
If I get time I might build this into an enclosure, as a permanent project (powering the the entire thing from a Li-Ion battery that connects on the board (Olimex BATTERY-LIPO1400mAh fits, if you buy the right connector).