Pages: [1]   Go Down
Author Topic: DMX Out on ATTINY85-20...  (Read 1316 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am nuts about DMX and Arduino ! So getting them together is a real challenge and a joy for me !

My latest purchase is ATTiny85's, I have made an Arduino ISP board, and my first project was to get the tiny to spit out DMX signals to 512 channels (just dimming up/down for now), within half an hour I got it all working (although not tweaked) there were no glitches !

I shall post the code soon as its on my other PC

I intend to couple this DMX code with a simplified FFT code so that I can audio process music and convert it to 16 channels of light..Bob
Logged

while (z--) { snore; }

Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WORKING DMX CODE ON ATTINY85

Code:
#include "pins_arduino.h";
#define sig 3                 // DMX signal output pin
int value = 0;
int valueadd = 3;

void setup () {
  pinMode(sig, OUTPUT);
  digitalWrite(sig, HIGH);
}

void loop(){
  while(1){
    digitalWrite(sig, LOW); 
    delay(10);     
    shiftDmxOut(sig, 0);     
    for (int count = 1; count <= 512; count++){
      shiftDmxOut(sig, value);
    }
    value += valueadd;
    if ((value == 0) || (value == 255)){
      valueadd *= -1;
    }
  } // while
}

void shiftDmxOut(int pin, int theByte){
  int port_to_output[] = { NOT_A_PORT, NOT_A_PORT, _SFR_IO_ADDR(PORTB)};
  int portNumber = port_to_output[digitalPinToPort(pin)];
  int pinMask = digitalPinToBitMask(pin);
  _SFR_BYTE(_SFR_IO8(portNumber)) |= pinMask;
  //delayMicroseconds(10);
  cli(); 
  _SFR_BYTE(_SFR_IO8(portNumber)) &= ~pinMask;   
  fourUSdelay(); 
  for (int i = 0; i < 8; i++){
    if (theByte & 01){
      _SFR_BYTE(_SFR_IO8(portNumber)) |= pinMask;
    }
    else {
      _SFR_BYTE(_SFR_IO8(portNumber)) &= ~pinMask;
    }
    fourUSdelay();
    theByte >>= 1;
  }
  _SFR_BYTE(_SFR_IO8(portNumber)) |= pinMask; 
  sei(); 
}

void fourUSdelay(void) {
    asm("nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n");
    asm("nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n");
}

Logged

while (z--) { snore; }

Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code was butchered from another source, which I have also got working on a 644 and 1284...

It doesnt use interrupts, but since it is just a simple program, it just bashes everything out willy-nilly !

I have yet to try this on some other products other than my 4 channel 240v fader pack
Logged

while (z--) { snore; }

Offline Offline
Newbie
*
Karma: 3
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for posting.  My own project is for accepting a DMX signal, and using the data to control a motor. But, I learned that monitoring the DMX line would take a great deal of the Arduino's processing power.  So, I think I will instead us a DMX to Serial interface from http://www.chromationsystems.com ($25 kit).

Have you heard of anyone else creating a motor controlled by a DMX signal, and using an Arduino?

-Joe
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Joe, I have written many programs that convert DMX data into light and movement using LEDs and servos and stepper motors, it can be done and is not at all processor hungry. I have used http://www.mathertel.de/Arduino/DMXSerial.aspx many times, its a great library, worth a try... the examples are really good too. Bob
Logged

while (z--) { snore; }

Offline Offline
Newbie
*
Karma: 3
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In regards to my own project, when I say "servo motor" I am not referring to the integrated RC Hobby type of system.  Rather, I am looking at the type of servo that uses a separate motor and controller.  The controllers use feedback from an external potentiometer, or a quadrature encoder.  These typically involved a number of parameters that must be set, and can sometimes have fairly complex in terms of what the Arduino is capable of handling. A PID control system, which you might recognize.

My own project (for which I am simply evaluating the feasibility), is to create a Tinkerbell character by suspending a 6" ball of LED's from two cords located in the upper corners of the stage opening.  The cords are on a motorized reel, controlled by a DMX signal.  I was initially hoping to have a fairly precise positioning system that can be pre-programmed. But, I might simplify it to be just a live joystick control that only controls the speed of the motors.

Can you describe some of your projects that involved motors?

Joe Dunfee
jdunfee12@yahoo.com
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've made a few simple scanners and moving head devices that receive DMX, plus made a few DMX controlling devices too, all good fun !!!
Logged

while (z--) { snore; }

Offline Offline
Newbie
*
Karma: 3
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know most moving head lights use steppers. Were your systems only using steppers?

-Joe Dunfee
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah 5wire types, kind of NEMA ones I think, really easy to use and very cheap !
Logged

while (z--) { snore; }

Offline Offline
Full Member
***
Karma: 1
Posts: 182
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a video of the project so far...

http://youtu.be/SBjkxvv0yRw

I have improved this further stil so that the ATTiny outputs differntial DMX rather than having to use a RS485 driver chip

Regards

Logged

while (z--) { snore; }

Pages: [1]   Go Up
Jump to: