Flynntestpage

From Stanford SSI Wiki
Jump to navigation Jump to search

Why do we need this?

The normal way our telemetry radio communicates is LoRa, which is a proprietary form of modulation designed for long distances. CircuitPython already has libraries for LoRa.

However, as part of the satellites operations, the satellite will need to transmit a beacon. This is basically a very slow, weporful message that we decide ahead of time. It is usually transmitted using morse code. As an example, our satellite might transmit "SSI" in morse code. This is usually implemented using something called On/Off Keying (OOK). Basically, the radio turns on to transmit a one and turns off to transmit a zero.

Our radio's hardware supports OOK, and there are drivers written for it already. However, none are in CircuitPython.

How do we implement this?

It's pretty much just writing a driver for the radio. We write values to various registers to set the radios configuration, and to receive and send messages. We will do this in CircuitPython.

What do we have to work off of?
We will start with the codebase for the existing driver (here). We also have the RFM98 datasheet (here). This is pretty much the same datasheet as the underlying radio chip, the SX1278 (datasheet is here). There's an existing implementation of the driver in the RadioLib library, except it's written in C (here). There are most likely other implementations (tip: you'll have more luck finding info if you search for SX1278, not RFM98).

With regard to RadioLib, most of the code is in the folder src/modules/SX127x/, in SX1278.cpp, SX127x.cpp, and their corresponding .h files. You can start in the beginFSK functions and then follow the code from there. FSK is another type of modulation, and the functionality for OOK is linked to the functionality for FSK (you'll see what I mean if you look at the relevant datasheet sections).

On a high level, how does the radio work?

Basically, the registers all have different functions in OOK mode versus LoRa mode. In OOK mode, we can set the relevant configurations (it looks like they will be bitrate, current limit, frequency, bandwidth, power, and preamble length). We can then create transmit and receive functions (it looks like the radio has intermediate states between transmit and receive, but they might be irrelevant). To receive, theres a FIFO that we put data in, which is read by SPI (there's another way to do this but it's probably not what we want). There's also some weird things with node addressing to be cognizant of.

What are some potential hurdles?

It will be hard to test since it's very low-level code. Also, it looks like the OOK module is designed to prepend a preamble to the data it sends, which might not be the behavior we want. There are two modes to use the OOK module, one involving raw pins, and I'm not sure which to use yet.