DmxSerial - port to Spark Core

Hi Guys,

for some reason I would like to integrate a Spark Core intoo a DMX light controller. Currently I use a case with integrated power supply so all you need is to plug in power and DMX. As we use another DMX controller for simple light effects, I also need to switch the DMX line to the light controller.

With a Spark Core it should be possible to receive DMX signals (using DmxSerial) and send them as ArtNet-UDP-Packets over WiFi. As soon as the Spark Core device is online I can implement a rule that switches the DMX line to the ArtNet-Receiver (with data from Spark Core).

I don’t assume that generating valid ArtNet packets should be that complicated. My problem right now is that I don’t succeed to implement the DmxSerial library, which sounds to be the most simple solution, to the Spark Core firmware.

To port the DmxSerial to Spark Core I need to set all the registers for the USART-Serial interface, but I don’t have an idea how to get all these:

// These definitions are used on ATmega8 boards
#define UCSRnA UCSRA  // Control and Status Register A
#define TXCn   TXC    // Transmit buffer clear
#define UCSRnB UCSRB  // USART Control and Status Register B
#define RXCIEn RXCIE  // Enable Receive Complete Interrupt
#define TXCIEn TXCIE  // Enable Transmission Complete Interrupt
#define UDRIEn UDRIE  // Enable Data Register Empty Interrupt
#define RXENn  RXEN   // Enable Receiving
#define TXENn  TXEN   // Enable Sending
#define UCSRnC UCSRC  // Control and Status Register C
#define USBSn  USBS   // Stop bit select 0=1bit, 1=2bits
#define UCSZn0 UCSZ0  // Character size 00=5, 01=6, 10=7, 11=8 bits
#define UPMn0  UPM0   // Parity setting 00=N, 10=E, 11=O
#define UBRRnH UBRRH  // USART Baud Rate Register High
#define UBRRnL UBRRL  // USART Baud Rate Register Low
#define UDRn   UDR    // USART Data Register
#define UDREn  UDRE   // USART Data Ready
#define FEn    FE     // Frame Error
#define USARTn_RX_vect   USART_RXC_vect  // Interrupt Data received
#define USARTn_TX_vect   USART_TXC_vect  // Interrupt Data sent
#define USARTn_UDRE_vect USART_UDRE_vect // Interrupt Data Register empty

Any idea how I can get this library working?

kind regards

edit: updated code formatting

@joky you are connecting the core to the DMX using Serial (tx/rx)?

If so, you have to worry about the serial settings on the core side as it has been initialized in the libraries

Ah sorry bout that. We need to get DMXsimple ported somehow. I see that they are using Timer to implement this so porting is going to take more changes.

Let me see what I can do :slight_smile:

@joky So i looked at the DMXSerial code and it requires ISR and Timer which aren’t really exposed to Users at this point in time on the :spark: core.

Beyond my knowledge to get this ported over at this point in time!

@mohit could you shed some light and see how feasible it is to get this going?

@joky one workaround i can think of at this point in time is to have an Arduino interfaced to be the DMX controller and the Core will talk to the Arduino through I2C communications. I know it doesn’t cool this way but that’s a temporary tryout you can consider :slight_smile:

1 Like

2 Likes

@timb does this mean that you are going to work on it? :smiley:

Woo! Y’all gonna make me port this library, up in here, up in here! Y’all gonna me code all out, up in here, up in here!

(Off the chain, :spark: leave Arduinos soft in the brain! All my RuffCoders meet me outside! timb gotcha bouncin’ again, bouncin’ again, bouncin’ again!)

2 Likes

Hi guys,
any progress on porting the code??

regards

It seems like there’s a DMX port for Maple:

However at a quick glance I think it uses the Maple abstraction layer, which we don’t use (we use ST’s standard peripheral library).

But then there’s also this:

https://code.google.com/p/stm32-dmx512/w/list

I don’t think anything’s gonna work out of the box, but at least there are some starting points…

1 Like

I’m working on a DMX shield. I’ll update when I have something.

Currently not planning to isolate the DMX, because I can power the core off floating wall-warts.

I could be persuaded to change my mind and use an isolated RS-485 interface, but I do not think I need to.

4 Likes

Ah so awesome! Many stuff happening in the background :smiley:

Maybe @timb can tell us his progress since he has a DMX shield and can help with the library pirting

I moved a post to a new topic: Spark Core DMX Shield

Hi guys,
any news rgd. porting the dmx-library?

All the bests

I’d love a port of DMXSerial too… Have code working with a Leonardo and an RS485 shield, but the port looks nontrivial for sure.

@djMax, if you can post your code or refer me to a library, I can take a look at porting it :smile:

1 Like

@djMax, that IS a doozy of a library since it is so hardware dependent. A port would require rewriting the USART serial port code to handle the different baud and stop bit configurations, as well as, managing the receive and transmit interrupts. Yuck! :frowning:

Reading/generating the break that signals the start of frame is another fairly unique issue - I’ve used framing errors for that in the past, but that’s not really the way you’re “supposed” to do it.

DMX512 isn’t that complicated, but it can get a little messy.

I have no plans to port any existing arduino library or hook things into the cloud, I’ll probably be looking at a task-specific firmware load, but this project has not made it back to the top of my TODO pile yet, sorry.

@AndyW Any luck porting the library? Will the Photon make things any easier for DMX control? Hoping to control some BlinkyTiles with the Spark and FastLED, but this has been the blocker.

Remember, I’m not porting the library.

My plans are to create a different firmware load that runs on bare metal and doesn’t do setup()/loop()/cloud stuff.

Hi @AndyW,

I did a lot with DMX and Arduinos. I managed to implement a cross fade version of the well known Arduino lib. It worked good with 128 channels. and at the same time the Arduino run a web interface.
I think that a good DMX implementation needs a multiprocessor approach. Imagine a Spark with a little shield that holds 2 atmega’s each running a universe. The spark sends them the changes in DMX settings via SPI.
With this approach we can build a powerful Wireless DMX controller that can be controlled from many sources.