Arduino Forum

Community => Exhibition / Gallery => Topic started by: mcnobby on Nov 11, 2014, 08:59 am

Title: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Nov 11, 2014, 08:59 am
Hi All,

I thought I would publish this for all those who are interested in DMX and those clever little WS2812 RGB leds

Its written to fit in an ATTiny13A which has 1k of flash space and 64 bytes of Ram

Code: [Select]
/*
ATTINY13 - DMX512-Receiver to 4 x WS2812 driver - 9.6mhz - 962 bytes
LED to show that DMX data is being received
Up/Down buttons to select DMX RX channel - both held will reset channel to 1
Channel saved to EEprom
Requires 75176 differential transceiver chip to interface DMX to ATTiny13

Get tiny13 cores -> http://forum.arduino.cc/index.php?topic=89781.0

boards.txt entries :
attiny13at9.name=ATtiny13 @ 9.6MHz (internal 9.6 MHz clock)
attiny13at9.bootloader.low_fuses=0x3a
attiny13at9.bootloader.high_fuses=0xff
attiny13at9.upload.maximum_size=1024
attiny13at9.build.mcu=attiny13
attiny13at9.build.f_cpu=1200000
attiny13at9.build.core=core13

                 RESET 1 -     - 8 VCC
     DEBUG/LED/A3/Pin3 2 -     - 7 Pin2/A1/SCK/WS2812 data
  DMXin+/DMXin/A2/Pin4 3 -     - 6 Pin1/MISO/PWM/CHANUP button to 0v
                   GND 4 -     - 5 Pin0/MOSI/PWM/CHANDN button to 0v
*/

#include <avr/eeprom.h>
#define WAIT_FOR_BREAK_START 0
#define WAIT_FOR_START_BIT 1

// Pin definitions
#define DMX_IN 4 // PortB4 = actual pin 3 on chip
#define INPUT_PULLUPS 0b00000011 // pin 0 & 1 for pull ups only
#define UP_KEY 0b00000010
#define DN_KEY 0b00000001
#define KEYS   0b00000011
#define DEBUG_PIN 0b10000000
#define LED_MASK 0b00001000
// precise timings etc
#define MAXCHANNELS 512
#define PINMASK 0b00010000
#define DEBOUNCE 100 // debounce time in micros
// WS2812 specific
#define DIGITAL_PIN   (2)         // Digital port number
#define PORT          (PORTB)     // Digital pin's port
#define PORT_PIN      (PORTB2)    // Digital pin's bit position
#define DMX_PIN       (PORTB4)
#define NUM_CHANS     (13)

uint8_t lastRaw, key; // 2 bytes (2)
uint8_t rxData, state, chCount, x, LED_count; // 5 bytes (7) // flags,
unsigned long keyTime; // 4 bytes (11)
uint16_t DMXstart, rxCount; // 4 bytes (15)
uint8_t dmxData[NUM_CHANS];  

void setup(void) {
  DDRB |= 0b00001100; // set data direction for debug etc
  PORTB |= INPUT_PULLUPS; // used when setting key inputs
  // EEPROM INIT (if uninitialsed, then init !)
  if ( eeprom_read_byte((unsigned char *) 2) ) {
    eeprom_write_byte((unsigned char *) 2, 0 ); EEPROMwrite(1);
  }
  // READ EEPROM
  DMXstart = eeprom_read_byte((unsigned char *) 0) + ( eeprom_read_byte((unsigned char *) 1) <<8 );
  cli();
  WS2812(); // clear LEDs
}

