RC08Firmware

From RoboJackets Wiki
Jump to navigation Jump to search

The firmware resides on the microcontroller and includes software to implement the protocol, control the motors, and perform closed loop control on the motors and the robot itself.

Tasks

  • [X] Generate an I/O spec
  • [X] Evaluate the the current protocol - Currently no changes will be made until after the robot hardware is finished
  • [X] Update if necessary
  • [X] Add code to interface with FPGA using SPI or serial
  • [X] Implement timer based psuedo-preemptive scheduler
    • [ ] Investigate actual preemptive schedulers
  • [ ] Add transmit channel from robot to base station
  • [X] Support base station development (Note: Jake has Phillips Butterfly)
  • [X] Re-map printf to ARM and write RX buffer code as an interrupt (Note: Not enough memory to use printf wrote my own)
  • [X] Code and test AD function
  • [ ] Model motors in Simulink, build a PID controller and find good gains
    • [ ] Add wheel slip to model and see if it can be controlled
    • [ ] Investigate if a state-estimator can be used in place of PID
      • [ ] Investigate if ARM can handle the load and maintain appropriate sample rate
      • [ ] See if coding a better scheduler will help
      • [ ] See if encoder resolution is enough to even make this work (may not)
  • [ ] Write code to determine velocity using counter
    • [ ] Extend that code to use accelerometer and Kalman filter
  • [ ] Write PID controller for robot and test
  • [ ] Integrate the entire system and test

Code Documentation

Protocol

General packet format:

Sync sequence   3 bytes: FF FF FF
Type/length     1 byte
    Bit 7:5 - Type
        Types 000-011 are base -> robot (forward).
        Types 100-111 are robot -> base (reverse).
    Bit 4:0 - Length (including this byte but not sync or CRC)
Data            <length - 1> bytes
CRC             2 bytes

The sync sequence must not appear anywhere in the packet except to
denote the beginning of the packet.  If it appears anywhere else,
it will be interpreted as the beginning of another packet and the packet containing
it will be ignored.

Note that the last data byte may not be FF in case the CRC bytes are FF FF.

Motor command packet:
    0       Type/length == 0x17
    1:4     Motor speeds for robot 0
    5:8     Motor speeds for robot 1
    9:12    Motor speeds for robot 2
    13:16   Motor speeds for robot 3
    17:20   Motor speeds for robot 4
    21:22   Flags, little endian:
        Bit 15:13   - Reserved, set to zero
        Bit 12:10   - Which robot should kick, 5-7 means no kick.
        Bit 9   - Robot 4 charge
        Bit 8   - Robot 4 roller
        Bit 7   - Robot 3 charge
        Bit 6   - Robot 3 roller
        Bit 5   - Robot 2 charge
        Bit 4   - Robot 2 roller
        Bit 3   - Robot 1 charge
        Bit 2   - Robot 1 roller
        Bit 1   - Robot 0 charge
        Bit 0   - Robot 0 roller

Files (In alphabetical order)

AD.c

Buzzer.c

crt0.s

delay.c

FPGA_bus.c

interrupt.h

motor.c

number.c

packet.c

packet_handler.c

PID.c

radio.c

robot.c

scan.c

Threadz.c

uart.c

VIClowlevel.c

Links