Pages: [1]   Go Down
Author Topic: DMX controller code problems  (Read 782 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
greater than 3 arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everybody, I've built the DMX circuit that is described in the tutorial on http://www.arduino.cc/playground/Learning/DMX, using the SN75176B chip and using an old arduino with atmega168.
Now I'm trying to put the code from the tutorial on the arduino, but there are a lot of things going wrong. Probably because the code was written for 0004 or 0005, and I'm using arduino 0010.

couple of things in the code I don't understand and which give compiler errors:
Code:
port_to_output[digital_pin_to_port[pin].port];
Is this some sort of array, or object? Compiler error says it's not declared, which is true, it's not getting declared anywhere.
Code:
digital_pin_to_port[pin].bit;
same here
Code:
_SFR_BYTE(_SFR_IO8(portNumber)) |= _BV(pinNumber);
(...)
_SFR_BYTE(_SFR_IO8(portNumber)) &= ~_BV(pinNumber);
(...)
   _SFR_BYTE(_SFR_IO8(portNumber)) |= _BV(pinNumber);
(...)
 _SFR_BYTE(_SFR_IO8(portNumber)) &= ~_BV(pinNumber);
???. I've made projects with arduino for almost 2 years now, but never ran into these kind of codes. Help, what are they doing here? Where did the come from? Is it machinecode or something else that directly talks to the atmega chip? Is it because I should just not try to mess with the incredible Zen powers of DMX? I'm getting a little scared here.
« Last Edit: December 12, 2007, 09:03:20 am by eelke » Logged

malmö / berlin
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
fhp>--vs--<k3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 hej,

you are right, you are using code which is just working with arduin 004 and 005 (maybe up to 007), the old arduino software releases  are still one the arduino side, ...

but there are some amazing hungarian guys (Peter Szakal and Gabor Papp), who did a example for arduino 008, and maybe it work for 010 as well, (it is a realy nice looking pice of code)

http://www.arduino.cc/playground/uploads/DMX/dmx008fade-070807.zip

good luck
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
greater than 3 arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey tomek,

Thanks for your reply! I tried that code and it compiles correctly on 0010 smiley (ie. it's not giving errors).

Yet its not working with my rgb led par (showtec).

I think this has mainly to do with the fact that I have no idea what the code is doing, except for the perception that there is assembly / machine code involved.

Can anyone please explain the non-arduino non-documented lines of code to me, or tell me where I can find that info?
Logged

malmö / berlin
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
fhp>--vs--<k3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

uff,

a showtec led par, is not the best obejct to test the code,  because  i asspect showtec stuff not to build propperly or i mean i would asspect that they can not handle dmx signal which are not perfectly timed good as other dmx (better) slaves,  (but sorry i will not argument against showtec further more)

anywaym the only part in code which is interessting is void loop
if you know the dmx protocoll it is very easy to follow:


> /***** sending the dmx signal *****/
>
>  // sending the break (the break can be between 88us and 1sec)
> digitalWrite(sig, LOW);
>
>  delay(10);
>
> // sending the start byte
>  shiftDmxOut(sig, 0);
>

>>>>>>>>>all above this line is just the stuff you have send according to the dmx protocoll, break start bit etc
>>>>>>>>>all this stuff above you never have to change change

  
>>>>>>>>>>>>>>>>here comes the interessting part
>>>>>>>>>>>>>>>> here are all the 512 dmx channels
>>>>>>>>>>>>>>>> right now all the 512 channels are just fading up and down

for (int count = 1; count <= 512; count++)
  {
    shiftDmxOut(sig, value);
  }

  value += valueadd;
  if ((value == 0) || (value == 255))
  {
    valueadd *= -1;
  }
}

>>>>>>>>>>>maybe you should have a look at the other code example, you can not upload them but you can check out the void loop and see what we are doing there,


is the salve receiving any singal ?

have fun
tomek
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
greater than 3 arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks smiley After looking into that I still wasn't getting any good results, so I went over to my circuit and looked if all was well connected: No! I incidentally connected the ground of the arduino to the wrong strip on my breadboard (really stupid little mistake), so there was no reference for the dmx >> not working.

When that was fixed, I got it working (HOURAY!) with the fading up and down script in combination with the old 0005 software!. I edited it so it now responds to the serial data coming from maxmsp, giving me a nice rgb colour mixer.

I agree with you on the showtec quality though. Some downsides:
- weird bug: sending a value of 127 on any rgb channel makes all leds flicker in a cray manner. (128 works fine)
- not all leds are perfectly aimed (the red ones have a bigger angle), so not all colours mix well (yellow in particular is really bad: a green center with a red halo). A solution for this would probably be some sort of lens that I can place in front of the par?

Thing is, I really need 6 of these working together for an exhibition, and there is virtually no budget, so I'm bound to these units. (rgb and not producing any heat > perfect)

Besides it all working now, I am still really curious what the _SFR codes mean, and the asm() in the 0008 script (from szakal & papp). Does anyone know?
Logged

malmö / berlin
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
fhp&gt;--vs--&lt;k3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hej,

it would be great if you could add you a  max msp to dmx example to the wiki, this would be great, and it doesn"t take so much time, so just paist a code example for ardunino and max, and maybe a small discription with a photo....
the communicty would thank you.

here is now you own section:

http://www.arduino.cc/playground/DMX/Interface?action=edit

or go to
http://www.arduino.cc/playground/Learning/DMX
and then to the interfacing examples (it is not edit jet)


about the _SFR stuff, this is like the real c code, which we normaly never see becaue it is in all this .h .c files and we just call more easyer funkctions, but in case of the dmx timing we don"t have the time to call a functions which calls other function which calls.......  so thats why we have to use this hard stuff
i"m actually having no idea about c, but you get pretty far with copy pasit and i got a lot of help from david.
if you want to learn more about it, i guess you have to learn c or check out the libarys included in the arduino, there you can find a lot of stuff, a starting point to look for the pins.h( or pin.h or something like this) in the arduino 005 folders.

all the best
tomek
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
greater than 3 arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again smiley
Once I have everything sorted out and written a cleaner code I'll post a zip with Arduino and Max codes, but that isn't going to happen before January the 6th smiley-wink
(thats the date our expo opens: see http://www.zesbaans.nl/sam)

Also, I do have some glitches in the dmx signal, sometimes channels don't send the exact proper code it seems (resulting in wrongly mixed colours). I talked to the salesperson of the musicstore where I got the PAR, and he said he never had problems with it or heard about such a thing (and they sold a lot). I am going to check on a regular dmx-clubtable tonight, to try figure out if there is something I can do about that glitch.. Any ideas?
« Last Edit: December 18, 2007, 11:02:49 am by eelke » Logged

Pages: [1]   Go Up
Jump to: