DUDS
Distributed Update of Data from Something
duds::hardware::devices::instruments::AMG88xx Class Reference

Support for the AMG88xx, a low resolution thermal camera. More...

#include <AMG88xx.hpp>

Inheritance diagram for duds::hardware::devices::instruments::AMG88xx:
Collaboration diagram for duds::hardware::devices::instruments::AMG88xx:

Public Types

typedef double double8x8[8][8]
 Image array type. More...
 

Public Member Functions

 AMG88xx (std::unique_ptr< duds::hardware::interface::I2c > &c)
 Attempts to reset the device and put it into sleep mode. More...
 
 ~AMG88xx ()
 Suspends the device operation (sleep mode) if a DeviceMisidentified error did not occur on the last start() call. More...
 
void configure (bool fps1)
 Configures the device. More...
 
const double8x8image () const
 Provides direct access to the most recent sample. More...
 
void oneFps ()
 Configures the device for a 1Hz sampling rate. More...
 
void resume ()
 Same as start(). More...
 
void sample ()
 Reads a sample from the device. More...
 
void start ()
 Transitions the device to normal operating mode so that it begins sampling. More...
 
void suspend ()
 Transitions the device to sleep mode. More...
 
duds::data::Quantity temperature () const
 Returns the temperature of the device as reported by its thermistor. More...
 
void tenFps ()
 Configures the device for a 10Hz sampling rate. More...
 

Private Types

enum  Mode { Normal, Sleep, StandBy60, StandBy10 }
 Operating modes. More...
 

Private Attributes

struct {
   unsigned int   fps1Not10: 1
 Frame rate setting. More...
 
   unsigned int   misid: 1
 True when the last read of the operating mode failed on error, or provided a result that did not match the operating mode that was just set. More...
 
   unsigned int   mode: 2
 Current operating mode. More...
 
}; 
 
std::unique_ptr< duds::hardware::interface::I2ccom
 The I2C communication interface. More...
 
double img [8][8]
 Temperature image. More...
 
duds::hardware::interface::Conversation read
 Used to read in sampled data from the device. More...
 
std::int16_t temp
 Thermistor temperature. More...
 

Detailed Description

Support for the AMG88xx, a low resolution thermal camera.

The first few frames captured may not be a good representation of what the camera is looking at. It clears up quickly, though, and isn't totally wrong, so using the first frame to initialize values for an exponential moving average likely will work ok.

The thermal image output is somewhat noisy, so something like an exponential moving average may be needed to smooth out the data. The temperature from the thermistor is much less noisy, but can climb to more than 1K above the ambient air temperature from the heat generated by sampling.

The further an object is from the sensor, assuming it is still large enough to cover whole pixels, the more the reported temperature will skew towards the temperature of the sensor. This is readily noticeable within the documented 5 meter range.

The device is a bit finicky with how it switches between its sleep and normal operation modes. Earlier in development, the code would sometimes fail to convince the device to sample and result in either frames of all zero temperature (Celsius) or all identical non-zero frames. The failure occurred without any reported error, and the device reported its current operating mode as normal (used for misidentified device check). While the current code does not exhibit the problem, the failure may still be observed if other software uses the device first without an intervening power cycle. A second attempt at using the device may be enough to get past the issue.

Author
Jeff Jackowski
Examples:
amg88xxtest.cpp.

Definition at line 46 of file AMG88xx.hpp.

Member Typedef Documentation

◆ double8x8

typedef double duds::hardware::devices::instruments::AMG88xx::double8x8[8][8]

Image array type.

Definition at line 172 of file AMG88xx.hpp.

Member Enumeration Documentation

◆ Mode

Operating modes.

Enumerator
Normal 

Regular sampling at 1Hz or 10Hz.

Sleep 

No sampling ; reduced power usage.

StandBy60 

Only mention in documentation is "Stand-by mode (60sec intermittence)".

Not used here.

StandBy10 

Only mention in documentation is "Stand-by mode (10sec intermittence)".

Not used here.

Definition at line 66 of file AMG88xx.hpp.

Constructor & Destructor Documentation

◆ AMG88xx()

duds::hardware::devices::instruments::AMG88xx::AMG88xx ( std::unique_ptr< duds::hardware::interface::I2c > &  c)

Attempts to reset the device and put it into sleep mode.

Postcondition
The device is suspended; no samples are being taken. The 10Hz sampling rate is selected.
Parameters
cThe I2C interface to communicate with the device. The address should be either 0x68 or 0x69.

Definition at line 19 of file AMG88xx.cpp.

◆ ~AMG88xx()

duds::hardware::devices::instruments::AMG88xx::~AMG88xx ( )

Suspends the device operation (sleep mode) if a DeviceMisidentified error did not occur on the last start() call.

Definition at line 57 of file AMG88xx.cpp.

Member Function Documentation

◆ configure()

