Questions about the TPA81 Sensor/ABB/AtomPro/SSC

Hello,

For the past few weeks I have been playing around with the TPA81 sensor from Devantech, I’ve got my AtomPro working with this sensor so that it oututs readings via DEBUG, but now I have been trying to program the AtomPro so that I can have my bot follow or track a heat source(sensor is mounted on a servo to pan, which is mounted on my bot the A4WD1)

I have written some code so that I can take readings from the TPA81, and have it tell me the highest reading as well as which pixel detected it.

The TPA81 is basically 8 sensors all lined up in a row 1 2 3 4 5 6 7 8 where 1 is the right and 8 is the left(it also has another sensor that shows ambient temp).

SO part of the code I have right now which shows me the highest reading and which pix it is:

tpa81_scan:
tpa_temp = 0
tpa_high = 0
’ this has 8 sensors(pix1-8) pix1 is to the right and pix8 is the left. readings are given in degrees C
I2CIN SDA,SCL,0xD0,0,[Ver, Ambient, Pix(1), Pix(2), Pix(3), Pix(4), Pix(5), Pix(6), Pix(7), Pix(8)]
if Pix(1) > 254 then goto tpa_error ’ if the reading is off, start over

DEBUG "temps “,DEC Pix(1),” “,DEC Pix(2),” “,DEC Pix(3),” “,DEC Pix(4),” “,DEC Pix(5),” “,DEC Pix(6),” “,DEC Pix(7),” ",DEC Pix(8),13]
pause 500

for w = 1 to 8
If Pix(w) > tpa_high then
tpa_high = Pix(w) ’ what’s the highest reading
tpa_temp = w ’ which pix was highest store it in w
endif
next

I am not that good with programming in general(still learning), I even looked around at some examples on how to use the TPA81 to follow a heat source(which is written in C, so that wasn’t much help) there are other examples out there, but in general they just give readings.

I am stuck on this using the code above:

I know which pix had the highest reading, I could also write code so that it can tell me the lowest reading, but could it be useful for what I am trying to do?

each pix value 1-8 is stored, so how would I program the AtomPro to know which was the next highest, in order to have the pan servo actually track it and not lose it?(one thought I had was to remove the highest reading and then figure out what the highest one was with the remaing
values?)
another thought is that when it does track this heat source, I should have the sensor move until it get’s the middle pix sensors “locked” onto this heat source, then if the heat source moves to the left or right, it will be able to keep tracking it because it would know which way the heat source was going.

I’ve been at this for a few weeks now, and either I am making this harder then it should be, or I am going about this the wrong way?

The other thing is that I am wondering is if the AtomPro will be able to handle this, and if not possibly use a PIC to do the tracking(when I figure out how to actually track) my bot currently can roam around a room without hitting anything using 3 srf05 sonars in front, of course if it has to backup there is a minor problem, no sensors in the back which I intend on adding 3 more srf05 sensors when I can afford it.

I would greatly appreciate any input / ideas on this

Hi Charley,

Interesting part, and project! What heat sources are you going to seek with your array?

One way to find lower values is my making a sorted list. then you could “walk” the list to find the values you want.

Or make a two dimentional array of points, and you could have something like a topographical map.

Probably depends on how much memory is available for arrays. I think you’re going to have a lot of data to sift through. Not a bad idea to use a seperate PIC processor for the IR navigation code. When it wanted a “course change”, it could signal the main processor.

You’d probably want to implement some Subsumption modules to generate a course-change when you first acquire a heat source. Just like a light-following algorithm. Once the 'bot was “centered” on a course to the heat source, then the module drops out, and a lower level module to simply follow the set course (accept when obsticles get in the way) until within some minimum distance wanted from the heat source.

Check into Subsumption and Behaviors, I believe this is a quantum development in writing AI to run a 'bot! I hope to be learning more on this topic. My own robot is still getting her (Shelob) “sea legs”, but will want to acquire these behaviors as well.

Alan KM6VV

Hi charleyshf!

