Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Tecchie

Member Since 02 Dec 2010
Offline Last Active Apr 11 2014 05:27 PM
-----

#10615 Simple DMX Transmitter

Posted by Tecchie on 06 March 2011 - 05:50 PM

Generating DMX data with Netduino is quite simple, as DMX is just (more or less) a serial RS485 protocol. Its properties are 250kbit/s, 8 data bits, no parity bit, 2 stop bits. So you don't have to manually bitbang to generate the DMX data, but one can use one of the netduino UARTs.

Of course you have to convert the ttl serial signal into the differential RS485 form, but there are many ICs out there, which do just that. I'm using the simple SN75176B in my example as i had that one lying around, but depending on which fancy features you want to have (ESD protection, galvanic isolation, ...) you may use another one.

But there's one feature in the DMX protocol which interferes with just using the serial port. That's the >88µs break (setting signal to low) which marks the beginning of a new dmx data frame. On the full blown .NET the SerialPort class has a Break property which can be used to generate the break, but i haven't seen that on the micro SerialPort class.

So i had to do it in another way. I'm generating the break on a seperate pin (D4 in my example) and use an AND-gate to combine the serial output and the break signal. I'm using one of the gates of a 74HCT32 74HCT08 IC.

The code side is quite simple. Just create a SerialPort with the correct properties and the OutputPort for the break signal. For each dmx frame generate the break and then send the data, up to 513 bytes for the start code (0x00 for DMX data) and a full blown DMX universe (512bytes). To get a correct length of the break, i'm just calling Write two times on the OutputPort which results in a ~110µs break on my Netduino Plus.

    public class Program
    {
        // data for a whole universe including start code (which must be zero for DMX data)
        private static byte[] data = new byte[513];

        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            // init test bytes
            for (int i = 0; i < data.Length; i++)
            {
                // first byte (=start code) must be zero for DMX data
                data[i] = (byte)i;
            }

            OutputPort pBreak = new OutputPort(Pins.GPIO_PIN_D4, true);
            SerialPort sp = new SerialPort(SerialPorts.COM2, 250000, Parity.None, 8, StopBits.Two);
            sp.Open();

            while (true)
            {
                led.Write(true);
                // create the break (2x Write(false) to get a break length of >88µs)
                pBreak.Write(false);
                pBreak.Write(false);
                pBreak.Write(true);
                // rely on .net lazyness for 8µS Mark-after-Break
                sp.Write(data, 0, data.Length);
                led.Write(false);

                Thread.Sleep(40);
            }
        }

    }

In the specification of DMX there's a 8µs Mark-after-Break between the break and the serial data in which the signal should be high. I'm not explicitly generating that as the Write-Call on the serial port already takes much longer to start sending the data.

Disclaimer: i've only tested it with my really old DMX tester, not with any actual lighting fixture. But it should work with those :)

[edit: corrected small error in fritzing diagram]
[edit2: corrected IC name, sorry for the confusion]

Attached Files




#9882 i2C netduino won't work!

Posted by Tecchie on 20 February 2011 - 08:51 AM

Having a quick look at klotz's code, it seems that having to shift the address 0x50 one bit to the right may be the culprit.

   I2CConfig = new I2CDevice.Configuration(0x50 >> 1, 100);



#6971 Pinout Cards

Posted by Tecchie on 04 January 2011 - 10:33 AM

I really like the pinout card that came with the mbed. As i haven't found anything similiar for the Netduinos, i created them myself. The diagrams are quite large in the PDFs, please scale them to your needs when printing. If someone spots an error please post it so i can correct the diagrams. Tecchie

Attached Files




#6079 Unstable USB connector

Posted by Tecchie on 14 December 2010 - 12:36 PM

Anyway I've just noticed that the usb connector is very unstable. If I lift the wire from the table (or touch it in an upward direction really) the board will disconnect. (Power failure)


Got my Plus yesterday and had the same problem. Solved it by squeezing the metal shield of the usb connector on the netduino a bit, so that the plug fits tightly.
Of course you have to be cautious when doing that.

Tecchie


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.