void loop(void) {
  cli();
  switch (state) {

    case WAIT_FOR_BREAK_START:
      asm ( "L_%=:\n\t" "sbic %0, %1\n\t" "rjmp L_%=\n\t" :: "I" (_SFR_IO_ADDR(PORT)), "I" (DMX_PIN)  ); // wait for break to start (HIGH->LOW)
      chCount = 0;
      while (chCount < 22 ) { // this value should really be <22 to measure 88us
        asm ("ldi %0,8\n break:\n dec %0\n brne break\n" :: "r" (8) ); // to give a 4us loop
        if (PINB & PINMASK) { chCount=0; }  // if High then reset count
        else { chCount++; }
      }
      while (!(PINB & PINMASK)) { }  // wait for break to expire
      if (!LED_count--) { // heartbeat indicator
        PORTB ^= LED_MASK; LED_count=16;
      }
      rxCount = chCount = 0; // reset byte counter
      state = WAIT_FOR_START_BIT; // set next state

    case WAIT_FOR_START_BIT:
      while (PINB & PINMASK) { } // wait while input is high
      uint8_t m=1; // start bit mask at 0b00000001
      asm ("here1:\n dec %0\n brne here1\n" :: "r" (5) ); // delay to align sample of first bit
      for (x=0; x<8; x++) {
        asm ("ldi %0,7\n nop\n nop\n bits:\n dec %0\n brne bits\n" :: "r" (7) );
        // the above line may require adjustment for internal resonator
        // generally the 2 x NOPs work, but I have seen some requiring either one NOP or even NONE
        PORTB |= DEBUG_PIN; // do not remove
        if (PINB & PINMASK) { rxData |= m; }  
        if (!(PINB & PINMASK)) { rxData &= ~m; }  
        m <<= 1; // shift mask right
        PORTB &= ~DEBUG_PIN; // do not remove
      }
      asm ("stop:\n dec %0\n brne stop\n" :: "r" (5) ); // post bit read delay, wait for stop bits
      
      if ( (PINB & PINMASK) && (chCount <= NUM_CHANS) ) { // stop bit found ?
          if ( rxCount >= DMXstart )  { dmxData[++chCount] = rxData; } // ensure captured channel is in our range
          rxCount++; // get next byte
          state = WAIT_FOR_START_BIT; // go and grab next byte
          break;
      }
      // if you get to here then all required channels have been captured, so dump rest of packet and do WS2812 stuff
      else {
        uint8_t t; for (x=1; x<NUM_CHANS; x+=3) {
          t=dmxData[x+1]; dmxData[x+1]=dmxData[x]; dmxData[x]=t; // rearrange RGB input to GRB for WS2812
        }
        WS2812(); // output data to devices
        state = WAIT_FOR_BREAK_START; // start all over again
        break;
      }
   }
}

void WS2812(void) {
  for (volatile uint8_t y=1; y<NUM_CHANS; y++) {
      asm volatile(
          "ldi  %3, 8\n\t"      // reset number of bits
        "nextbit:\n\t"          // label                      
          "sbi  %0, %1\n\t"     // SET OUTPUT HIGH
          "sbrs %4, 7\n\t"      // Skip output low if HiBit in value is set  
          "cbi %0, %1\n\t"      // SET OUTPUT LOW, early for a low
          "sbrc %4, 7\n\t"      // Skip output low if HiBit in value is clear  
          "cbi %0, %1\n\t"      // SET OUTPUT LOW, late for a high
          "rol  %4\n\t"         // shift value left to get to next bit
          "dec  %3\n\t"         // decrement nBits
          "brne nextbit\n\t"    // branch if bits not finished
          ::
          // Input operands         Operand Id (w/ constraint)
          "I" (_SFR_IO_ADDR(PORT)), // %0
          "I" (PORT_PIN),           // %1
          "e" (&PORT),              // %a2
          "r" (8),                  // %3
          "r" (dmxData[y])          // %4
        ); // asm
    } // x loop
    readKeys();
}

void readKeys(void) {
    uint8_t raw = ~PINB & KEYS; // read key in reverse
    if (raw != lastRaw) {
     keyTime = micros();
    }
    if ((micros() - keyTime) > DEBOUNCE && raw != key) {
      key = raw;
      if ( key == KEYS ) {
        EEPROMwrite(1); // reset DMX channel to 1
      }
      if ( (key == DN_KEY) && DMXstart > 1) {
        EEPROMwrite(--DMXstart); // decrease DMX channel & save
      }
      if ( (key == UP_KEY) && DMXstart < (uint16_t) (MAXCHANNELS - NUM_CHANS) ) {
        EEPROMwrite(++DMXstart); // increase DMX channel & save
      }
    }
    lastRaw = raw;
}

