Arduino DMX Examples not working?
i'm trying power 4 dmx channels arduino diecimila. keep getting error in code saying:
error: port_to_output not declared in scope
this example code arduino website:
now i've modified code in order function properly. per directions given in topic:
http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1205193597/0#9
the modified code come in next post!
error: port_to_output not declared in scope
this example code arduino website:
code: [select]
/* dmx shift out arduino - 004 , 005
* -------------
*
* shifts data in dmx format out dmx enabled devices
* extremely restrictive in terms of timing. therefore
* program stop interrupts when sending data
*
* elektronic foundation dmx rs 485, have use
* max-485 or 75176.
*
* wirring sending dmx max-485
1 - ro - receiver output --- set ground 100 ohm resistor
2 - re - receiver output enable -- set ground
3 - de - driver output enable -- set 5v
4 - di - driver input -- input arduino
5 - gnd - ground connection -- set ground -- refence dmx singal --- (dmx pin 1)
6 - - driver output / receiver input -- dmx signal (hot)------------------ (dmx pin 3)
7 - b - driver output / receiver input -- dmx signal inversion ( cold)------ (dmx pin 2)
8 - vcc - positive supply -- 4,75v < vcc < 5,25v
* every dmx packet contains 512 bytes of information (for 512 channels).
* start of each packet market start byte (shiftdmxout(sig,0);),
* should send 512 bytes if don*t use 512 channels.
* time between every dmx packet market break
* between 88us , 1s ( digitalwrite(sig, low); delay(10);)
*
* (cleft) 2006 tomek ness , d. cuartielles
* k3 - school of arts , communication
* fhp - university of applied sciences
* <http://www.arduino.cc>
* <http://www.mah.se/k3>
* <http://www.design.fh-potsdam.de>
*
* @date: 2006-09-30
* @idea: tomek ness
* @code: d. cuartielles , tomek ness
* @acknowledgements: johny lowgren dmx devices
*
*/
int sig = 11;
int count = 0;
int swing = 0;
int updown = 0;
/* sends dmx byte out on pin. assumes 16 mhz clock.
* disables interrupts, disrupt millis() function if used
* frequently. */
void shiftdmxout(int pin, int thebyte)
{
int wastetime = 0;
int thedelay = 1;
int count = 0;
int portnumber = port_to_output[digital_pin_to_port[pin].port];
int pinnumber = digital_pin_to_port[pin].bit;
// first thing write te pin high
// mark between bytes. may also
// high before
_sfr_byte(_sfr_io8(portnumber)) |= _bv(pinnumber);
delaymicroseconds(10);
// disable interrupts, otherwise timer 0 overflow interrupt that
// tracks milliseconds make delay longer want.
cli();
// dmx starts start-bit must zero
_sfr_byte(_sfr_io8(portnumber)) &= ~_bv(pinnumber);
//we need delay of 4us (then 1 bit transfert)
// @ arduino delay 1us precise every thing between 2 , 12 jsut luke
// excatly 4us have delay 1us 4 times
delaymicroseconds(thedelay);
delaymicroseconds(thedelay);
delaymicroseconds(thedelay);
delaymicroseconds(thedelay);
(count = 0; count < 8; count++) {
if (thebyte & 01) {
_sfr_byte(_sfr_io8(portnumber)) |= _bv(pinnumber);
}
else {
_sfr_byte(_sfr_io8(portnumber)) &= ~_bv(pinnumber);
}
delaymicroseconds(thedelay);
delaymicroseconds(thedelay);
delaymicroseconds(thedelay);
// write every bit 4 microseconds, have waste time here.
//thats why doing loop nothing do, delaymicroseonds not smal enough
for (wastetime =0; wastetime <2; wastetime++) {}
thebyte>>=1;
}
// last thing write pin high
// mark between bytes. (this break have between 8 , 1 sec)
_sfr_byte(_sfr_io8(portnumber)) |= _bv(pinnumber);
// reenable interrupts.
sei();
}
void setup() {
pinmode(sig, output);
digitalwrite(13, high);
}
void loop() {
// sending break (the break can between 88us , 1sec)
digitalwrite(sig, low);
delay(10);
//sending start byte
shiftdmxout(sig,0);
shiftdmxout(sig, 255); //1
shiftdmxout(sig, 0); //2
shiftdmxout(sig, 0); //3
shiftdmxout(sig, 0); //4
shiftdmxout(sig, 0); //5
shiftdmxout(sig, 0); //6
shiftdmxout(sig, 0); //7
shiftdmxout(sig, 255); //8
(count = 1; count<=504; count++){ //the rest
shiftdmxout(sig, 0);
}
}
now i've modified code in order function properly. per directions given in topic:
http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1205193597/0#9
the modified code come in next post!
this modified code.
my dimmer not recognise dmx signal. example in forum-post did work me, did not work multiple channels.
does know i'm missing here? in advance!
code: [select]
/* dmx shift out arduino - 004 , 005
* -------------
*
* shifts data in dmx format out dmx enabled devices
* extremely restrictive in terms of timing. therefore
* program stop interrupts when sending data
*
* elektronic foundation dmx rs 485, have use
* max-485 or 75176.
*
* wirring sending dmx max-485
1 - ro - receiver output --- set ground 100 ohm resistor
2 - re - receiver output enable -- set ground
3 - de - driver output enable -- set 5v
4 - di - driver input -- input arduino
5 - gnd - ground connection -- set ground -- refence dmx singal --- (dmx pin 1)
6 - - driver output / receiver input -- dmx signal (hot)------------------ (dmx pin 3)
7 - b - driver output / receiver input -- dmx signal inversion ( cold)------ (dmx pin 2)
8 - vcc - positive supply -- 4,75v < vcc < 5,25v
* every dmx packet contains 512 bytes of information (for 512 channels).
* start of each packet market start byte (shiftdmxout(sig,0);),
* should send 512 bytes if don*t use 512 channels.
* time between every dmx packet market break
* between 88us , 1s ( digitalwrite(sig, low); delay(10);)
*
* (cleft) 2006 tomek ness , d. cuartielles
* k3 - school of arts , communication
* fhp - university of applied sciences
* <http://www.arduino.cc>
* <http://www.mah.se/k3>
* <http://www.design.fh-potsdam.de>
*
* @date: 2006-09-30
* @idea: tomek ness
* @code: d. cuartielles , tomek ness
* @acknowledgements: johny lowgren dmx devices
*
*/
int sig = 3;
#define ledpin 13
int count = 0;
int swing = 0;
int updown = 0;
#include "pins_arduino.h";
int port_to_output[] = {
not_a_port,
not_a_port,
_sfr_io_addr(portb),
_sfr_io_addr(portc),
_sfr_io_addr(portd)
};
int value = 0;
int valueadd = 3;
/* sends dmx byte out on pin. assumes 16 mhz clock.
* disables interrupts, disrupt millis() function if used
* frequently. */
void shiftdmxout(int pin, int thebyte)
{
int port_to_output[] = {
not_a_port,
not_a_port,
_sfr_io_addr(portb),
_sfr_io_addr(portc),
_sfr_io_addr(portd)
};
int wastetime = 0;
int thedelay = 1;
int count = 0;
int portnumber = port_to_output[digitalpintoport(pin)];
int pinmask = digitalpintobitmask(pin);
int pinnumber = digitalpintobitmask(pin);
// first thing write te pin high
// mark between bytes. may also
// high before
_sfr_byte(_sfr_io8(portnumber)) |= _bv(pinnumber);
delaymicroseconds(10);
// disable interrupts, otherwise timer 0 overflow interrupt that
// tracks milliseconds make delay longer want.
cli();
// dmx starts start-bit must zero
_sfr_byte(_sfr_io8(portnumber)) &= ~_bv(pinnumber);
// need delay of 4us (then 1 bit transferred)
// seems more stable using delaymicroseconds
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");
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");
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");
for (count = 0; count < 8; count++) {
if (thebyte & 01) {
_sfr_byte(_sfr_io8(portnumber)) |= _bv(pinnumber);
}
else {
_sfr_byte(_sfr_io8(portnumber)) &= ~_bv(pinnumber);
}
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");
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");
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");
// write every bit 4 microseconds, have waste time here.
//thats why doing loop nothing do, delaymicroseonds not smal enough
//for (wastetime =0; wastetime <2; wastetime++) {}
thebyte>>=1;
}
// last thing write pin high
// mark between bytes. (this break have between 8 , 1 sec)
_sfr_byte(_sfr_io8(portnumber)) |= _bv(pinnumber);
// reenable interrupts.
sei();
}
void setup() {
serial.begin(300); // initialize serial communications
pinmode(sig, output);
digitalwrite(13, high);
digitalwrite(sig, high);
}
void loop() {
// sending break (the break can between 88us , 1sec)
int i;
for(i=1;i<=4;i++){ // led boot sequence -- blinks 4 times
digitalwrite(ledpin, high);
delay(50);
digitalwrite(ledpin, low);
delay(50);
}
while(1){
/***** sending dmx signal *****/
// sending break (the break can between 88us , 1sec)
digitalwrite(sig, low);
delay(10);
if (serial.available() > 0) {
int value1 = serial.read();
// sending start byte
shiftdmxout(sig, 0);
shiftdmxout(sig, value1); //1
shiftdmxout(sig, value1); //2
shiftdmxout(sig, value1); //3
shiftdmxout(sig, value1); //4
for (count = 1; count<=508; count++){ //the rest
shiftdmxout(sig, value2);
}
}
}
}my dimmer not recognise dmx signal. example in forum-post did work me, did not work multiple channels.
does know i'm missing here? in advance!
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Arduino DMX Examples not working?
arduino
Comments
Post a Comment