Vermes
Advanced Member level 4
It is a DMX switch which can be used during a disco. The whole design was made in BASCOM-AVR environment. Program takes half of the microprocessor's space. Triac with a large supply of current is the executive system. Except the reliability, this solution also provides the possibility of temporary operation with a much larger load.
DMX signal is received by UART of Atmega8. You can find on the Internet how to configure hardware UART to work with DMX signal. Piece of code responsible for configuration of UART and interrupt support is shown below. Additional variables improve reliability such as checking whether the DMX packages are correct.
Code:
$crystal = 12000000
$baud = 250000
*
'uart dmx
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 2 , Databits = 8 , Clockpol = 1
On Urxc Dmxint
Enable Urxc
Enable Interrupts
*
*
Dmxint:
Etimer5 = 0
Odb = Udr
If Ucsra.fe = 1 Then
Incr Dmxoklck
If Dmxoklck > 8 Then Dmxoklck = 1
Dmxok(dmxoklck) = Maxkanal
Maxkanal = 0
Kanal = 0
Reset Watchdog
Else
Incr Kanal
If Kanal > Maxkanal Then Maxkanal = Kanal
If Kanal = Adresdmx Then If Dmxbad = 0 Then Odbior = Odb
End If
Return
Diagram and other pictures:
Display is controlled directly from ports with multiplexing. Only one segment lights in one moment – this solution allows you to resign from a lot of resistors for each cathode of the display – there is only one resistor in anode. Thus the display should be as bright as possible, because it is refreshed in 24 cycles, so that each segment lights with an average current ratio of 1/24 of current of limiting resistor. 3 digit red displays provide good brightness.
Handling of keyboard is protected against short pins of interference or very used buttons (delay of pressing and releasing statements).
Setting the address consists of three buttons, each of them changes the other digit. The address is stored in two places of EEPROM with the control sum in order to improve the reliability.
Mode PROT 10% - enabled by holding down the button. It allows the operation with a protection against enabling the output for more than 10 seconds during about 80 seconds. The device calculates the fill factor, so that a series of short starts but in small intervals results in activation of the protection. This mode is useful for example when working with blinders.
Manual mode – output can be operated and its default state can be defined even when there is no DMX signal.
Link to original thread (useful attachment) - Switch 1-kanałowy DMX [Atmega 8][BASCOM]