I so want to work with one of these! I want to turn W.A.L.T.E.R. into a cat seeker to patrol my kitchen and keep my precocious feline out of there. :slight_smile: I wish these were not so expensive, but I certainly understand why they are, with 8 separate heat sensors. You can tell which direction (left/right or up/down) a heat source is located, depending on the orientation of the sensor. Use two of them and you have full 3D heat source location and can do full pan/tilt warm body tracking.

[quote="charleyshf"] I know which pix had the highest reading, I could also write code so that it can tell me the lowest reading, but could it be useful for what I am trying to do? [/quote] You will need to know the readings from the sensors farthest to left and right (or up and down) so you can move the TPA81 in the correct direction for another reading. [quote="charleyshf"] each pix value 1-8 is stored, so how would I program the AtomPro to know which was the next highest, in order to have the pan servo actually track it and not lose it?(one thought I had was to remove the highest reading and then figure out what the highest one was with the remaing values?) [/quote] You need to be reading the TPA81 sensors in the same order as the datasheet shows them. This will make your code easier to understand as well as maintain. [quote="charleyshf"] another thought is that when it does track this heat source, I should have the sensor move until it get's the middle pix sensors "locked" onto this heat source, then if the heat source moves to the left or right, it will be able to keep tracking it because it would know which way the heat source was going. [/quote] You should move the sensor in the direction of the strongest heat detection, until the center pair of sensors have the strongest detection. Then repeat until you start losing detection, then move the sensor back to where you had it last. You will need to save the last strongest detection location of the pan servo and detection values for the two center sensors for comparisons. I have it in my mind how it needs to come together to make it all work. it would not be difficult to write the code now. :slight_smile:

Assuming (for now) the sensors are numbered from right to left (7 6 5 4 3 2 1 0) looking at the BACK of the TPA81:

[code]do
’ Take a set of readings from TPA81
I2CIN SDA,SCL,0xD0,0,[Ver, Ambient, Pix(1), Pix(2), Pix(3), Pix(4), Pix(5), Pix(6), Pix(7), Pix(8)]

' Save center readings
tpa_center_4 = Pix(4)
tpa_center_3 = Pix(3)

' Save extreme left and right readings
tpa_right_7 = Pix(7)
tpa_left_0 = Pix(0)

if tpa_left_7 > tpa_center_4 then
 ' Pan right a bit
  else
    if tpa_right_0 > tpa_center_3 then
       ' Pan left a bit
    endif
endif

while tpa_center_3 < Pix(3) ’ Depends which direction you are interested in - tpa_center_4 < Pix(4) for other direction
[/code]
This is the kind of thing you need to do, but you will probably have to adjust the orientation of variables to the way the datasheet shows the sensor numbering. I wrote this based on looking directly at the BACK of the TPA81 and have not yet checked the datasheet for the sensor.

I believe either the Basic Atom or Atom PRO can handle this nicely. However, I think the idea thing would be to eventually dedicate a PIC to handling just the TPA81 sensor, and eventually a pair of them.

I believe the Atom PRO could easily handle a pair of TPA81’s and everything else. It would be more difficu’t with a Basic Atom, due to speed and less program memory. It just depends on how much additional stuff you want your main MCU to handle along with the TPA81 and other sensors. I have written code to handle reading any number of Sharp IR Rangers and PING sensors. Oooooooooooh, I very much want to work with these TPA81s!

I can see some very cool and useful applications for this!

8-Dale

linuxguy,

Steve Norris has already written PIC code for the TPA81 which I converted to PBASIC for use with a Parallax BS2p. The PIC code determines the hottest pixel after two scans of the array.

You can download the PIC hex code from the “Follow Me” article in the summer issue of Robot Magazine.

Steve Norris has also written Propeller spin obj code to handle the TPA81. The spin obj code can be downloaded from the “Huey: A color chasing Robot” article in the Winter issue of Robot Magazine.

Just a thought.

Regards,
TCIII

Hello again,

Well I have been playing around with the TPA81 sensor and I finally got some code to work with it. Something right off the bat, thing is VERY ACCURATE!

with it mounted on a servo to pan around, I had it tracking a candle with hardly any problems, I’ve got to go through my code to see if I can speed this up a bit, otherwise I don’t see where it could follow a person or even a small animal, course I think that this sensor might need to be controlled via a PIC at this point.

