Skip to content

About

Code for UB NASA Lunabotics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

NASA Lunabotics: Dual-Core RTOS Motor Control & Telemetry System

Platform RTOS

Project Overview

This repository contains the firmware for the University at Buffalo NASA Lunabotics rover. The system serves as a deterministic communication bridge between an ESP32-S3 and a Beckhoff CX7000 PLC using Modbus TCP over a wired W5500 Ethernet connection.

The firmware is architected to prioritize motor control stability and real-time sensor processing through a dual-core FreeRTOS implementation.

System Architecture

Dual-Core Task Allocation

To ensure deterministic performance, tasks are pinned to specific CPU cores:

  • Core 0: Control & Communication (modbus_task)
    • Manages a non-blocking Modbus TCP client to interface with the Beckhoff PLC.
    • Executes a custom state machine for writing control/speed words and reading motor status.
  • Core 1: Sensing & User Interface
    • tof_task: Continuous 20Hz polling of the VL53L0X Time-of-Flight sensor for obstacle tracking.
    • oled_task: Updates an SSD1306 display with real-time distance metrics and system status.

Thread-Safe Hardware Management

The system utilizes FreeRTOS Mutexes to prevent bus contention on the shared I2C bus (SDA: GPIO 5, SCL: GPIO 4) used by both the ToF sensor and the OLED display.

Key Technical Features

  • Deterministic Control: Achieved a rigid motor control loop through non-blocking asynchronous callbacks and optimized task scheduling.
  • Hardware Interface: Utilizes SPI for the W5500 Ethernet controller to bypass Wi-Fi latency in high-interference environments.
  • Interactive UART CLI: A custom command-line interface allows for real-time troubleshooting and manual motor overrides (enable, stop, velocity tuning) without halting the RTOS scheduler.
  • Robust Signal Logic: Implemented digital filtering for sensor readings to filter invalid distance data and manage range status errors.

Commands & Debugging

The system features a serial interface (115200 baud) for live diagnostics:

  • enable: Energizes the motor system.
  • stop / disable: Halts all movement and clears target speed.
  • vel <n>: Dynamically updates the target speed word.
  • stat: Returns a snapshot of current motor status, command words, and sensor telemetry.

Dependencies

  • ModbusEthernet
  • Ethernet (W5500 support)
  • Adafruit_VL53L0X
  • Adafruit_SSD1306
  • Wire & SPI

About

Code for UB NASA Lunabotics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages