Q2: AMG88xx thermal camera demo - how to modify for a differ

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tkinsman
 
Posts: 170
Joined: Sun Sep 25, 2016 2:04 pm

Q2: AMG88xx thermal camera demo - how to modify for a differ

Post by tkinsman »

I am trying to understand and modify the thermal camera demo.

It was intended to use a 1.4" TFT display that is 128 x 128 pixels.
That's out of stock, so I got a 1.8" TFT that is 128x160.

(I went and got Files --> Examples --> Adafruit AMG88xx --> thermal_cam)

How should I modify this for the different sized display?

Does anyone have any experience with this?

User avatar
adafruit_support_bill
 
Posts: 88090
Joined: Sat Feb 07, 2009 10:11 am

Re: Q2: AMG88xx thermal camera demo - how to modify for a di

Post by adafruit_support_bill »

It looks like the code will adapt the resolution to the size of the TFT dsplay you are using.

Code: Select all

uint16_t boxsize = min(tft.width() / INTERPOLATED_COLS, tft.height() / INTERPOLATED_COLS);

User avatar
tkinsman
 
Posts: 170
Joined: Sun Sep 25, 2016 2:04 pm

Re: Q2: AMG88xx thermal camera demo - how to modify for a di

Post by tkinsman »

I started with the example from File-->Examples-->AMG88xx Thermal Camera -->thermal_cam_interpolate.
For a learning exercise for students the code would benefit from a more low-level comments added in about what is going on.

The "pixels" on the sensor is always 8x8. That's fixed by the thermal sensor.
I probably would have named this variable "sensor_array".

Code: Select all

float pixels[AMG_COLS * AMG_ROWS];
Internally, the code allocates a "smeared_image" for the interpolated image.
This image might or might be the same size as the final display, or smaller.
I re-wrote this for an Arduino Uno as:

Code: Select all

#define INTERPOLATED_COLS 24
#define INTERPOLATED_ROWS 24
float dest_2d[INTERPOLATED_ROWS * INTERPOLATED_COLS]; 
This dest_2d variable is what causes the stack to overflow on an Uno.

The "boxsize" is how much to replicate each pixel by so that it fits on the final display.
So, the boxsize is how many times to replicate each "pixel" in the "pixels" variable to get to the dest_2d variable.

I got this working by setting INTERPOLATED_ROWS and INTERPOLATED_COLS to 8 (the same size as the sensor), and then forcing the boxsize to be 16. This works for my 1.8" TFT display, which is 128x160.


As an educator, we are always fighting the motivation and cost battles. We want fun examples that are motivating, but also low cost. By using these hacks I was able to get a demo such that the kids could build a thermal camera with one AMG8833 (AMG8833 ~$40) and one 1.8" TFT (ST7735R ~$20). This is only about a $60 additional cost. I think I can justify this to my management to get students to want to learn about computers. :-)

User avatar
adafruit_support_bill
 
Posts: 88090
Joined: Sat Feb 07, 2009 10:11 am

Re: Q2: AMG88xx thermal camera demo - how to modify for a di

Post by adafruit_support_bill »

Good to hear you got it working. Thanks for posting your results.

User avatar
tkinsman
 
Posts: 170
Joined: Sun Sep 25, 2016 2:04 pm

Re: Q2: AMG88xx thermal camera demo - how to modify for a di

Post by tkinsman »

Opps:

I meant to say that I re-wrote it so that the dest_2D was 8x8 internally --> so no interpolation was really used.

User avatar
tkinsman
 
Posts: 170
Joined: Sun Sep 25, 2016 2:04 pm

Re: Q2: AMG88xx thermal camera demo - how to modify for a di

Post by tkinsman »

Just to let folks know -- I finally got this working on an Arduino UNO.

I used linear interpolation along each 8 pixel row , for two rows at a time, to create two rows of pixels that were 128 pixels long.

Then I interpolated each of the 15 rows between those two rows, and sent each one to the TFT display. This fit in the 2K bytes available on an Arduino.

To do this I had to use fixed-point math, which is scaled math. Instead of using floating point math (A * 0.0625 + ... ) I used multiples of 16, and then divided by 16 later by shifting off 4 bits. ( A / 16 == A >> 4 ).

The results do not look dramatic in a picture of the display taken in the dark, but they are much better in person. They are not "mine craft" block images.

User avatar
adafruit_support_bill
 
Posts: 88090
Joined: Sat Feb 07, 2009 10:11 am

Re: Q2: AMG88xx thermal camera demo - how to modify for a di

Post by adafruit_support_bill »

Fixed point math is often very useful. Not just for memory savings - but for better control of representation and rounding errors.

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”