void EEPROMwrite(uint16_t val) {
  eeprom_write_byte((unsigned char *) 0, val);
  eeprom_write_byte((unsigned char *) 1, val>>8);
}


Regards, Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Nov 11, 2014, 09:26 am
Video HERE (https://www.youtube.com/watch?v=Krsjzqjq9h0)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Nov 18, 2014, 09:11 am
Perhaps I should upload a circuit diagram, I shall do one !
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Genesis92 on Nov 18, 2014, 10:22 pm
great and interesting :)
The internal 9.6Mhz clock is ok over temperature range to have good timings for the DMX speed and asynchronous WS2812 chips?
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Nov 19, 2014, 09:02 am
great and interesting :)
The internal 9.6Mhz clock is ok over temperature range to have good timings for the DMX speed and asynchronous WS2812 chips?

The WS2812 are fine, but I have found the DMX can be a bit flakey over temperature and even some t13 chips are different to others... in saying that you get a lot of bang for your buck with this code.. its just a bit of fun.. I managed to make 10 working boards that seemed reasonably stable, although some of them needed tweaking timing wise (see notes in code) - really this should be done using the bits that can finely adjust the resonator frequency
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Genesis92 on Nov 19, 2014, 10:30 am
ok :)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Nov 19, 2014, 04:37 pm
and thanks for your interest Genesis :)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Bianco on Dec 29, 2014, 09:10 pm
Have you tried using main() and while(1) rather than setup() and loop()?

It saves a few hundred bytes in some situations.
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: smeezekitty on Dec 30, 2014, 08:29 am
Without setup(), many of the core functions won't work.
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Dec 30, 2014, 08:48 am
There have been several occasions where I have had to use main() instead of loop() etc, I think it may have had something to do with hijacking timer0 (on other projects).

I have had to go the main() route on THIS (http://forum.arduino.cc/index.php?topic=288766.0;topicseen) project, not only to save bytes, but it seemed to be the only way to solve a _vector error that I couldnt trace.. I think I looked it up on line somewhere and the suggestion was to move to main(), and by doing that I didnt noticd any loss in core functions as I write a fair amount in asm these days

:)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Bianco on Dec 31, 2014, 06:58 pm
Without setup(), many of the core functions won't work.
They will if you include the libraries, won't they?
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: tmaceng on May 26, 2015, 09:21 pm
You mentioned a circuit diagram.  Do you have one?  Board layout?  Thanks for sharing.  I would like to experiment with this for my christmas display 2015.
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on May 26, 2015, 10:10 pm
The circuit is very simple with the main connections being here

Code: [Select]
                 RESET 1 -     - 8 VCC
     DEBUG/LED/A3/Pin3 2 -     - 7 Pin2/A1/SCK/WS2812 data
  DMXin+/DMXin/A2/Pin4 3 -     - 6 Pin1/MISO/PWM/CHANUP button to 0v
                   GND 4 -     - 5 Pin0/MOSI/PWM/CHANDN button to 0v


I do have a board layout too, I shall dig that out and perhaps do a full schematic :)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: vaibhavphale on Dec 01, 2015, 06:21 am
Hi friends. I need a circuit diagram of this project. Can you please provide it to me?
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Dec 01, 2015, 02:40 pm
I made a PCB if that would help ?
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: vaibhavphale on Dec 01, 2015, 06:20 pm
OK sir
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Dec 02, 2015, 01:14 pm
There is a far better solution to serial reception than the above, it relies on counting cycles between leading edges of the received bits, and when a bit changes state within a 'window' the syncronisation is reset. With this application is it very useful as I have found that temperature and differences in ATTiny13's effect the clock somewhat and sometimes get data errors.

So either a resync on each bit is good (but tricky to implement) or a sync on the startbit of each byte only may be better

I have only written this approach in spec form and not coded yet, but it is on my list, and I am hoping it will still fit into the <1k bytes

