One , introduce

1, Internal block diagram

        You can see AMG8833 There is infrared dot matrix temperature measurement inside , It also has a thermistor . Use the same ADC Sampling , And give it to Control.

2, Device parameters

Temperature measurement points :64(8x8 Matrix of )

Frame rate :10 Frames per second or 1 Frames per second

Resolution of infrared temperature measurement :0.25℃

Temperature range of thermistor measurement :-20℃~80℃

Resolution of thermistor :0.0625℃

Accuracy of infrared temperature measurement :High gain The error is within 2.5℃ within ;Low gain The error is within 3℃ within .

3, The arrangement order of the lattice is : Right to left , From bottom to top . So the bottom right is the first point .

 

4, Perspective is level 60 degree , vertical 60 degree .

5, schematic diagram

2 Foot and 3 Feet are IIC Communication pin , Maximum speed 400K.

4 The pin is the interrupt pin , If INT control The interrupt function is activated in the register , When interruption occurs , This pin will pull down .

5 Feet are IIC Device address selection pin . Pull down , The device address is 110 1000, Namely 0x68. pull up , The device address is 110 1001, Namely 0x69.

High equipment address 7 position , The lowest bit is the read-write bit ,0 It means writing ,1 Express reading . So when 5 Lower your feet , When writing ,8 Bit data is :1101
0000, Namely 0xD0, During read operation ,8 Bit data is :1101 0001, Namely 0xD1.

6 Feet are the ground .

9 Foot and 13 Feet are VDD, sure 3.3V or 5V power supply .

10 Pin to a capacitor and resistor .

12 Pin to a capacitor .

Two , register

1,Power Control register : set up AMG8833 Working mode of

Working modes include 4 species :

Transformation relationship between patterns :

notes :

(1) Write operations in sleep mode only take effect after entering normal mode .

(2) Read operations are invalid in sleep mode .

2,Reset register : Perform soft reset .

There are two ways to reset :

        Flag Reset Will clear Status register (0x04), Interrupt flag , Interrupt table (0x10~0x17)

        Initial Reset Will reset flag , And make AMG8833 The parameters of the .

3,Frame Rate register : Set frame rate

bit0: Setting Frame Mode
1: 1FPS
0: 10FPS

4,Interrupt Control register : Configure interrupt function

bit1: INTMOD
1: Absolute Value Interrupt Mode
0: Difference Interrupt Mode
bit0: INTEN
1: INT Pin output enable
0: INT Pin inhibit output ( Keep high resistance )

5,Status register : Overflow flag and interrupt flag

bit3: OVF_THS
1: Thermistor temperature output overflow mark
(Value of Thermistor (0x0E,0x0F) : 0xFFF)
bit2: OVF_IRS
1: Infrared temperature output overflow mark
(Value of Temperature Register(0x80~0xFF): 0xFFF)
bit1: INTF
1: Interrupt occurred flag
(Value of Interrupt Table Register(0x10~0x17): Except for 0x00)

6,Status Clear register : Clear overflow flag and interrupt flag

bit3: OVT_CLR
1: Clear the temperature output overflow mark of thermistor
bit2: OVS_CLR
1: Clear infrared temperature output overflow mark
bit1: INTCLR
1: Clear interrupt flag

7,Average register : Set moving average output mode

bit5: MAMOD
1::Twice moving average Output Mode

0:No moving average

8,Interrupt Level register : Set the upper limit of the interrupt , Lower limit , hysteresis .

INT_LVL_H [11:0]: Interrupt upper limit value , When the temperature is higher than this value , Output interrupt and set Interrupt Table register .

INT_LVL_L [11:0]: Interrupt lower limit , When the temperature is below this value , Output interrupt and set Interrupt Table register .

INT_HYS [11:0]: Set upper limit value , Hysteresis value of lower limit value , Similar to Schmidt trigger .

        above 3 It's all data 12 Bit data . The highest bit is the sign bit , The value is 0 It means positive , The value is 1 It means negative . The step value is 0.25℃.

9,Thermistor register : Temperature value measured by thermistor

Yes 12 Bit data . The highest bit is the sign bit , The value is 0 It means positive , The value is 1 It means negative . The step value is 0.0625℃. Examples are as follows :

10,Interrupt Table register : Displays which pixel is interrupted

        When 64 The temperature of one of the pixels is higher or lower than Interrupt Level The upper and lower limits set in the register , It'll be there Interrupt
