Author Topic: TPA81 & AXON 2 code  (Read 2624 times)

0 Members and 1 Guest are viewing this topic.

Offline teoxanTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
TPA81 & AXON 2 code
« on: March 17, 2010, 06:05:15 PM »

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.

Code: [Select]
#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)


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
rprintf("No responce\n");

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
Re: TPA81 & AXON 2 code
« Reply #1 on: March 18, 2010, 08:07:19 PM »
Good job, nice. Very simple and clean.

I'll add the device to WebbotLib - I'll give you "some" credit - mainly coz I need to restructure it to make it swappable with other sensors. Also need to add a configuration for it to Project Designer, write up docs etc etc. So your couple of lines of code then take me several hours to incorporate  ::)

I've checked the datasheets and I can't find any info on:
1. How much power the sensor requires (for Project Designer)
2. Whether it needs any kind of delay between reads (as WebbotLib sensors have code to stop you reading them too quickly).

Have you found anything on the above?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline teoxanTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
Re: TPA81 & AXON 2 code
« Reply #2 on: March 19, 2010, 12:37:08 AM »

1. According to the Devantech's Web site, we must give it 40ms between readings when using a servo to pan it.

2. It draws 5mA, excluding the servo attached on it.

The sensor has direct connections for a servo on it, and can be directly connected and issue I2C commands to pan it.

The servo tested from Devantech is the Hitech HS311, I have a Hitech HS322 on it and it doesn't work, I don't know why..

But I think this is not an issue since you can connect any servo on Axon and use it to pan the sensor.

Next testing with the Axon 2 will be the SRF02 ranger which has two modes: I2C and serial.




Get Your Ad Here