|
DUDS
|
Distributed Update of Data from Something
|
Support for the AMG88xx, a low resolution thermal camera. More...
#include <AMG88xx.hpp>
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 double8x8 & | image () 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::I2c > | com |
| 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... | |
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.
Definition at line 46 of file AMG88xx.hpp.
| typedef double duds::hardware::devices::instruments::AMG88xx::double8x8[8][8] |
Image array type.
Definition at line 172 of file AMG88xx.hpp.
|
private |
Operating modes.
Definition at line 66 of file AMG88xx.hpp.
| 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.
| c | The I2C interface to communicate with the device. The address should be either 0x68 or 0x69. |
Definition at line 19 of file AMG88xx.cpp.
| 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.
| 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.
| fps1 | True for 1Hz sampling rate. |
Definition at line 63 of file AMG88xx.cpp.
|
inline |
Provides direct access to the most recent sample.
Definition at line 177 of file AMG88xx.hpp.
|
inline |
Configures the device for a 1Hz sampling rate.
Definition at line 131 of file AMG88xx.hpp.
|
inline |
Same as start().
Definition at line 152 of file AMG88xx.hpp.
| 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.
Definition at line 117 of file AMG88xx.cpp.
Referenced by resume().
| void duds::hardware::devices::instruments::AMG88xx::start | ( | ) |
Transitions the device to normal operating mode so that it begins sampling.
| DeviceMisidentified | The device failed to transition to the normal operating mode. This likely means the device is not an AMG88xx. |
Definition at line 78 of file AMG88xx.cpp.
| void duds::hardware::devices::instruments::AMG88xx::suspend | ( | ) |
Transitions the device to sleep mode.
Definition at line 109 of file AMG88xx.cpp.
Referenced by resume(), and ~AMG88xx().
| duds::data::Quantity duds::hardware::devices::instruments::AMG88xx::temperature | ( | ) | const |
Returns the temperature of the device as reported by its thermistor.
Definition at line 132 of file AMG88xx.cpp.
Referenced by image().
|
inline |
Configures the device for a 10Hz sampling rate.
Definition at line 137 of file AMG88xx.hpp.
| struct { ... } |
|
private |
The I2C communication interface.
Definition at line 50 of file AMG88xx.hpp.
Referenced by AMG88xx(), configure(), sample(), start(), and suspend().
| unsigned int duds::hardware::devices::instruments::AMG88xx::fps1Not10 |
Frame rate setting.
Definition at line 94 of file AMG88xx.hpp.
Referenced by configure(), and start().
|
private |
| 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().
| 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().
|
private |
Used to read in sampled data from the device.
Definition at line 54 of file AMG88xx.hpp.
|
private |
Thermistor temperature.
Definition at line 62 of file AMG88xx.hpp.
Referenced by sample(), and temperature().