New Member Training - Autonomous-Motorsports-Purdue/Electrical_Documentation GitHub Wiki

This document will walk new members to the Electrical subteam through some relevant skills to begin contributing to the club in a meaningful way.

MCU

Arduino Tutorial: Adafruit Arduino Tutorial Use the above for main reference page or links below for the most relevant sections. Note that these links are for sections 0-4.

NOTE: if you don’t have a physical Arduino, you can simulate it with TinkerCad

Start Here: adafruit.com/ladyadas-learn-arduino-lesson-number-0/take-a-tour

Once you have completed the above sections and are comfortable writing Arduino Programs continue to the following problem statement.

Objective:

Write an Arduino sketch to parse a serial packet structure for controlling the go-kart state machine

Kart States:

  • Default
    • Default state that the kart is automatically in upon startup
  • Enable
    • Kart is enabled (able to drive) but no throttle, steering signals are sent.
  • Drive
    • contains control packet/s for throttle, steering, and braking
  • Error
    • Something went wrong so shut down the kart
      • crc failed
      • E-stop packet is sent
      • E-stop hardware button pressed

Requirements:

  • Packets must have header information (header byte indicating the packet id)
  • Packets must have some sort of validation check
    • recommend using a basic cyclic redundancy check (crc)
  • Packets need to have a variable-length for Drive/control packets
    • able to send drive packet with any combination of throttle, steering, and braking control sub-packets\

Hints:

  • use Serial.println() throughout the program to simulate the functionality for each state
    • i.e. you don’t have to flesh out the functionality of the states, only the changes between said states
  • Suggested Steps:
    • Sketch out (on paper) the state machine responding to all possible inputs/outputs
    • Create a sketch that echos back the serial data that is sent to it
    • Create a state machine that will cycle through based on any serial input
    • Modify the state machine to only change state on the “correct” input
    • Compile your serial structure into the code so that based on the serial packet sent, the state machine changes

Get creative with this. If you think that it would be easier to format the serial in such a way that we would want to reformat the kart states, do it! This is supposed to be an exercise in problem-solving and design so feel free to try things and don’t be afraid to get things “wrong”.


Hardware

FYI

  • Basic Electronics Crash Course link