TPA81 Thermopile Array and NXT

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderators: roger, 99jonathan, imaqine

TPA81 Thermopile Array and NXT

Postby quantgeek » Tue Jan 31, 2012 6:42 pm

Hi,

I got this sensor that I want to use with my NXT. Does anyone know how to connect this to the NXT? It is an I2C 5V sensor. The specs are available here:

http://www.robot-electronics.co.uk/htm/tpa81tech.htm

There seems to be some members who appears to have connected it...

Thanks,

QuantGeek
quantgeek
New User
 
Posts: 2
Joined: Tue Jan 31, 2012 6:38 pm

Re: TPA81 Thermopile Array and NXT

Postby TechnoX » Thu Feb 02, 2012 6:42 pm

I have done it for RoboCup! Works like a charm! :)

You have to add external resistors for clock and data lines. I did a small adapter with a NXT female connector and a female header.

What specifically do you wonder? I can upload some code and images in the weekend if you want ;)
TechnoX
Novice
 
Posts: 51
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: TPA81 Thermopile Array and NXT

Postby quantgeek » Fri Feb 03, 2012 1:49 am

Technox,

Yes!!! Images and sample code would be great. Since I am not an engineer, connection tips would be wonderful! Where you able to use the SERVO output as well??

Thanks,

Quant Geek
quantgeek
New User
 
Posts: 2
Joined: Tue Jan 31, 2012 6:38 pm

Re: TPA81 Thermopile Array and NXT

Postby TechnoX » Sat Feb 04, 2012 6:35 pm

We didn't used the servo output, I haven't read so much about it. But with my code you are able to read the individual segments and then act according to that, I think it's easier for the NXT to do so instead of reading PWM signals(?).

I'll try to find my images (or take new ones) tomorrow ;)

This is the class I used. Hope it works for you!
Code: Select all
import lejos.nxt.*;

/**
 * Class to read of the heat sensor
 *
 * @author SOFT Robotics
 * @author Fredrik Löfgren
 * @author Sebastian Gustafsson
 * */
public class HeatSensor extends I2CSensor {

   static final byte ADDRESS = (byte) 0xD0;

    // Data buffer for the IR values
   private byte[] data = new byte[1];

   public HeatSensor(I2CPort port, byte adress) {
      super(port, adress, I2CPort.STANDARD_MODE, I2CSensor.TYPE_LOWSPEED);
   }

   public HeatSensor(I2CPort port) {
      this(port, ADDRESS);
   }

   public void testSensor() {
      int ret;

      if ((ret = this.getData(0, data, 1)) < 0)// Can fetch data?
         throw new RuntimeException("Heatr: " + ret);
      else if (data[0] <= 0) // Correct data returned?
         throw new RuntimeException("Heatd: " + data[0]);
   }

   /** Return the most heated segment that the sensor sees just now */
   public int getHeat() {
      int max = 0;
      for (int pos = 0; pos < 8; pos++) {
         this.getData(pos + 0x02, data, 1); // read pixel command
         if (data[0] > max)
            max = data[0] & 0xFF;
      }
      return max;
   }

   /** Read internal temperature */
   public byte ReadAmbient() {
      this.getData(0x01, data, 1); // the i2c read command
      return data[0];
   }

   /** Read one pixel */
   public byte ReadPixel(int pos) {
      this.getData(pos + 0x02, data, 1); // read pixel command
      return data[0];
   }
}
TechnoX
Novice
 
Posts: 51
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: TPA81 Thermopile Array and NXT

Postby warrocket94 » Mon Apr 02, 2012 8:51 am

Hi
i'm an italian student and i use TPA-81 with my Lego Mindstorm NXT 2.0... but it's so difficoult to programme it... the hardware parts is finished but now i'm programming it...on the web i don't find some programme to help me... is there that can help me to programme TPA 81 Sensor? I use bricx command center to programme the sensor..

Thank you very much for your help :)

Davide
warrocket94
New User
 
Posts: 3
Joined: Mon Apr 02, 2012 8:44 am

Re: TPA81 Thermopile Array and NXT

Postby TechnoX » Tue Apr 03, 2012 8:06 pm

What have you tried?

I would use the ReadI2CRegister method.
TechnoX
Novice
 
Posts: 51
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: TPA81 Thermopile Array and NXT

Postby warrocket94 » Tue Apr 03, 2012 10:09 pm

I use this string to read the value of the temperature of the TPA but it's wrong because the LCD Lego Display always show me this value "-32".
http://bricxcc.sourceforge.net/nbc/nxcd ... 6b5b92d77d


This is the programme that i try:

int temp,port,address;
byte outbuffer [8];

task main()
{
port=1; //it's the number of port where i connect the TPA81 on the Lego Brick
address=208; //it's the 0xD0 adress in decimal value
do
{
temp = I2CRead(port, address, outbuffer);
TextOut(5,LCD_LINE2,"temp");
Wait(1000)
}
while (1)
}


this programme don't work because the LCD Lego Display shows only this value "-32"

Can you help me pleaseeee!! i don't find something on the web that can help me. Should you help me please?
warrocket94
New User
 
Posts: 3
Joined: Mon Apr 02, 2012 8:44 am

Re: TPA81 Thermopile Array and NXT

Postby TechnoX » Fri Apr 06, 2012 12:21 pm

I have not been programming NXC for several years, and I think this is the wrong place to get good answers about it... :)

But the TPA81 uses registers, so you need to specify from what register you want to read. Either by doing a write before you read values from the sensor, or by using the function (ReadI2CRegister) I recomended earlier. The last method is easier and clearer.

Code: Select all
int temp,port,address;
byte outbuffer [1];

task main()
{
port=1; //it's the number of port where i connect the TPA81 on the Lego Brick
address=208; //it's the 0xD0 adress in decimal value
do
{
temp = ReadI2CRegister(port, address, 2, outbuffer); // Just read the first segment
NumOut(5, LCD_LINE2, temp);
Wait(1000)
}
while (1)
}


I have not tested the code above, but I think you get the idea? :)
TechnoX
Novice
 
Posts: 51
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: TPA81 Thermopile Array and NXT

Postby warrocket94 » Sun Apr 08, 2012 9:03 pm

yes i try the "I2C Read Register" but the LCD Lego Display show me this value : "-32"... "-32" is an error and it means that 0xE0 (the specific channel or connection) is not configured or busy. And i don't know how i can resolve this problem!
http://bricxcc.sourceforge.net/nbc/nxcd ... 4e7fd3d94d
In the link there are some parametres that i don't know very well... For example what are "reg" and "out" parametres? And what are their value?
Moreover need i activate the sensor with some string?
warrocket94
New User
 
Posts: 3
Joined: Mon Apr 02, 2012 8:44 am

Re: TPA81 Thermopile Array and NXT

Postby gloomyandy » Sun Apr 08, 2012 10:44 pm

Hi,
You will probably get more help with your NXC questions over on the mindboards forum...
http://sourceforge.net/apps/phpbb/mindb ... 05fa829bc5
That is where most of the NXC users tend to hang out...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 2 guests

cron
more stuff