Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Lab 8 Protocol

Purpose:
This protocol is defined to enable the communication between a leader PIC32 and two follower
PIC32. There are two goals of this communication. The first is for the master to be able to
communicate target RPMs to the motor pic. The second goal is to be able to communicate the
current status of the robot to the IR as well as receiving sensor events from the IR pic.
Connection Interface
Pinout:

Master Follower 1 Follower 2

SCK1 RB14 (Pin 25) RB14 (Pin 25) RB14 (Pin 25)

SDO1 RB8 (Pin 17) RB8 (Pin 17) RB8 (Pin 17)

SDI1 RB11 (Pin 22) RB11 (Pin 22) RB11 (Pin 22)

SS1 RPB2 (Pin 6) RPB15 (Pin 26) -

SS2 RPB3 (Pin 7) - RPB15 (Pin 26)

Input State Query - RA4 (Pin12 ) RA4 (Pin 12)

LED - RA0 (Pin 2) RA0 (Pin 2)

TX RB6 (Pin 15) RB6 (Pin 15) RB6 (Pin 15)

RX RB7 (Pin 16) RB7 (Pin 16) RB7 (Pin 16)

1
Schematic:

Byte Transfer Specification


This SPI communication system interfaces a leader node (referenced as “Leader”) to two slave nodes (referenced as
“Follower 1” and “Follower 2"). To begin a transfer, the SS line must be lowered then raised upon completing the
data transfer. The SDO line transfers serial data from the Leader to both Followers. The SDI line transfers serial
data from the Followers to the Leader. The timing information associated with these transfers is detailed in the Byte
Level Protocol section.

Byte Level Protocol Specification


Common Byte Format:
Conversations between the Leader and the follower will take place at a frequency of 10kHz (a Baud Rate of 999).
Serial output data will change on transition from active clock to idle clocks state. The idle state for the clock is a high
level. A 5ms delay is required between each byte transferred. 3 Bytes are sent in each transfer.

Leader to Follower Bytes:


These are the bytes that the Leader can send containing meaningful content.

Command (byte 1) Meaning

0x22 Update drive motors

0x00 Push byte

0x41 Bot is on Team A

0x42 Bot is on Team B

0x01 Bot is running the starting leg

0x02 Bot is not running the starting leg


2
Follower to Leader Bytes:
​The Followers will return a value of 0x00 when the Leader command is sent. The second byte is
a unique acknowledgement of the command received. The third byte in the transfer is the status of
pin 24 on the follower that is responding.

Command (from Leader) Response (from Follower 2) Meaning

0x22 0x22 Follower 2 Setting Target


RPMs

Command (from Leader) Response (from Follower 1) Meaning

0x00 0x31 Side phototransistor trigger


frequency

0x00 0x32 Front phototransistor trigger


frequency

0x00 0x51 Front right tape detected

0x00 0x52 Front left tape detected

0x00 0x53 Front right and left tape


detected

0x00 0x61 Back right tape detected

0x00 0x62 Back left tape detected

0x00 0x63 Back right and left tape


detected

0x33 Robot Waiting, transmit IR


from beacon

0x44 Robot got Bumped, begin


reading & reporting tape
sensors

PATE: ​Pin state response byte

0 STATE STATE 0 0 0 0 0

3
bits 0-4 Unused
bit 5-6 STATE: ​Pin State
Low = 01
High = 11
bit 7 Unused

Example Interaction:

Example 1​ is the following 3-byte interaction where the Leader asks the Drive Follower to set both
speeds to full throttle forward
Command Byte Acknowledgement Byte Pin Status Byte

Leader 0x22 0xFF 0xFF

Follower 1 0x00 0x22 0x00

Power-on and Reset Behavior:


Initially, after power on or a reset, the Leader and Followers will return 0x00 from any query until
such time as they are internally initialized.

Command Timing:
The interval between two successive transfers from the Leader to the Followers should be at least
5 ms. The SS line must remain high for a minimum of 5 ms between successive transfers, and
de-asserted during the entirety of a single command transfer.

Invalid Command Bytes:


If the Followers receives a command byte not listed in the table, it will respond to the invalid
command byte by returning a 0xFF byte as the acknowledge byte.

You might also like