top of page
Search
  • Writer's pictureHaaris Ahmed

Communication Protocol Proposal

The Raspberry Pi user interface platform has more secondary memory available that the STM32 system controller. Furthermore, it is easier to create simple text files and modify them when stored on the Raspberry Pi system. For these reasons, it was decided that the Raspberry Pi system would host the recipe files, which would be in the format of text files.


The instructions in these files will be parsed by the raspberry pi system and then transmitted to the STM32 system controller once a recipe has been selected.


Proposed File Format for Recipes

Each line of the recipe file shall refer to a specific command. Possible commands include:

  • Set temperature

  • Dispense from container

  • Rotate pot at a specific speed

An example of a recipe instruction might be:

  • HEAT 1500 350

Here, the first argument is the command, the second argument is the time from the last command, and the final argument is the temperature


Proposed Format for Communication Protocol

There are two types of commands that can be sent:

  • Send recipe

  • Check status

Send Recipe

The send recipe command is a longer communication procedure therefore it is important to ensure that the STM32 system controller is ready to receive data. Handshaking must be performed prior to a recipe being sent. The handshaking procedure is as follows:

  • The user interface controller starts the handshaking procedure by sending a two-byte packet known as the READY packet <0x01><0x01>

  • If the system controller is ready to receive the recipe, it will echo the READY packet, and if the system is not ready to receive the recipe, it will instead respond with the two-byte NOT_READY packet <0x02><0x02>

If the handshaking process was successful, the user interface controller will start transmitting the recipe one instruction at a time. Each instruction packet will have the same general format:

  • <start><num_arguments><arguments …><end>

  • <0x01><1_byte_number><multiple_bytes><0x02>

Each packet shall have the command type (1 byte) as its first argument, and the time from the last command in seconds (4 bytes) as its second argument. All other arguments shall be 1-byte parameters.


After each instruction packet is received, the system controller will respond with the READY packet if it is ready to receive the next instruction set, or the NOT_READY packet to abort the procedure.


Check Status

The check status command may be used by the user interface controller to query the recipe execution progress.

Send the CHECK_STATUS byte <0x03> will cause the system controller to respond with a packet that contains the number of the command that was last executed. For example, a packet of the format:

  • <0x01><0x04><0x02>

would indicate that the 4th command in the recipe was the last command to be executed.


Summary of Command List


typedef enum
{
    COMMAND_START     = 0x01,
    COMMAND_END       = 0x02,
    COMMAND_STATUS    = 0x03,
    COMMAND_HEAT      = 0x04,
    COMMAND_DISPENSE  = 0x05,
    COMMAND_STIR      = 0x06,
} commandList_E;

// READY Packet Format
<0x01><0x01>

// NOT_READY Packet Format
<0x02><0x02>

// Standard Packet Format
<start_1_byte><num_parameters_1_byte><command_1_byte><time_since_last_4_bytes><parameters_multiple_bytes><end_1_byte>

// Check_Status Packet Format
<check_status_command_1_byte>

// Check_Status_Response Packet Format
<start_1_byte><instruction_number_1_byte><end_1_byte>
33 views

Recent Posts

See All
bottom of page