Design

The Varifocal motherboard schematics and wiring can be found here at https://github.com/icanc0/varifocal-motherboard. For a better viewing experience, please download and open the project with KiCad.

The firmware would utilize RP2040 features to maximize performance. Such as PIO, interpolators, PWM/UART/I2C/Timer Peripherals.

We’ll be using FreeRTOS with the RP2040. An example can be found here: https://github.com/raspberrypi/pico-examples/blob/master/freertos/hello_freertos/hello_freertos.c.

Firmware Architecture

graph TD;
    PD["USB-C PD Port (PD Decoy)"]
    Charger["PD Charger (12V)"]
    FUSB302["FUSB302<br/>PD PHY"]
    MCU["RP2040<br/>(Firmware Core)"]
    HostUSB["USB Port (Host PC)<br/>UART/Serial"]
    Command["Serial Command Handler"]
    Hall["TMAG5273<br/>Hall Sensor"]
    Feedback["Position Feedback"]
    MotorDrv["DRV8841<br/>Motor Driver"]
    VCM["Voice Coil Motor"]
    PID["PID Control Loop"]

    Charger -.-> PD
    PD --> FUSB302
    FUSB302 --> MCU

    HostUSB --> Command
    Command --> MCU

    MCU -->|I2C| Hall
    Hall --> MCU

    MCU --> Feedback
    Feedback --> PID

    Command --> PID

    PID -->|PWM| MotorDrv
    MotorDrv --> VCM

References

image.png

Bare PCB

image.png

Actual PCB

List of components

Component Description
RP2040 Main microcontroller
DRV8841 H-bridge motor driver used as Voice coil motor drivers
FUSB302 PD PHY for 12V negotiation
TMAG5273 Hall sensor for feedback. Exists on a separate daughter board.
UART/Debug 3 pin Dupont/JST to be used with Raspberry pi debugger