This current application works by this method
1. lock onto start of DMX stream
2. read just enough bits/bytes that we need, then and stop reading
3. write serial data to the serial LEDs
4. the current DMX frame will still be streaming here but ignore it go back to (1)

I am not a big fan of coding like this, I prefer interrupts, but sometimes you have to break the rules, especially when you are trying to sniff data at 250kbps and write to LEDs at 800KHz !!
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Dec 02, 2015, 01:16 pm
To be honest the whole code would be better written in assembler rather than dodging in and out of C all the time, it would probably run more accurate and efficient too

this would be one C-code file with the assembler embedded in, and would happily run in the Arduino environment, so nothing special to do apart from write using USBISP
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Jun 02, 2016, 02:45 pm
I have rewritten this code to efficiently decode DMX512, all in assembler
using the internal 9.6MHz resonator, and accurate sample points, start/stop bit detection, Break and MAB detection, and error detection.

Currently using this to try and write to a much larger string of WS2812 LEDs, but the limitation is RAM (60bytes). I tried to slow the WS writes down so that they fell in-line with RX speed of the DMX bytes, but this is too slow for the WS chips and they seem to do their own thing !!

Nevertheless, I have a good solid DMX receiver

Just wondering what projects I can use this simple/cheap/small device on

DMX switch/relay ?

Any suggestions ??

Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: imayoda on Jul 20, 2016, 02:44 pm
Nice job for this, but asm is not in my chords (yet) unfortunately :)

I've seen lots of cinese commercial products like rgb pars (many watts) using overpowered stm8 mcus, similar in power to the 328p.

Open source tiny code is state of art for receivers, i'm trying myself to make custom pars or scene lights  with cheaper and smaller avr.

kudos to you
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Jul 21, 2016, 09:22 am
Hello imayoda

I am working on a much better DMX RX to WS controller, there were flaws in this design, which now I understand them I will be improving, most of the code is written, about 95% in AVR assembler

This will shortly be an "ATTiny85 to WS2801/11/12 NRZ & SPI converter", using the full 512 bytes (170 Pixels) and should be fully compliant with DMX512 (but not RDM)

Thanks for your comments

Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: j_dunavin on Oct 08, 2016, 10:13 pm
with this project, you are able to send DMX and change the led lights?


I would like to control these leds via an existing DMX controller. red green and blue faders.
Where in the code does it tell the LEDs what color to be?
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Oct 10, 2016, 09:24 am
with this project, you are able to send DMX and change the led lights?
Yes, that is the idea

Quote
I would like to control these leds via an existing DMX controller. red green and blue faders.
Where in the code does it tell the LEDs what color to be?
if you are using WS2812 leds then following would occur:
DMX chan 1 = Pixel 1 Green
DMX chan 2 = Pixel 1 Red
DMX chan 3 = Pixel 1 Blue
DMX chan 4 = Pixel 2 Green
DMX chan 5 = Pixel 2 Red
DMX chan 6 = Pixel 2 Blue
etc....
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Oct 10, 2016, 09:26 am
This project really needs a bit more thought and improvement
The ones I made work fine, but some controllers may cause this to go screwy.. on reflection it really needs an overhaul, perhaps all written in asm
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: j_dunavin on Oct 19, 2016, 04:41 pm
thank you for your reply. That would take up a lot of channels if I planned on using several strips.

Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Oct 20, 2016, 09:59 am
The ATTiny13A has only a very small amount of RAM, 60 bytes from memory, therefore I only used 12 channels (4 RGB Pixels) to allow me left over bytes to run my program, it is very tight !!
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: woody072 on Oct 23, 2016, 10:12 pm
Hi Bob, Have been reading several posts around DMX on Arduino.

I can confirm an answer to a question you asked sometime ago... DUE doesnt work with TinkerKit DMX Shield...

I have a project that I can get two halves to work, but need to interface them together.

Environment: Start lights and track signals for a Slot Car setup (havenwoodraceway.co.uk)

