Skip to content
The Cosino Mega 2560 DALI implementation
C++ Python Processing Makefile
Branch: master
Clone or download
Luca Zulberti
Luca Zulberti Fix invalid sequence "\n\r"
Signed-off-by: Luca Zulberti <luca.zulberti@cosino.io>
Latest commit 23ca116 Feb 2, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Dali_sketch Add first release of the code Dec 1, 2015
lib/Dali Fix invalid sequence "\n\r" Feb 2, 2016
.gitignore Add first release of the code Dec 1, 2015
LICENSE Initial commit Dec 1, 2015
Makefile.inc Add first release of the code Dec 1, 2015
README.md README.md: wiki markups fixed Dec 1, 2015
SConstruct Add first release of the code Dec 1, 2015
cosino_dali_logo.png
dali.txt Add first release of the code Dec 1, 2015
protocol.txt

README.md

Arduino DALI library for Cosino MEGA 2560

Multi bus DALI master based on a Cosino Mega 2560 board.

This device con control 2 DALI busses.

Prerequisites

To compile the code you need some packages on your Cosino Mega 2560 board and you can use the following command line to install them:

# aptitude install arduino scons make git-core

Then you need the file mega2560.sh to upload your HEX file into the Mega 2560 CPU. It can be downloaded from the URL https://github.com/cosino/cosino.github.io/blob/master/data/extensions/mega_2560/mega2560.sh.

Doing a simple program

An example program can be found in Dali_sketch/Dali_sketch.pde. The code is reported below:

#include <Dali.h>

/*
 * Objects
 */
 
Dali dali0, dali1;

/*
 * Setup
 */
 
void setup()
{
	delay(500);
	Serial.begin(115200);
	
	delay(500);
	Serial.println("DALI testing program - ver. 1.00");
	Serial.println("Cosino Mega 2560 extension");
	Serial.println("Luca Zulberti <luca.zulberti@cosino.io>");
	
	delay(500);
	dali0.begin(18, 10);	/* Overwrite OC1A and OC1B */
	dali1.begin(A14, A15);	/* Overwrite ADCch 14 and 15 */
}

/*
 * Loop
 */

void loop()
{
	serialDali();
}

As a normal Arduino projects, you can compile and load the sketch into the Mega 2560 CPU with few commands.

From the Cosino Mega 2560 console enter into the main folder and then use the commands below:

# cd Dali_sketch
# make
scons -f ../SConstruct ARDUINO_BOARD=mega2560 \
            EXTRA_LIB=../lib/ -Q
maximum size for hex file: 258048 bytes
scons: building associated VariantDir targets: build
[ ... ]
avr-size --target=ihex Dali_sketch.hex
text    data     bss     dec     hex filename
   0   13028       0   13028    32e4 Dali_sketch.hex

Then use the mega2560.sh to load the HEX file as follow (I supposed you installed the program under the /opt directory):

# /opt/mega2560.sh prog Dali_sketch.hex
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "Dali_sketch.hex"
avrdude: input file Dali_sketch.hex auto detected as Intel Hex
avrdude: writing flash (13028 bytes):

Writing | ################################################## | 100% 1.73s

avrdude: 13028 bytes of flash written

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Test the simple program

To test the program you can use the screen program (use the usual aptitude command to install it).

screen /dev/ttyS3 115200

In the screen type:

d1000*(CTRL+j)*

This command will turn ON the light at the address 0x00 on bus 0 (see the documentation file protocol.txt).

To turn OFF the device, type:

d0000*(CTRL+j)*

Documentation files

You can’t perform that action at this time.