void duds::hardware::devices::instruments::AMG88xx::configure ( bool  fps1)

Configures the device.

The only option is the frame rate. Calling this function is not required. The 10Hz sampling rate is the default.

Parameters
fps1True for 1Hz sampling rate.

Definition at line 63 of file AMG88xx.cpp.

Referenced by oneFps(), and tenFps().

◆ image()

const double8x8& duds::hardware::devices::instruments::AMG88xx::image ( ) const
inline

Provides direct access to the most recent sample.

Warning
This is not thread-safe.
Examples:
amg88xxtest.cpp.

Definition at line 177 of file AMG88xx.hpp.

◆ oneFps()

void duds::hardware::devices::instruments::AMG88xx::oneFps ( )
inline

Configures the device for a 1Hz sampling rate.

Examples:
amg88xxtest.cpp.

Definition at line 131 of file AMG88xx.hpp.

◆ resume()

void duds::hardware::devices::instruments::AMG88xx::resume ( )
inline

Same as start().

Definition at line 152 of file AMG88xx.hpp.

◆ sample()

void duds::hardware::devices::instruments::AMG88xx::sample ( )

Reads a sample from the device.

This does not cause the device to sample; it does so at regular intervals based on its own clock. Reading a second time before the device takes the next sample will result in an identical sample to the last one read. Two sampled frames will never be mixed together.

Precondition
The device is in its normal operating mode. This is done by start().
Examples:
amg88xxtest.cpp.

Definition at line 117 of file AMG88xx.cpp.

Referenced by resume().

◆ start()

void duds::hardware::devices::instruments::AMG88xx::start ( )

Transitions the device to normal operating mode so that it begins sampling.

Postcondition
The device will sample at the configured sampling rate.
Exceptions
DeviceMisidentifiedThe device failed to transition to the normal operating mode. This likely means the device is not an AMG88xx.
Examples:
amg88xxtest.cpp.

Definition at line 78 of file AMG88xx.cpp.

Referenced by resume(), and tenFps().

◆ suspend()

void duds::hardware::devices::instruments::AMG88xx::suspend ( )

Transitions the device to sleep mode.

Postcondition
The device will cease sampling.

Definition at line 109 of file AMG88xx.cpp.

Referenced by resume(), and ~AMG88xx().

◆ temperature()

duds::data::Quantity duds::hardware::devices::instruments::AMG88xx::temperature ( ) const

Returns the temperature of the device as reported by its thermistor.

Examples:
amg88xxtest.cpp.

Definition at line 132 of file AMG88xx.cpp.

Referenced by image().

◆ tenFps()

void duds::hardware::devices::instruments::AMG88xx::tenFps ( )
inline

Configures the device for a 10Hz sampling rate.

Examples:
amg88xxtest.cpp.

Definition at line 137 of file AMG88xx.hpp.

Member Data Documentation

◆ @7

struct { ... }

◆ com

std::unique_ptr<duds::hardware::interface::I2c> duds::hardware::devices::instruments::AMG88xx::com
private

The I2C communication interface.

Definition at line 50 of file AMG88xx.hpp.

Referenced by AMG88xx(), configure(), sample(), start(), and suspend().

◆ fps1Not10

unsigned int duds::hardware::devices::instruments::AMG88xx::fps1Not10

Frame rate setting.

Definition at line 94 of file AMG88xx.hpp.

Referenced by configure(), and start().

◆ img

double duds::hardware::devices::instruments::AMG88xx::img[8][8]
private

Temperature image.

Definition at line 58 of file AMG88xx.hpp.

Referenced by image(), and sample().

◆ misid

unsigned int duds::hardware::devices::instruments::AMG88xx::misid

True when the last read of the operating mode failed on error, or provided a result that did not match the operating mode that was just set.

False after an attempt to change the operating mode succeeds. Used to avoid suspending the device in the constructor if the last operating mode change attempt fails in an attempt to prevent the next attempt at using the device from failing. Earlier in development, the device would work for one run of the test program, and fail on the next; the alternation of success and failure was consistent. I hoped this might help resolve the issue.

Definition at line 106 of file AMG88xx.hpp.

Referenced by start(), and ~AMG88xx().

◆ mode

unsigned int duds::hardware::devices::instruments::AMG88xx::mode

Current operating mode.

Definition at line 90 of file AMG88xx.hpp.

Referenced by AMG88xx(), configure(), start(), and suspend().

◆ read

duds::hardware::interface::Conversation duds::hardware::devices::instruments::AMG88xx::read
private

Used to read in sampled data from the device.

Definition at line 54 of file AMG88xx.hpp.

Referenced by AMG88xx(), and sample().

◆ temp

std::int16_t duds::hardware::devices::instruments::AMG88xx::temp
private

Thermistor temperature.

Definition at line 62 of file AMG88xx.hpp.

Referenced by sample(), and temperature().


The documentation for this class was generated from the following files: