This program will capture and display DCC messages off the tracks. It will capture all messages, or filter messages with a specific address. Filtering only works with addresses in the range 0-127.
Copy the main.py and dcc_capture.py files to the pico module, then cycle power. I use putty to communicate with the module so I can save messages to a log file.
This is the program main. It sets which GPIO pins are used. It has a callback function to receive messages from dcc_capture.py. It handles address filtering and display.
The DCC_Capture class contains a PIO routine to decode the DCC signal. Data bytes are written to the fifo and a interrupt is generates at the end of each message. A DMA controller copies the data to a buffer. An IRQ routine copies the message data, adds a timestamp, then calls a user callback function. The timestamp is in units of milliseconds.
This is the circuit I used to read the signal from the tracks. Please note, component selection was influenced by the contents of my spare parts bin.
This class generates a DCC signal for testing of the DCC_Capture class.
This is the main program that controls a loopback test.