//snooze
//wait for Break sequence
// to complete
bytein = RCREG; //discard the byte,
// clear RCIF flag
while(ABDEN); //measure the chirp
bytein = RCREG; //discard the byte,
// clear RCIF flag
enable_RXint; //get ready for real data
SLEEP();
while(WUE);
//wait for incoming PID
while(!(CharInQueue()));
pid_in = recvchar(); //retrieve PID
id_in = pid_in & 0x3F; //get identifier
if(id_in == 0x02)
{
//number of data bytes in response
lin_buf[msg_len] = 3;
//used to compute frame checksum
lin_buf[id_loc] = pid_in;
lin_buf[msg_loc] = 0x11;
lin_buf[msg_loc+1] = 0x22;
lin_buf[msg_loc+2] = 0x33;
//enhanced checksum calculation
checksum = lin_buf[id_loc];
for(i=0;i<lin_buf[msg_len];++i)
{
// data
checksum = checksum +
lin_buf[msg_loc+i];
}
//where to store frame checksum
chksum_loc = msg_loc + 3;
lin_buf[chksum_loc] =
~(checksum & 0x00FF);
//add checksum ato length
lin_buf[msg_len] = lin_buf[msg_len]+1;
LIN_TX; //place MCP2201 in Tx mode
//SEND RESPONSE
for(i=0;i<lin_buf[msg_len];++i)
{
sendchar(lin_buf[msg_loc+i]);
}
do{
LED1 ^= 1;
sdelay1(2);
//kill time
Microchip — www.microchip.com
LIN Serial Analyzer
MCP2021
PIC18F2620
MPLAB REAL ICE
MPLAB ICD2
HI-TECH PICC- 18 PRO C Compiler
LIN Node Printed Circuit Board
Sources
}while(1);
}
}
There should be no mystery surrounding the code
preceding the if(id_in==0x02) statement. You shouldn’t
have any trouble following the rest of the slave response
code either as we’ve only adjusted the response
transmission routine. With the help of the LIN Serial
Analyzer, I can offer you the visual results of the slave
response code in Screenshot 4.
You are a LIN Master
The LIN-influenced hardware and software elements we
have discussed can be used to build a number of LIN slave
node variants, as well as a LIN master node. The LIN node
hardware we assembled can be used in applications using
the official LIN Specifications.
However, I think that those of you that put our
LIN hardware to work will come up with your own
“specifications” and use the LIN frame’s PID and eight
response bytes to your robotic advantage. SV
Fred Eady can be reached via email at fred@edtp.com
STEER WINNING ROBOTS
WITHOUT SERVOS!
Perform proportional speed, direction, and steering with
only two Radio/Control channels for vehicles using two
separate brush-type electric motors mounted right and left
with our mixing RDFR dual speed control. Used in many
successful competitive robots. Single joystick operation: up
goes straight ahead, down is reverse. Pure right or left twirls
vehicle as motors turn opposite directions. In between stick
positions completely proportional. Plugs in like a servo to
your Futaba, JR, Hitec, or similar radio. Compatible with gyro
steering stabilization. Various volt and amp sizes available.
The RDFR47E 55V 75A per motor unit pictured above.
www.vantec.com
Order at
(888) 929-5055
SERVO 07.2009
49