Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Interfacing / Re: DMX woes... on: September 17, 2009, 09:24:59 am
Hi all. This is my first post on this site.
I managed to abapt the code on the Macetech site and splice it into the above DMX recive code, enabeling me to run five ShiftBright's. The computer with the code on it is not to hand at the moment, but if anyone is inerested I could post it at a later date. I work in the concert lighting business, I hooked my test bed (that looked like a birdsnest) into the system. The address set in the program was the same as an Led fixture in the rig and they both behaved the same  smiley Sorry I didnt think of taking any photos. I am new at this!
So It it would not be to hard to adapt the code to work with a TLC5940.
2  Forum 2005-2010 (read only) / Interfacing / Re: Use Arduino to switch 64 220v lights? on: March 24, 2010, 08:37:31 am
If your not paying the bill and there is enough mains I would say go for it  smiley-wink
3  Forum 2005-2010 (read only) / Interfacing / Re: Use Arduino to switch 64 220v lights? on: March 24, 2010, 05:18:12 am
Wow 69 amps. This is way above any standard house wiring. If you intend to use this in your home you had better seek permission from the bill payer  smiley-wink.
Your calculation is based on everything on at the same time, if this is not going to happen you might get away with it.
I don't want to preach but as everyone has already said, you are dealing   with possible lethal voltages please be very very careful. Not only when working on the project but also when its turned on and fault finding, because it's very easy to see a problem and steam in to fix it and forget to turn it off. You are probably board of people going on about this but we all care about fellow hobbyists.
4  Forum 2005-2010 (read only) / Interfacing / Re: Use Arduino to switch 64 220v lights? on: March 22, 2010, 11:21:19 am
If you use solidstate relay's you might be able to get away without using extra hardware between the shiftregisters and relay, because some if not all use an opto isolator in the low voltage side of the relay. Also some solidstste relays have a zero crossing circuit in them that will only turn on the relay when the mains voltage passes 0 volts. This prevents large current spikes. Hope this helps
5  Forum 2005-2010 (read only) / Interfacing / Re: DMX + Shiftbrites on: February 18, 2010, 09:50:43 am
Hi Chaps.
I have adapted some code I found on this site and have been able to run
some shiftbrites. I managed to run 20 (thats all I have  smiley )without any problems. My code is a bit crude, and a bit light on comments. The code here runs 10 Shiftbrights. I have run them next to a professional LED lighting fixture and they worked very well.
// The DMX reciver
// DMX reciver code for arduino with ATmega 168
// It is based on Hendrik Hoelschers dmx code from
// This code was adapted for the ATmega 8 by big_mark_h
// And finaly Gustaf Gagge adapted it for ATmega 168 with lots of help from big_mark_h and Grumpy_Mike
// Simon Howarth then adapted it and added the code to control a number of ShiftBright's

#include <avr/io.h>
#include <stdint.h>
#include <avr/interrupt.h>

// ********************* local definitions *********************
#define DMX_CHANNELS    (30)            //Define the number of DMX values to store. 3 for each ShiftBright

enum {IDLE, BREAK, STARTB, STARTADR};      //DMX states

uint8_t  gDmxState;
uint8_t  *gDmxPnt;
uint16_t DmxCount;

uint8_t  DmxField[DMX_CHANNELS];     //array of DMX vals (raw)
uint16_t DmxAddress;                   //start address

int datapin  = 9; // DI
int latchpin = 10; // LI
int enablepin = 11; // EI
int clockpin = 12; // CI
int Count;
int Tred;  // Temp value red
int Tgreen;  // Temp value green
int Tblue;  // Temp value blue

void setup()                           // run once, when the sketch starts
  // sets the digital pin as output
  pinMode(datapin, OUTPUT);
  pinMode(latchpin, OUTPUT);
  pinMode(enablepin, OUTPUT);
  pinMode(clockpin, OUTPUT);
  digitalWrite(latchpin, LOW);
  digitalWrite(enablepin, LOW);

  // Disable interrupts

  // 250kbps baud - only works for 16MHz clock frequency. See the ATMega8 datasheet if you are using a different clock speed
  UBRR0H = 0;
  UBRR0L = 3;

  // enable rx and interrupt on complete reception of a byte
  UCSR0B = (1<<RXEN0)|(1<<RXCIE0);
  UCSR0C = (1<<UMSEL01)|(3<<UCSZ00)|(1<<USBS0);

  // Enable interrupts

  gDmxState= IDLE;

  uint8_t i;
  for (i=0; i<DMX_CHANNELS; i++)
    DmxField[i]= 0;

  DmxAddress= 1;  //Set the base DMX address. Could use DIP switches for this.

void SB_SendPacket(int SB_CommandMode, int SB_RedCommand, int SB_GreenCommand, int SB_BlueCommand) {
  unsigned long SB_CommandPacket;
  SB_CommandPacket = SB_CommandMode & B11;
  SB_CommandPacket = (SB_CommandPacket << 10)  | (SB_BlueCommand & 1023);
  SB_CommandPacket = (SB_CommandPacket << 10)  | (SB_RedCommand & 1023);
  SB_CommandPacket = (SB_CommandPacket << 10)  | (SB_GreenCommand & 1023);

  shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 24);
  shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 16);
  shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 8);
  shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket);

void SB_Make_It_So() {
  delay(1); // adjustment may be necessary depending on chain length
  digitalWrite(latchpin,HIGH); // latch data into registers
  delay(1); // adjustment may be necessary depending on chain length

void loop()                     // run over and over again
   for (Count = 1; Count<= 10; Count++){ // set ShiftBrights to full
  for (Count = 0; Count<=27; Count +=3){
    Tred = DmxField[Count] * 4; //Times by 4 because dmx is only 8 bit
    Tgreen = DmxField[Count+1] * 4;
    Tblue = DmxField[Count+2] * 4;
    SB_SendPacket(B00, Tred, Tgreen, Tblue);


// *************** DMX Reception ISR ****************
uint8_t USARTstate= UCSR0A;                              //get state
uint8_t DmxByte= UDR0;                                    //get data
uint8_t DmxState= gDmxState;                              //just get once from SRAM!!!

if (USARTstate &(1<<FE0))                              //check for break
      UCSR0A &= ~(1<<FE0);                              //reset flag
      DmxCount= DmxAddress;                              //reset frame counter
      gDmxState= BREAK;

else if (DmxState == BREAK)
      if (DmxByte == 0)
            gDmxState= STARTB;                        //normal start code detected
            gDmxPnt= ((uint8_t*)DmxField +1);
      else gDmxState= IDLE;

else if (DmxState == STARTB)
      if (--DmxCount == 0)                              //start address reached?
            gDmxState= STARTADR;
            DmxField[0]= DmxByte;

else if (DmxState == STARTADR)
      uint8_t *DmxPnt;
      DmxPnt= gDmxPnt;
      *DmxPnt= DmxByte;
      if (++DmxPnt >= (DmxField +DMX_CHANNELS))             //all ch received?
            gDmxState= IDLE;
      else gDmxPnt= DmxPnt;

6  Forum 2005-2010 (read only) / Interfacing / Re: Simple timestamp in serial window? on: October 09, 2009, 08:21:11 am
Hi. Have you looked at He has a nice looking RTC board that is compatible with the Arduino, even some sample code for you. I hope this helps  smiley
Pages: [1]