Table Corresponding bit setting value of register . The value is 1 There was an interruption on behalf of ,0 No .

11,Temperature register : Temperature value measured by infrared lattice

Yes 12 Bit data . The highest bit is the sign bit , The value is 0 It means positive , The value is 1 It means negative . The step value is 0.25℃. Examples are as follows :

        0x80 and 0x81 The temperature value of the first pixel is saved ,1~64 The corresponding address of the pixel is 0x80~0xFF.

notes :

(1)1~64 pixel (0x80~0xFF) The temperature values are updated together , No instructions are required .

(2)0x80~0xFF The data is read at one time , So you don't have to worry about mixing the new temperature with the old one .

Three , Register table

...

Four , Driver code

1,AMG_IIC.h
#ifndef __AMG_I2C_H #define __AMG_I2C_H #include "stdint.h" #include "sys.h"
#include "delay.h" #define AMG_SDA_RCC RCC_APB2Periph_GPIOB #define AMG_SDA_PIN
GPIO_Pin_7 #define AMG_SDA_IOx GPIOB #define AMG_SCL_RCC RCC_APB2Periph_GPIOB
#define AMG_SCL_PIN GPIO_Pin_6 #define AMG_SCL_IOx GPIOB #define AMG_SDA_IN()
{GPIOB->CRL&=0x0FFFFFFF;GPIOB->CRL|=8<<28;} #define AMG_SDA_OUT()
{GPIOB->CRL&=0x0FFFFFFF;GPIOB->CRL|=3<<28;} #define AMG_IIC_SCL PBout(6) //SCL
#define AMG_IIC_SDA PBout(7) //SDA #define AMG_READ_SDA PBin(7) // input SDA #define
AMG88xx_ADR 0xD0 //5 Device address when the foot is pulled low //Status #define STATUS_OK 0x00 #define
STATUS_FAIL 0x01 void AMG8833_IIC_Init(void); u8 AMG_IIC_Write_1Byte(u8
SlaveAddress, u8 REG_Address,u8 REG_data); u8 AMG_IIC_Read_1Byte(u8
SlaveAddress, u8 REG_Address,u8 *REG_data); uint8_t AMG_I2C_Read_nByte(uint8_t
SlaveAddress, uint8_t REG_Address, uint8_t *buf, uint16_t len); #endif
2,AMG_IIC.c
#include "AMG_IIC.h" void AMG8833_IIC_Init(void) { GPIO_InitTypeDef
GPIO_InitStructure; RCC_APB2PeriphClockCmd( AMG_SDA_RCC, ENABLE );
GPIO_InitStructure.GPIO_Pin = AMG_SDA_PIN; // port configuration GPIO_InitStructure.GPIO_Mode
= GPIO_Mode_Out_PP ; // Push pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//50Mhz speed GPIO_Init(AMG_SDA_IOx, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(
AMG_SCL_RCC, ENABLE ); GPIO_InitStructure.GPIO_Pin = AMG_SCL_PIN; // port configuration
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ; // Push pull output
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50Mhz speed
GPIO_Init(AMG_SCL_IOx, &GPIO_InitStructure);
GPIO_SetBits(AMG_SDA_IOx,AMG_SDA_PIN);//SDA High output
GPIO_SetBits(AMG_SCL_IOx,AMG_SCL_PIN);//SCL High output } void AMG_IIC_Start(void) {
AMG_SDA_OUT();//sda Line output AMG_IIC_SDA=1; AMG_IIC_SCL=1; delay_us(4);
AMG_IIC_SDA=0;//START:when CLK is high,DATA change form high to low
delay_us(4); AMG_IIC_SCL=0;// Hold on I2C Bus , Prepare to send or receive data } // produce IIC Stop signal void
AMG_IIC_Stop(void) { AMG_SDA_OUT();//sda Line output AMG_IIC_SCL=0;
AMG_IIC_SDA=0;//STOP:when CLK is high DATA change form low to high delay_us(4);
AMG_IIC_SCL=1; AMG_IIC_SDA=1;// send out I2C Bus end signal delay_us(4); } u8
AMG_IIC_Wait_Ack(void) { u8 ucErrTime=0; AMG_SDA_IN(); //SDA Set as input
AMG_IIC_SDA=1;delay_us(1); AMG_IIC_SCL=1;delay_us(1); while(AMG_READ_SDA) {
ucErrTime++; if(ucErrTime>250) { AMG_IIC_Stop(); return 1; } }
AMG_IIC_SCL=0;// Clock output 0 return 0; } // produce ACK answer void AMG_IIC_Ack(void) {
AMG_IIC_SCL=0; AMG_SDA_OUT(); AMG_IIC_SDA=0; delay_us(2); AMG_IIC_SCL=1;
delay_us(2); AMG_IIC_SCL=0; } // Not produced ACK answer void AMG_IIC_NAck(void) {
AMG_IIC_SCL=0; AMG_SDA_OUT(); AMG_IIC_SDA=1; delay_us(2); AMG_IIC_SCL=1;
delay_us(2); AMG_IIC_SCL=0; } //IIC Send a byte // Return whether the slave has answered or not //1, Yes //0, No response void
AMG_IIC_Send_Byte(u8 txd) { u8 t; AMG_SDA_OUT(); AMG_IIC_SCL=0;// Pull down the clock to start data transmission
for(t=0;t<8;t++) { if((txd&0x80)>>7) AMG_IIC_SDA=1; else AMG_IIC_SDA=0;
txd<<=1; delay_us(2); AMG_IIC_SCL=1; delay_us(2); AMG_IIC_SCL=0; delay_us(2); }
} // read 1 Bytes ,ack=1 Time , send out ACK,ack=0, send out nACK u8 AMG_IIC_Read_Byte(void) { unsigned char
i,receive=0; AMG_SDA_IN(); //SDA Set as input AMG_IIC_SDA = 1; delay_us(4);
for(i=0;i<8;i++ ) { receive<<=1; AMG_IIC_SCL=0; delay_us(4); AMG_IIC_SCL=1;
delay_us(4); if(AMG_READ_SDA) receive |= 0x01; delay_us(4); //1 } AMG_IIC_SCL =
0; return receive; } //IIC Write a byte of data u8 AMG_IIC_Write_1Byte(u8 SlaveAddress, u8
REG_Address,u8 REG_data) { AMG_IIC_Start(); AMG_IIC_Send_Byte(SlaveAddress);
if(AMG_IIC_Wait_Ack()) { AMG_IIC_Stop();// Release bus return 1;// Quit if you don't answer }
AMG_IIC_Send_Byte(REG_Address); AMG_IIC_Wait_Ack(); delay_us(5);
AMG_IIC_Send_Byte(REG_data); AMG_IIC_Wait_Ack(); AMG_IIC_Stop(); return 0; }
//IIC Read a byte of data u8 AMG_IIC_Read_1Byte(u8 SlaveAddress, u8 REG_Address,u8
*REG_data) { AMG_IIC_Start(); AMG_IIC_Send_Byte(SlaveAddress);// Send and write commands
if(AMG_IIC_Wait_Ack()) { AMG_IIC_Stop();// Release bus return 1;// If you quit, you don't respond }
AMG_IIC_Send_Byte(REG_Address); AMG_IIC_Wait_Ack(); delay_us(5);
AMG_IIC_Start(); AMG_IIC_Send_Byte(SlaveAddress|0x01);// Send read command
AMG_IIC_Wait_Ack(); *REG_data = AMG_IIC_Read_Byte(); AMG_IIC_Stop(); return 0;
} //I2C Read multiple bytes of data uint8_t AMG_I2C_Read_nByte(uint8_t SlaveAddress, uint8_t
REG_Address, uint8_t *buf, uint16_t len) { AMG_IIC_Start();
AMG_IIC_Send_Byte(SlaveAddress);// Send and write commands if(AMG_IIC_Wait_Ack()) {
AMG_IIC_Stop();// Release bus return 1;// Quit if you don't answer } AMG_IIC_Send_Byte(REG_Address);
AMG_IIC_Wait_Ack(); delay_us(5); AMG_IIC_Start();
AMG_IIC_Send_Byte(SlaveAddress|0x01);// Send read command AMG_IIC_Wait_Ack(); while(len) {
*buf = AMG_IIC_Read_Byte(); if(1 == len) { AMG_IIC_NAck(); } else {
AMG_IIC_Ack(); } buf++; len--; } AMG_IIC_Stop(); return STATUS_OK; }
//I2C Write multiple bytes of data uint8_t AMG_I2C_Write_nByte(uint8_t SlaveAddress, uint8_t
REG_Address, uint8_t *buf, uint16_t len) { AMG_IIC_Start();
AMG_IIC_Send_Byte(SlaveAddress);// Send and write commands if(AMG_IIC_Wait_Ack()) {
AMG_IIC_Stop();// Release bus return 1;// Quit if you don't answer } AMG_IIC_Send_Byte(REG_Address);
AMG_IIC_Wait_Ack(); while(len--) { AMG_IIC_Send_Byte(*buf++);
AMG_IIC_Wait_Ack(); } AMG_IIC_Stop(); return STATUS_OK; }
3,AMG8833.h
#ifndef __AMG8833_H #define __AMG8833_H #include "AMG_IIC.h" #define
AMG88xx_PIXEL_TEMP_CONVERSION 0.25 #define AMG88xx_THERMISTOR_CONVERSION 0.0625
enum { AMG88xx_PCTL = 0x00, AMG88xx_RST = 0x01, AMG88xx_FPSC = 0x02,
AMG88xx_INTC = 0x03, AMG88xx_STAT = 0x04, AMG88xx_SCLR = 0x05, //0x06 reserved
AMG88xx_AVE = 0x07, AMG88xx_INTHL = 0x08, AMG88xx_INTHH = 0x09, AMG88xx_INTLL =
0x0A, AMG88xx_INTLH = 0x0B, AMG88xx_IHYSL = 0x0C, AMG88xx_IHYSH = 0x0D,
AMG88xx_TTHL = 0x0E, AMG88xx_TTHH = 0x0F, AMG88xx_INT_OFFSET = 0x010,
AMG88xx_PIXEL_OFFSET = 0x80 }; enum power_modes{ AMG88xx_NORMAL_MODE = 0x00,
AMG88xx_SLEEP_MODE = 0x01, AMG88xx_STAND_BY_60 = 0x20, AMG88xx_STAND_BY_10 =
0x21 }; enum sw_resets { AMG88xx_FLAG_RESET = 0x30, AMG88xx_INITIAL_RESET =
0x3F }; enum frame_rates { AMG88xx_FPS_10 = 0x00, AMG88xx_FPS_1 = 0x01 }; enum
int_enables{ AMG88xx_INT_DISABLED = 0x00, AMG88xx_INT_ENABLED = 0x01 }; enum
int_modes { AMG88xx_DIFFERENCE = 0x00, AMG88xx_ABSOLUTE_VALUE = 0x01 }; void
AMG8833_Init(void); float AMG88xx_ReadThermistor(void); void
amg88xx_readPixels(float *buf, uint8_t size); #endif
4,AMG8833.c
#include "AMG8833.h" void AMG8833_Init(void) { AMG8833_IIC_Init(); //IIC initialization
//enter normal mode
AMG_IIC_Write_1Byte(AMG88xx_ADR,AMG88xx_PCTL,AMG88xx_NORMAL_MODE); //software
reset AMG_IIC_Write_1Byte(AMG88xx_ADR,AMG88xx_RST,AMG88xx_INITIAL_RESET); //set
to 10 FPS AMG_IIC_Write_1Byte(AMG88xx_ADR,AMG88xx_FPSC,AMG88xx_FPS_10); } float
signedMag12ToFloat(uint16_t val) { //take first 11 bits as absolute val
uint16_t absVal = (val & 0x7FF); return (val & 0x800) ? 0 - (float)absVal :
(float)absVal ; } float AMG88xx_ReadThermistor(void) { uint8_t raw[2]; uint16_t
recast; AMG_I2C_Read_nByte(AMG88xx_ADR,AMG88xx_TTHL, raw, 2); recast =
((uint16_t)raw[1] << 8) | ((uint16_t)raw[0]); return signedMag12ToFloat(recast)
* AMG88xx_THERMISTOR_CONVERSION; } void amg88xx_readPixels(float *buf, uint8_t
size) { uint16_t recast; float converted; uint8_t rawArray[128],i;
AMG_I2C_Read_nByte(AMG88xx_ADR,AMG88xx_PIXEL_OFFSET,rawArray,128); for(i=0;
i<size; i++) { uint8_t pos = i << 1; recast = ((uint16_t)rawArray[pos + 1] <<
8) | ((uint16_t)rawArray[pos]); converted = signedMag12ToFloat(recast) *
AMG88xx_PIXEL_TEMP_CONVERSION; buf[i] = converted; } }
 

Technology