DMX512-Receiver

The reception of DMX siganl with a Microcontroller no longer is a problem. However, there are a few basic points to consider. The basic framework is already receiving the DMX signal and places it in a "buffer".

The code still needs to be complemented at the output of multiple channels and a query a code switch to the start address of destination. Alternatively, it can be done with buttons and a display. Both require some pins of the microcontroller, which then no longer usable as outputchannels. Therefore display and buttons in the following project are controlled via I2C.

Since the Bascomversion 1.11.9.4 DMX-reception via high-level command is supported. The configuration is done with: Config Com1 = Dmxslave, channels = 16, start = 3, store = 1!

Bascom Basic Sourcecode

'--------------------------------------------------------------
'                        DMX-Empfang.bas
'       Grundgerüst für den Empfang des DMX-512 Signals
'                  (c) 2008, Günter Gerold
'                        Fileversion 1.0
'--------------------------------------------------------------
$regfile = "m8def.dat"
$crystal = 16000000                                         'selbst mit 8MHz kommt der Code noch locker mit
$baud = 250000
'USART auf DMX512 einstellen
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 2 , Databits = 8 , Clockpol = 1
On Urxc Empfang
Enable Urxc
Enable Interrupts

'Puffer für das angekommene Byte aus dem DMX-Signal
Dim X As Byte
'Alle 512 Kanäle werden in diesem Array gehalten
Dim Buffer(512) As Byte
'Der aktuelle Kanal in der Schleife
Dim Kanal As Word

Do
'Hier muß noch dein genialer Code rein...
Loop

'--------------------------------------------------------------
'
'Empfang:
'
'steht in der USART ein Byte an, wird ein Interrupt
'ausgelöst und folgender Code abgearbeitet:
'--------------------------------------------------------------
Empfang:
X = Udr
   If Ucsra.fe = 1 Then
      Kanal = 0
   Else
      Incr Kanal
      If Kanal < 513 And Kanal > 0 Then Buffer(kanal) = X
   End If
Return