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