I have succesfully interfaced the TPA81 thermall array sensor with Axon2 using Webbotlib.
The TPA81 is a fantastic sensor, using 8 infrared sensors to detect temperature. One of them is used to sensor ambient temperature.
It can detect a candle light from a 2 meters distance making ideal for firefighting robots, but also for detecting humans and animals.
The code is below.
#include "sys/axon2.h"
#include "a2d.h" //use for ADC
#include "rprintf.h" //use for UART
#include "i2c_master.h" //use for I2C
//user includes
#include "hardware.h"
uint8_t address=0xD0; // I2C address for TPA81
uint8_t responce[10]; // We need 9 readings + one for the software revision-for info only
uint8_t data[1]={0x0};
void appInitHardware(void)
{
//initialize UART ports (see hardware.h to change baud/names)
uartInit(USB_UART, USB_BAUD);
rprintfInit(USB_ACTIVATE);
}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
rprintf("\nAxon Initiated.\n\n");
return 0;
}
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{
i2cMasterSend(address,1,data); //read the Register 0x0 to get software revision
if (i2cMasterReceive(address,10,responce)) //all is ok?
{
rprintf("TPA81 Thermal Array Sensor\n");
rprintf("Software Revision: ");
rprintf("%d\n", responce[0]);
rprintf("Temp: ");
rprintf("%d\n", responce[1]); // Ambient Temperature
rprintf("%d\n", responce[2]); // sensor #1
rprintf("%d\n", responce[3]); // sensor #2
rprintf("%d\n", responce[4]); // sensor #3
rprintf("%d\n", responce[5]); // sensor #4
rprintf("%d\n", responce[6]); // sensor #5
rprintf("%d\n", responce[7]); // sensor #6
rprintf("%d\n", responce[8]); // sensor #7
rprintf("%d\n", responce[9]); // sensor #8
delay_ms(400); // give it some time to refresh readings
}
else
{
rprintf("No responce\n");
}
}