C# DMX512 code example

 

 

                  using FTD2XX_NET;

 

        byte[] Start = { 0x00 };
        byte[] MAB = new byte[256];
        byte[] dmx_data = new byte[512];

        private void set_data()
        {
            ftStatus = myFtdiDevice.SetDataCharacteristics(FTDI.FT_DATA_BITS.FT_BITS_8,FTDI.FT_STOP_BITS.FT_STOP_BITS_2,
                FTDI.FT_PARITY.FT_PARITY_NONE);

                if(ftStatus == FTDI.FT_STATUS.FT_OK)
                {
                    setdata = "Data Set!";
                }

                else
                {
                    setdata = "Data Error!";
                }
        }



        private void set_baudrate()
        {
            ftStatus = myFtdiDevice.SetBaudRate(250000);
            if (ftStatus == FTDI.FT_STATUS.FT_OK)
            {
                setbaudrate = "Baudrate OK!";
            }

            else
            {
                setbaudrate = "Baudrate Error!";
            }
        }


        void send_data()
        {
            myFtdiDevice.SetBreak(true);
            Thread.Sleep(10);
            myFtdiDevice.SetBreak(false);
            myFtdiDevice.Write(MAB, 0, ref count);
            myFtdiDevice.Write(Start, Start.Length, ref count);
            myFtdiDevice.Write(dmx_data, dmx_data.Length, ref count);
        }

 

 

Read 10118 times