Wednesday, March 21, 2007

RFID tracking going well

It took about 15 minutes to pop the batteries in the transmitters, throw them in the 3 cars and write up some code in starCOMUltra to do the vehicle tracking. They send out a beacon about every 2.5 seconds which the receiver picks up and sends a 4 character string to a serial port that sCU is watching. This code tracks the arrival of cars:

function AUXPorts::AUX2_LineIn(Line) {
var TempLine;
if (Line.substr(0,4)=="2xyz") {
if (CarsCheck(Car1)==0) {
TempLine ="# AUX 2:\tCar 1 Home";
LogDevice(TempLine);
CarsChange(Car1,1);
Speech.speak("R is home");
} else {
CarsInTime[0]=TimeSecs();
}
}
}


To track the departure of cars, my sCU script checks every 2 minutes if a car hasn't been heard from in a little while:

function ScriptTimers::Trigger(Index) {
var secs;
Site.LogDevice("# sCU Timer: " + ScriptTimers.Item(Index).Name +
" ("+ Index + ") expired");

switch(Index) {
...
case 1: // 2 minute
ScriptTimers.Item("TwoMinuteTimer").Continuous = -1;
ScriptTimers.Item("TwoMinuteTimer").Time = 120;
secs=TimeSecs();
if ((secs-CarsInTime[0])>90 && CarsCheck(Car1)==1) {
CarsChange(Car1,0);
LogDevice("# Cars:\tCar 1 Away");
}
break;
...


I haven't done any fine tuning of the placement of the receiver or of the transmitters in the cars. I have noticed that the car parked outside has occasional dropouts so I'll definitely be looking at re-positioning and possibly adding an antenna to the receiver. Overall, it was a very smooth install and I got right back to sCU beta testing.

No comments:

Post a Comment