Hi Charley,

Are you saying it CAN’T follow a person or a small animal?

I’d go along with the separate uP for the tracking task. Too bad I’m busy with the basic task of walking, or I’d check it out!

My son and his buddys saw my 'Bot walking last night, and he’s interested in digging up his video (camera) sensor and code he used on a line-following 'bot of a few years ago.

Alan KM6VV

Hello,

No I wouldn’t say it can’t follow a person or a small animal, it’s probaby something in my code, but my configuration currently just for the sensor has the TPA81 > AtomPro > SSC32, so whenever the atom pro reads the TPA81 and decides to move the servo the TPA81 is on, it sends out the commands to the SSC32, which I believe you need a delay in between sending commands to the SSC32 and depending on how the code is written, it may not need a delay(IE for next statements)

Once I get a better idea of what’s going on, I think I just may end up using a PIC to do the TPA81 readings because of all the other sensors my bot uses.

charleyshf,

Why are you using a SSC32 when the TPA81 has a single servo controller built into it that works just fine for panning the TPA81 around on a servo?

Just a thought.

Regards,
TCIII

Hi,

I actually have not tried to use it yet, but it’s something I plan on doing this weekend when I have some time to work on it again.

For a sensor such as the TPA81, it’s way better to have it on a pan/tilt turret. To get the most use from it and to be able to tell if what you detect is a small animal or a person, full 3D range detection is needed.

This is one of the most expensive sensors I have seen, and I would want to get maximum use from it. I’ve designed a 3DOF arm for WALTER that will allow looking around in a full 3D space. This would be the perfect mounting place for a TPA80 and a two pairs of ranging sensors (Sharp IR and PING or I2C ultrasonic).

8-Dale

You know I totally forgot about the tilt part of things, that would also be cheaper then getting another TPA81 and mounting it to detect heat sources high or low, the pan/tilt mount on the front of my bot is the one Jim sells, I just wanted to get it working and get an idea of what kind of programming I was in for, and if it could actually be able to track things quick enough.

I can definately say that I am going to need to get my PIC stuff out for this one, especially when I have all my SRF05 sonars as well as other sensors going, the AtomPro will need all the help it can get, and if I only offset the TPA81, it will help out quite a bit. (now if I can just imrpove on my basic programming :O)

I guess there are advantages to having very limited money to spend on toys. I have to figure out how to get the most use of everything I buy. :slight_smile: The pan/tilt for the TPA81 just seemed so obvious. :slight_smile:

How are you planning to have the Atom PRO communucate with the PIC? The PIC would have to be an I2C master to talk to the TPA81. Unless the PIC can switch to being an I2C slave, it will not be able to talk to the Atom PRO using I2C. I am working on a way to have a PIC be able to switch between Master and Slave modes. I just have to get the slave code working now. I can already jumper select a PIC to be Master or Slave, as well as set the device address via jumpers. I2C Master code works fine (Pete’s - sapian59 - dualPIC I2C code).

8-Dale

Hello,

You know I haven’t had much time to think about how I want to do this with a PIC and the AtomPro, but I have to go through my pic collection this weekend, I have a few 40-pin 18F4820’s as well as some others I had ordered months ago, as well as a few prototyping boards, including a Oricom tech BOT-40 board. It may end up becoming something that I use just PICS for, when I had last been working with PICS, I didn’t have as many problems as I did with the AtomPro.

The Atom PRO has to be I2C Master, so if you are going have it communicate with any other micro using I2C, that micro has to be an I2C Slave. I2C sensors are also Slave devices. Given all of this, you can’t have a PIC interface with an I2C sensor and communicate with the Atom PRO via I2C too.

If you want I2C between the PIC and sensors, then the Atom PRO must communicate with the PIC via some other means. You can’t use SPI, because some of the SPI pins are shared with the I2C pins on PICs.

The only other easy means would be via TTL serial I/O, which would require you to come up with a custom command protocol. This is not difficult. I already have this figured out and have a simple command parser coded in C (MPLAB, C18) and tested. My parser can handle commands of any length, but 1, 2 or 3 character commands should more than enough.

8-Dale