Objective: To control 2 x Banks of 5 x PAR CANs to simulate the start sequence of races
(Imagine PAR CANS doing the job of the LED's in this video
https://www.youtube.com/watch?v=cCZmtZ2FR_I)

Current Situation:
I have a PC running an application RCS 64 (rcs64.com) which controls a UNO for the lighting of individual LEDs'. The developers of this application are not prepared to open their source as they want to control the installation of their application from a single exe (understandable as they have a lot of development stuff going on that they are trying to support).

Approach:
My current thought was to implement an UNO driven by RCS64 and for it to connect to a DUE with Tinkerkit DMX Shield on, which would sniff the PWM output and then translate to DMX signals to the PAR CANS.

Status:
Cant get DUE to work with DMX Shield. So thinking of getting another UNO to do the DMX job.

But having seen your work I wonder if you have some other suggestions on how to achieve the objective? Grateful for any thoughts...

Best regards
Paul
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Oct 24, 2016, 09:53 am
Hi Paul

Google "MAX485 DMX"

The Max485 is a single chip solution to convert the serial data into differential data required for DMX.
I make these little convertor boards for next to nothing as you can buy MAX485 very cheaply, and you only need 0v/5v supply and the serial connection to TX from the Arduino

Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: woody072 on Oct 24, 2016, 08:36 pm
Thank you very much Bob. Chip has been ordered...
Suspect I might be coming back to you at a later stage to sanity check my thoughts on next steps.

Best regards for now
Paul
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: woody072 on Oct 25, 2016, 01:35 pm
And a general question...

In my logic the 5 DMX cans, hooked together in a serial fashion with XLR (3 pin), should each be addressed with their own first channel... i.e. 1st can (master) is channel 1 - red, can 2 - Channel 16 - red, Can 3 - Channel 24 etc

When using the DMX Shield I can only get action on the first can and first channel. My send strings from "Serial Monitor" have no effect on the subsequent cans....


Any suggestions?
Cheers
Paul
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Oct 25, 2016, 02:31 pm
And a general question...

In my logic the 5 DMX cans, hooked together in a serial fashion with XLR (3 pin), should each be addressed with their own first channel... i.e. 1st can (master) is channel 1 - red, can 2 - Channel 16 - red, Can 3 - Channel 24 etc

When using the DMX Shield I can only get action on the first can and first channel. My send strings from "Serial Monitor" have no effect on the subsequent cans....


Any suggestions?
Cheers
Paul
Hi Paul
You are right about the addressing, but im not sure why you are getting that results
Personally I would try the information at the following link, it works perfectly and alot of people use it

http://www.mathertel.de/Arduino/DMXSerial.aspx (http://www.mathertel.de/Arduino/DMXSerial.aspx)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Macarena on Jun 28, 2017, 10:40 pm
Will not work. I connected the kernel tiny. But it's new and the project is being compiled with an overabundance of memory
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Jun 29, 2017, 03:38 pm
Maybe the Kernel has been changed since I first posted this project
It was very very tight to fit the code into 1K, so perhaps this is the problem

It reality, this project need to be rewritten in assembler, not C

Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Macarena on Jun 29, 2017, 10:43 pm
Can someone have left the compiled code for firmware microcontroller?
Thank you
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Macarena on Jul 11, 2017, 11:43 pm
No one can help me?
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Jul 13, 2017, 11:08 am
I would like to help, but it not a project I have been working on for quite some time, not sure that I am even set up for it

Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: smeezekitty on Jul 15, 2017, 02:48 am
If your code is too big, I suggest trying a newer version of avr-gcc. I found that newer versions generate significantly smaller code. The version included with winavr if you are using that is quite old
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Macarena on Jul 31, 2017, 09:38 am

I do not have any programming experience at all, I found this project very compact and functional for installing something inside the DMX controller for the signal monitor.
 Help me please .
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Jul 31, 2017, 10:11 am
why not just buy one of these
http://www.ebay.co.uk/itm/321934091091 (http://www.ebay.co.uk/itm/321934091091)
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: bipsen on Jan 07, 2018, 11:28 am
Hi Bob,

I thought I would publish this for all those who are interested in DMX and those clever little WS2812 RGB leds

Its written to fit in an ATTiny13A which has 1k of flash space and 64 bytes of Ram

While searching the internet for a simple (and small) implementation of something to control a RGB LED via DMX, I stumbled over this thread.

A suggestion for improvement (in case someone is skilled enough to do the merge of the programming), is to implement the gammacorrection in the code, and maybe change the way to set the DMX address as done in the code on https://www.pcdimmer.de/downloads/Firmware_Treiber/DMX512/pc_dimmer_dmx512_rgbled.zip ?

The chip might have to be changed to a version with more memory - but due to the simplicity of the circuit (and size of components), it can probably be put on a really small PCB...  :-)

