I have recently discovered the amazing arduino platform and have started an artnet dmx node project based on the work of a few others that have gone down this path. Unlike most of the other projects which try to get multiple universes out of one device, I am sticking to a simple single universe artnet to dmx node. I have this device up and running and working great on an Arduino Nano.
Now, what I would like is to add a simple web configuration page to the code so that the ethernet settings can be changed and stored permanently from a web gui into the arduino for recall during future power ups. Not knowing much at all about the programming side, here is the code that I am using and have cleaned up to remove items which are not in use. This compiles fine on IDE 0023. So what needs to be done to add a simple web configuration page??
I found another code that does what I am looking for, but I am not sure the easiest approach to combining the two codes. The ethernetsetup code seems like there is a lot to merge into the original artnet code.....can it be changed into a header or something and referenced from the main code?? Or create a subsection in the main code to keep the pieces together? Both codes reference the ethernet mac, ip, etc....but in different ways.
Hello kjacobs
I have been working on exactly the same thing, although my solution is very much different.
I have a few tips for you
If you want to output only ONE DMX from artnet, I would firstly only check the first 18 bytes of the UDP packet to see if it is "Art-Net" and the right opcode and universe you require
If this matches then read the rest of the packet (512 bytes or whatever) out of the UDP packet, I think I am using udp.read rather than udp.readpacket for this, udp read will just read a certain amount of bytes that is in the packet that has arrived after it has been parsed
By only reading the first 18 bytes and checking you will be able to process your packets faster, also if this does match you can just read the 512 bytes into an array and keep them there until the next packet arrives
I have tried a few DMX out routines using various interrupts and found there were issues, but eventually wrote my own using a simple timer that recreates the DMX stream nicely
secondly, when you using client.println() to print your html or whatever, use it like this client.println(F("hello world!")); - I know you are using strcpy, by my method is really easy and I am sure a lot faster as it does it inline, the "F" creates a 'read from flash', without which an awful lot of ram would be used
I have written a full configuration interface for browser, with either single Universe DMX out, or TWO universes of WS2812 outputs this way
You started where I started
Are you using Wiznet W5100 board or Enc28j60 Ethernet card with your Nano ?
Honestly, most of what you wrote in your post was greek to me. While I can build electronics well, most of the coding info you sent went.....woosh over my head.....LOL.
I saw that you had been working on a nano dmx unit, and yours also had extras for leds, etc. I was going for a simple single universe, bare bones Artnet (or SACN) node for personal use in theater type lighting. Mine uses the WizNet W5100 unit.
The present code was written by someone else, so I can make no comment on its function and speed other than it seems to work fine. But it is missing the web config page for the ethernet I would like to have, which would make it easier to config if using more than one. I also think it is over bloated in that it has tons of extra code trying to squeeze out 2-3 more universes. It seems a single universe would be more efficient.
I think the simplest approach is 1 universe each...and if more is needed, just add more nodes. They are cheap enough to build.....
With a Nano, one DMX universe out as DMX data is all you will get, there is not enough ram to store more than one for output, I know this as I have tried everything to free up enough ram to do this, there 'appears' to be enough ram for two at compile time, but something else will always knobble that last bit, overwrite something and crash your software !
To be able to achieve this efficiently, you would really need to adjust the way the code reads the buffer, at the moment it reads about 530 bytes into a buffer (UDP packet from Ethernet), then copies virtually ALL the buffer to the DMX data array, thus wasting one quarter of the available ram
Sorry if your not following this, I have spent so much time creating speed and data efficient artnet nodes for Nano that I have become quite passionate about it
Sometimes, the answer is not always long winded code-bloaty libraries
Solution :
Only read the first 18 bytes of parsed UDP packet, using udp.read(name,18)
Check 'Art-Net' codes and if it matches the right opcode and universe/net etc then read the 512 byte packet straight from the udp buffer using udp.read(dmxdata,512), use the dmxdata within your interrupt driven dmx outputhandler
Problem 2 :
UART TX vectors knobbled by serial.write
Solution:
Create a timer interrupt to fire every 44us to output data directly to UDR0 (@250kbps generally), but also interleave this with a slower byte send @100kbps to start the packet
I have tested this and I get an uninterrupted stream of DMX data at 40Hz, while receiving single universe ArtNet packets at up to 35Hz
Hello Kjacobs, sorry to bother, but I have been following several posts on how to build an artnet node, I am working on the same library as you, I even downloaded the code that you published above. But I can't transmit dmx, my lighting equipment only blinks, I don't know if the problem is in the dmx shield or if it is a problem with the code. If you could guide me a bit, I would appreciate it. From already thank you very much.
Hi there..... thanks for the email. Unfortunately, I gave up on this project a while back and moved on to a completely different code for arduino to get my artnet node. It does not have the web interface, which would have been really nice, but the code was clean and it works fantastic. Good luck on your project.....
Thank you very much for answering. Luckily I was able to run my node which was what I wanted. Are you working with a totally different code from the one in artnet dmx four universe? Greetings