3 flavours of DMX UART/PIO/VERILOG

DMX512 is the official standard for transmitting up to 512 channels of lighting signals (a DMX universe) over a standard 2-wire half duplex RS485 interface. At first glance, generating DMX signals seems simple. This is a dangerous misconception, to implement DMX correctly you must be aware of the details and also how to verify them. This article will show you these details and 3 different ways to implement DMX correctly. By using a standard RS485 transceiver we implement 3 flavors.
1) old style UART MCU (not scalable, timing issues)
2) raspberry-pi pico PIO assembly using micropython (limited scaling)
3) FPGA technology demonstrating verilog and wishbone bus (unlimited scaling)
Shows how to create transmitters and receivers with accurate signal timing.
DMX needs extra care because of frame start detection using Mark/Space/Break detection, this makes implementation non-trivial.
Language for RPI2-Pico : micropython + pio assembly
Language for FPGA : Verilog
Used hardware:
MCU : Arduino Mega2560 https://www.elektor.nl/arduino-mega-2560-rev3
FPGA : Sipeed Tang Nano 9K Fpga https://wiki.sipeed.com/hardware/en/tang/Tang-Nano-9K/Nano-9K.html
Pico : RP2040 https://www.elektor.nl/wiznet-w5100s-evb-pico-rp2040-based-evaluation-board
Problems with common UART based implementations and timers/interrupt handling will be made clearly visible.
DMX hardware is also required : preferred on isolated RS485 transceiver board like : https://nl.farnell.com/digilent/410-310/evaluation-board-rs485-communication/dp/2528810
or a arduino DMX shield like : https://www.tinytronics.nl/shop/nl/communicatie-en-signalen/serieel/rs-485/dfrobot-dmx-shield-voor-arduino
Challenges :
* correct creation of DMX signal including Mark/space/break timing.
* correct detection of DMX frame start and ending, including short frames (not full universes)
* detecting change of DMX universe size
* detection of framing errors
* handling other tasks while doing DMX, using interrupts or DMA or other tricks
* testing the implementations for correctness and corner cases
This article will show common pitfalls for DMX timing and running other tasks at the same time.
Read code will be created step by step and explained based on the specific hardware/software implementation.
This is a 3 course meal, enjoy.
#oetelx
==== Nederlands ====
Demonstratie van 3 technologieën naast elkaar :
1) oude stijl UART MCU (niet schaalbaar, timing problemen)
2) raspberry-pi pico PIO assemblage met micropython (beperkte schaalbaarheid)
3) FPGA-technologie met gebruik van verilog en wishbone bus (onbeperkte schaalbaarheid)
Toont hoe zenders en ontvangers te maken met nauwkeurige signaal timing.
DMX heeft extra aandacht nodig vanwege frame start detectie met Mark/Space/Break detectie, einde frame is niet-triviaal.
Taal voor Arduino : 'C'
Taal voor RPI2-Pico : micropython + pio assembly
Taal voor FPGA : Verilog
Gebruikte hardware:
MCU en/serieel/rs-485/dfrobot-dmx-shield-voor-arduino
Uitdagingen :
* correcte generatie van DMX signaal inclusief Mark/space/break timing.
* correcte detectie van DMX frame start en einde, inclusief korte frames (niet volledige universums)
* detecteren van verandering van DMX universum grootte
* detectie van framing fouten
* afhandeling van andere taken terwijl DMX bezig is, met gebruik van interrupts of DMA of andere trucs
* testen van de implementaties op juistheid en onvoorziene situaties
Dit artikel zal veel voorkomende valkuilen laten zien voor DMX timing en het uitvoeren van andere taken op hetzelfde moment.
Implementaties worden stap voor stap getoond en uitgelegd op basis van de specifieke implementatie-eigenschappen van de hardware en software.
.
Dit is een 3 gangen menu, geniet ervan.
Diskussion (6 Kommentare)
Gunther Jordan vor 2 Jahren
Deltor vor 2 Jahren
mikaudio vor 2 Jahren
Frank Plöger vor 2 Jahren
DMX is so successfull, because it's very easy! But if it's too easy for you, you are free to make it complicated with complex FPGAs or high-level-processors on linux like RPi.
I'm using DMX on simple AVRs since AT90S2313 with assembler code. It's very easy using the frame-error to detect the break or generate a break and MAB with timers and then run the UART in the background. There is no need to make it complicated.
Deltor vor 2 Jahren
What are you talking about?
Who claimed to use a kernel?
Frank Plöger vor 2 Jahren
But overall, I understand the problems mentioned. The reason are the chosen languages: using python, c or arduino script and maybe using libraries programmed by others, it's hard to keep the timings. With assembler on a 8bit AVR at 8MHz or 16MHz it's no problem to detect the break, receive a universeframe, detect short universes (if needed), or send DMX.
Maybe this should be added to the project. Okay, assembler is not as easy as a few lines of arduino script but you can control the timings on a per instruction basis, so per nano-seconds. And interrupts help to do other things while continuously transmitting or receiving DMX.
madmen64 vor 2 Jahren
Thanks
Bartsw vor 2 Jahren
https://www.erwinrol.com/post/2021-05-02-fpga_dmx/
I will try to follow this project.
I think the fpga solution will always be better for a transmitter. (But it will be more expensive)
Maybe the receiver can be a MCU based controller.
Kind regards.
Mike Ellis vor 2 Jahren
Pjotr1010 vor 2 Jahren
Only links for the used hardware...
I am curious to read your article, hope to see it soon
Pjotr1010
eduino.io #oetelx vor 2 Jahren
Thank you for your interest in the project. It is a work in progress.
This project is a very large job, not just making it, but also documenting and writing a sensible article about it.
At the moment I am working on the FPGA implementation, together with a student of the Fontys University of Applied sciences which I am mentoring.
The raspberry pi pico I will do myself as an example.
The article is a work in progress, meant to show 3 solutions to the same problem.
I hope you have some patience.
Greetings,
Edwin
eengineer1982 vor 2 Jahren