Brian
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Jan 08, 2018, 10:23 am
Thank you Brian, I have moved on some way since doing this project and make all types of DMX devices now using Atmel, ST32 and ESP8266. The initial program was not that great at receiving DMX as there was instability due to timing errors. One day I will rewrite it just for fun (I have a greater knowledge of DMX & Pixel data now)

Interesting though about the gamma correction, but generally PC applications that send out pixel data (over DMX) is already gamma corrected by the application (Jinx live-leds.de for example)

Regards Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: bipsen on Jan 09, 2018, 10:12 pm
Well, my interrest in the ATtiny13 circuit was due to the small requirement for physical space...
An ATTiny13 with a WS2811 - some transistors and a 75176 or similar...

I am trying to figure out, if I somehow can put a DMX RGB circuit inside this 3D printed part (with minor adjustments to the back piece): https://www.thingiverse.com/thing:2051738

I know, that I probably will have to use some 1.25mm spaced JST connectors for DMX IN/OUT, but that is the least of my challenges...

There is a physical limit on the PCB, that should hold the circuit - approx 17x11 mm  :o  ... And I would like to try to drive a 3W RGB LED with it (not full power, though - I think total current will have to stay below 200mA in order for the LED not to get too warm) ...
A 20 pin SOIC 2313 takes up too much space - and I am not sure, that I will be able to solder a ATmega328P in a 32 pin TQFP package by hand ...
 
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: bipsen on Jan 10, 2018, 09:53 pm
Thank you Brian, I have moved on some way since doing this project and make all types of DMX devices now using Atmel, ST32 and ESP8266. The initial program was not that great at receiving DMX as there was instability due to timing errors. One day I will rewrite it just for fun (I have a greater knowledge of DMX & Pixel data now)
ESP8266 - isn't that the one usually being used with 2.4GHz networks? I have a couple of 2.4 GHz DMX transceivers somewhere (from China).. Would a ESP8266 be able to listen for DMX data from those, and maybe control a RGB LED ?

In the meantime I'm searching for an alternative 3-channel PWM dimmer solution with DMX C-sourcecode for a 32 pin TQFP AVR chip instead - ATmega168 or 328 or similar... Have not found anything useful yet, though...

Regards
Brian
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Mar 05, 2018, 12:20 pm
Hello Brian

How are you getting on with your ATTiny13/WS2811 project ?
I am in the process of making an ATTIny13a receive the WS2812 data, decode it and turn it into something useful, currently its is driving servos, but I also intend to drive PWM motor off and H-Bridge

I have had to crank up the clock from 9.6MHz to 16MHz using OSCCAL, but works an absolute treat !
Full use of the Timer0 (the only timer) where I shift it between several modes, once it hits its first interrupt mode I then change the interrupt type etc, then let it hit the next interrupt

I hope to publish code for this soon, once all the bugs are ironed out and I have a fully working circuit (actually there are NO components other than a bit of decoupling !)

Bob
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: smeezekitty on Mar 10, 2018, 06:02 pm
You can increase the OSCCAL that much??
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: mcnobby on Mar 14, 2018, 05:59 pm
You can increase the OSCCAL that much??
Well I seem to have done so, and it works !
Title: Re: FINISHED PROJECT: ATTiny13A DMX Receiver, to WS2813 LED controller in 962 bytes
Post by: Macarena on Mar 22, 2018, 07:49 pm
I got the hope of getting the code for a DMX tester, can I become a happy HEX owner?
I'm sorry, who can share the HEX code for Tiny?