Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:46 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : micromite and DMX512

Author Message
cheeseprader
Newbie

Joined: 06/10/2016
Location: United States
Posts: 7
Posted: 02:29pm 06 Oct 2016
Copy link to clipboard 
Print this post

As this is my first post, I have to say that the MicroMite is an incredible piece of kit. I am amazed at the power that Geoff Graham and Silicon Chip magazine has put out there at a very reasonable "cost".

Over the years, I have been a big fan of arduino and the amount of libraries available for this product. As I keep tabs on this forum, I have become VERY fond of the PIC32 and MMbasic and the ease that I can put something together quite rapidly.

I am currently trying to put something together using the "micromite", either the original one or the "plus" one. I am trying to make a user friendly DMX512 type of controller to control a wide array of lighting products that are readily available from places like amazon and ebay.

So basically I am wondering if there is a library available for doing DMX with the micromite or micromite plus, that can address DMX lighting systems? I have had limited success with the arduino to do this, but going back to my roots, I am more comfortable with "basic" than C or C++.

I thank you in advance for any and all information that may be available.

Rob
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 02:41pm 06 Oct 2016
Copy link to clipboard 
Print this post

Hi Cheeseprader, and welcome.

I will assume that you have a working micromite based on your post. I have spent some time playing with DMX512 using other micros. I was able to get a "simulated" DMX protocol working with the micromite. I will dig up my code when I get home and post. From what I remember, it only took two pins, but can't remember right now. I will get back to this when I get home. My buddy and I used this to run some Christmas lights last year.

 
cheeseprader
Newbie

Joined: 06/10/2016
Location: United States
Posts: 7
Posted: 02:51pm 06 Oct 2016
Copy link to clipboard 
Print this post

Thanks viscomjim. I didn't know if DMX control was possible or if there is a standard library available for that. Do you know if this can work using web based control or using Wifi?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10209
Posted: 09:08pm 06 Oct 2016
Copy link to clipboard 
Print this post

I wrote this routine in response to another TBS member who wanted to talk to a DMX device. The routine allows you to send any type of timed bitstream. Using this with a couple of wrapper routines in Basic it should be easy to drive DMX devices
 
VK2MCT
Senior Member

Joined: 30/03/2012
Location: Australia
Posts: 120
Posted: 09:29pm 06 Oct 2016
Copy link to clipboard 
Print this post

I looked at DMX at one stage and the high data rate was a problem. Might be poss now with chip hardware UART & C ?
250 kbit/s required.Edited by VK2MCT 2016-10-08
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10209
Posted: 09:34pm 06 Oct 2016
Copy link to clipboard 
Print this post

  Quote  Might be poss now with chip hardware UART & C ?


You can't use the UART for DMX as it uses variable timings. The routine I reference above will easily meet the DMX timings it is just a question of writing some Basic to package up the bit sequences into DMX commands
 
belsean21

Newbie

Joined: 06/07/2013
Location: Australia
Posts: 12
Posted: 02:34am 07 Oct 2016
Copy link to clipboard 
Print this post

I had wondered if DMX was possible on the Micromite.
Thanks matherp, that routine will be quite useful.

Do you think it be possible to to receive a DMX stream on a Micromite?

Sean.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 02:36am 07 Oct 2016
Copy link to clipboard 
Print this post

Cheeseprader, I was able to find some code, but I know I have some more useful routines somewhere. I am in Florida and there is a hurricane on the east coast. I live on the west coast so I find myself with a few people that evacuated to my house last night and getting to the computer was not possible. I'll try again tonight. But in the meanwhile...

'
DIM DMXVal(24)
DIM Cn, Cp, x
DIM Red, Grn, Blu

SETPIN 23, DOUT 'pin 23 used to provide 100us break pulse
PIN(23) = 1

open "COM1:250000, 256, S2" as #1 ' DMX uses 250K baud and 2 stop bits

ClrAll 'clear all DMX array values

'a quick test to send each channel Red, Green and Blue values
do
for x = 1 to 8
SendCnRGB x, 255, 0, 0
pause 200
SendCnRGB x, 0, 0, 0
SendCnRGB x, 0, 255, 0
pause 200
SendCnRGB x, 0, 0, 0
SendCnRGB x, 0, 0, 255
pause 200
SendCnRGB x, 0, 0, 0
next x
loop


---------------------- SEND CHANNEL RGB ----------------------
sub SendCnRGB (Cn, Red, Grn, Blu)
Cp = (Cn * 3) - 2
DMXVal(Cp) = Red
DMXVal(Cp + 1) = Grn
DMXVal(Cp + 2) = Blu
TransDMX
end sub

'---------------------- SEND ALL RGB ----------------------
sub SendAll (Red, Grn, Blu)
for Cn = 1 to 8
Cp = (Cn * 3) - 2
DMXVal(Cp) = Red
DMXVal(Cp + 1) = Grn
DMXVal(Cp + 2) = Blu
next Cn
TransDMX
end sub

'---------------------- CLEAR ALL DMX ----------------------
sub ClrAll
for Cn = 1 to 24
DMXval(Cn) = 0
next Cn
TransDMX
end sub


'---------------------- TRANSMIT DMX ----------------------
sub TransDMX
PULSE 23, .1 ' Create 100uS break signal

PRINT #1, CHR$(0); 'STARTCODE (always 0)
for CHAN = 1 to 24
PRINT #1, CHR$(DMXVAL(CHAN)); 'Channel 1-24 values
next CHAN
'for CHAN = 1 to 10 'Some boards seem to need extra DMX data
'PRINT #1, CHR$(0);
'next CHAN
end sub


My set up was this... I used an AND gate with Com1 Tx and Pin 23 as inputs and the output went to a 3.3v version of the 75176 (I can't look up the part number but will later tonight). The differential outputs of that went to a 24 channel DMX decoder like THIS one. You can have a pretty long cable run here. Each set of 3 channels went to an RGB led strip, so basically you get 8 RGB channels. You might also be able to create an AND gate with 2 diodes and a pullup, so you don't have to have an extra 14 pin chip. This board has address switches, so you can string more than one together and set the switches for the next 24 channels, etc.

The TransDMX sub uses pin 23 to create the first break signal required to start the DMX process. At first I tried to turn off the com port, set the com1 TX pin to an output, pulse it, turn the pin off, turn on the com port, etc. but this proved to be a bit too slow, hence the pin 23 pulse. Once the 100us pulse is done, you have to send a 0 to indicate the start code, then just go ahead and transmit up to 511 8 bit values with 2 stop bits. As you can see, I am only sending 24 values for my project. Due to the interpreter (I'm guessing), this timing isn't perfect, but good enough and works well. You can send more values based on your setup.

The particular decoder I am using has a feature that once you send a value to a channel, it keeps that value even if you don't continuously send a DMX stream, which in my case was a great feature. I believe that some DMX decoders require a constant stream of DMX info to keep the ball rolling, but not this one.

As you can see, I basically (pun intended) load values ranging from 0 to 255 into an array (DMXVal(xx)) and send that every time the array is manipulated. Like I said earlier, I have some more routines, so I'll post them later. Some are pretty cool effects. If I can get to my lab (where my east coasters are currently residing) I will try and post some video of the effects we used.

 
cheeseprader
Newbie

Joined: 06/10/2016
Location: United States
Posts: 7
Posted: 03:22am 07 Oct 2016
Copy link to clipboard 
Print this post

Thanks viscomjim, can you give me a bit more information on the AND chip and what it is doing exactly? I am not very advanced in the hardware area so forgive my ignorance. Your code looks pretty simple so I will give that a try. I have a 3 channel DMX decoder I can try it with and will hook up an RGB led. I also want to try and use some relays as outputs. Do you have any ideas for using relays instead of leds? What would you send as a command to control a relay that is just off or on? Thank you for your help. I hope you don't get blown away in the storm.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 04:17am 07 Oct 2016
Copy link to clipboard 
Print this post

Take a look at the DMX timing shown HERE . You can see that the "break" signal is used to start the entire DMX stream. If you want to use the Com1 TX line to create the break, you have to set the pin to an output, pulse the pin low for 100uS, turn the pin off, open the com port to transmit the rest of the stream, close the com port, set the pin as an output, pulse, etc. This switching back and forth takes too much time. I looked at it using a logic analyzer with a DMX protocol setup and that action took too long to stay true to the required DMX protocol. So I decided to just hook up a simple and gate and use another I/O pin to create just the 100uS break pulse and then keep the com port open all the time. Once I send the pulse, I right away send the serial stream after it. This keeps things simple and quick. I have done this before using a compiler and a pic and it worked fast enough using just the tx line, but the uMite uses a basic interpreter and takes a bit too long to make the switch.

As far a relays are concerned, you can simply hook up a 12 volt relay to any (or all) channel of your 3 channel DMX decoder. When you send a 0 to a channel, there is no pwm coming out of the decoder, when you send a 255 you will have full power (12 volts) coming out of that channel, turning the relay on. The only thing I recommend is that you put a diode across the relay coils to prevent damage caused by back emf. Other than that, you are all set. On the board I am using from ebay, you could hook up 24 individual relays and control all of them with only two pins of the uMite. Theoretically, you could control over 500 of them with the same two pins. From the DMX timing protocol, you could update over 500 channels at a refresh rate of over 40 times a second. I will hook up my logic analyzer and send all 512 channels using the uMite method and see how long it actually takes.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 02:32pm 07 Oct 2016
Copy link to clipboard 
Print this post

Cheeseprader, the differential driver I used was the Maxim 3485 which is a very similar part to the 75176 driver but can run on 3.3v like the uMite. The AND gate I used was the 4081which also works at 3.3 volts. Again, I think you can get rid of this and use 2 diodes and a pull up like THIS

I got your PM. Check your email.
 
cheeseprader
Newbie

Joined: 06/10/2016
Location: United States
Posts: 7
Posted: 03:01pm 07 Oct 2016
Copy link to clipboard 
Print this post

@viscomjim,

Just tried your code. Thank you. It works nicely. The 76176 seems to be working at 3.3 volts so not a problem there. The part you mentioned is on order right now. Will be a few days before I get it.
I ran your code and removed the delays. Seems like the micromite is pretty quick. Without the delays, the leds appear white due to how fast they are updating, but with the delays, the leds are definitely changing from red to green to blue. This is great. I got your email but am having a difficulty with some of it. I get an error when calling one of the subroutines (rainbow one). I will email you when I get a chance. I am having more luck with this than I had with the arduino DMX library and it is starting to make sense. Thanks again.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 03:33pm 07 Oct 2016
Copy link to clipboard 
Print this post

I messed up and forgot to dimension some variables. So try this code. It works on my setup. Please let me know how you make out...



Option Explicit

DIM DMXVal(24)
DIM Cn, Cp
DIM Red, Grn, Blu
DIM x, Rclr, Rchn, xx, chan, z

randomize timer

SETPIN 23, DOUT
PIN(23) = 1

open "COM1:250000, 256, S2" as #1 ' DMX uses 250K baud and 2 stop bits

ClrAll 'clear all DMX array values

'some random tests

'send each channel Red, Green and Blue values
for x = 1 to 8
SendCnRGB x, 255, 0, 0
pause 100
SendCnRGB x, 0, 0, 0
SendCnRGB x, 0, 255, 0
pause 100
SendCnRGB x, 0, 0, 0
SendCnRGB x, 0, 0, 255
pause 100
SendCnRGB x, 0, 0, 0
next x

DO
'send all channels random colors from color wheel
for x = 1 to 50
Rclr = Int(RND() * 255) + 1 'pick a number between 1 and 255
Wheel Rclr
SendAll Red, Grn, Blu
pause 100
next x

'send random channel random color from color wheel
for x = 1 to 50
Rclr = Int(RND() * 255) + 1 'pick a number between 1 and 255
Rchn = Int(RND() * 8) + 1 'pick a number between 1 and 8
Wheel Rclr
SendCnRGB Rchn, Red, Grn, Blu
'pause 10
next x

'cycle all channels rainbow colors
for x = 1 to 255 'color wheel colors
for z = 1 to 8 'channel number
Wheel ((z + x) and 255)
SendAll Red, Grn, Blu
next z
next x


'cycle rainbow over 8 channels
for x = 1 to 255
for z = 1 to 8
Wheel (((z * 256 / 8) + x) and 255)
SendCnRGB z, Red, Grn, Blu
next z
next x

LOOp



'---------------------- COLOR WHEEL ----------------------
sub Wheel(WheelPos)
if WheelPos < 85 then
Red = WheelPos * 3
Grn = 255 - WheelPos * 3
Blu = 0
exit sub
end if

if WheelPos < 170 then
WheelPos = WheelPos - 85
Red = 255 - WheelPos * 3
Grn = 0
Blu = WheelPos * 3
exit sub
end if

WheelPos = WheelPos - 170
Red = 0
Grn = WheelPos * 3
Blu = 255 - WheelPos * 3
end sub

'---------------------- SEND CHANNEL RGB ----------------------
sub SendCnRGB(Cn, Red, Grn, Blu)
Cp = (Cn * 3) - 2
DMXVal(Cp) = Red
DMXVal(Cp + 1) = Grn
DMXVal(Cp + 2) = Blu
TransDMX
end sub

'---------------------- SEND ALL RGB ----------------------
sub SendAll(Red, Grn, Blu)
for Cn = 1 to 8
Cp = (Cn * 3) - 2
DMXVal(Cp) = Red
DMXVal(Cp + 1) = Grn
DMXVal(Cp + 2) = Blu
next Cn
TransDMX
end sub

'---------------------- CLEAR ALL DMX ----------------------
sub ClrAll
for Xx = 1 to 24
DMXval(Xx) = 0
next Xx
TransDMX
end sub


'---------------------- TRANSMIT DMX ----------------------
sub TransDMX
PULSE 23, .1 ' Create 100uS break signal

PRINT #1, CHR$(0); 'STARTCODE (always 0)
for CHAN = 1 to 24
PRINT #1, CHR$(DMXVAL(CHAN)); 'Channel 1-24 values
next CHAN
'for CHAN = 1 to 10 'Some boards seem to need extra DMX data
'PRINT #1, CHR$(0);
'next CHAN
end sub



 
cheeseprader
Newbie

Joined: 06/10/2016
Location: United States
Posts: 7
Posted: 04:56am 08 Oct 2016
Copy link to clipboard 
Print this post

Jim, I just got this DMX decoder from amazon and some RGB modules and a decent 12 volt power supply. Your code is working now and the rainbow show is very cool. I think my dmx decoder is the same as yours but with a case. Now I can get crazy with the Christmas lights. Perfect timing. I also hooked up my 3 channel unit with 3 12 volt relays and address starting at 25, 26, and 27 daisychained to the dmx out from the 75176. This is also working. Fun begins... now!

Did you test the timing for sending out 512 bytes from the micromite? I'm curious how many times you can send the whole thing per second. Thanks for your help.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:28am 08 Oct 2016
Copy link to clipboard 
Print this post

Hi Rob, that decoder is nice. It has both a dmx in and dmx out, so you don't have to connect both your decoders to the 75176. Just connect the output of the 75176 to the 24 channel dmx in and the 3 channel unit to the dmx out of the 24 channel unit. This is how dmx works, you can just daisy chain things together from one unit to the next. I'm glad code is working for you. I have other code for different effects that I will post or send you. I am just getting rid of my hurricane evacuees and have a day of babysitting my sisters kids, so I will try and get to this while they "nap" ha ha. I won't be able to test the full 512 string until maybe tonight when I might be able to set everything back up. Been kind of out of the loop for a bit due to other obligations, so hang in there and do some of your own experimenting now that you are making progress.

Don't get me started about Christmas lights. Be warned, that can get out of control...
 
JTR0701
Regular Member

Joined: 10/07/2013
Location: Australia
Posts: 71
Posted: 12:13pm 08 Oct 2016
Copy link to clipboard 
Print this post

Just a heads-up. DMX can be done straight from the UART. No bit-banging, extra I/O or AND gate required. To generate the break simply change the baud rate to ~100K baud and send a 0b00000000 data byte. This effectively creates a 90us "break" to anything that is listening at 250k baud.

Try it and see how it goes.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 04:04pm 11 Oct 2016
Copy link to clipboard 
Print this post

I have been having a great time playing with the DMX using the micromite chip. A buddy of mine has a similar addiction as far as Christmas lights are concerned. He and I have used the LOR system in the past to create Christmas lighting displays for fun but have always had to use a laptop or other dedicated computer to do things with the DMX lights using a USB to DMX interface. Using the micromite to do simple things as far as sequences, etc. I can do things without a computer just to do simple things but anticipate more complex things later. Over time, my buddy came across quite a few "commercial" spot lights that were DMX controlled but he could never get them to work, which is good for me as I got all of them for free due to his frustration. After finding some Chinese information, I found that these lights used 8 dmx addresses instead of 3. They had a cryptic digital display on the back of them to set them into several different modes of operation. Once I figured out how to just make them DMX "slaves", I was on my way. So five addresses were used for built in functions and the other 3 were used for the actual RGB info. Address 1 was used for dimmer info, 0 - 255, address 2, 3 and 4 for RGB info and addresses 5 - 8 for built in functions which he could never figure out how to use, even with a common DMX console. By modifying the TransDMX subroutine from before, I was able to adjust the serial data and actually use these lights. (Of course, now he wants them back, won't happen LOL).

Here is the modifications I used to make them work. Keep in mind that since the fixtures used 8 addresses each, the first one started at 1, the second one at 9, etc. sending out 64 bytes instead of 24 for 8 fixtures was necessary. Hopefully this will be useful for someone...

P.S. I have yet to try and create the break signal by changing the baud rate like JTR0701 suggested, but this is on the to do list. Using the extra IO pin 23 is working so far but it would be cool not to have to use 2 pins. But since it is working so far, I haven't tried it yet.



'---------------------- TRANSMIT DMX ----------------------
sub TransDMX
PULSE 23, .1 ' Create 100uS break signal

PRINT #1, CHR$(0); 'STARTCODE (always 0)
for CHAN = 1 to 8
CHANSEND = (CHAN * 3) - 2
PRINT #1, CHR$(255); 'dimming value full on
PRINT #1, CHR$(DMXVAL(CHANSEND)); 'Red Value
PRINT #1, CHR$(DMXVAL(CHANSEND + 1)); 'Green Value
PRINT #1, CHR$(DMXVAL(CHANSEND + 2)); 'Blue Value
PRINT #1, CHR$(0); 'Turn off unknown function
PRINT #1, CHR$(0); 'Turn off unknown function
PRINT #1, CHR$(0); 'Turn off unknown function
PRINT #1, CHR$(0); 'Turn off unknown function
next CHAN
end sub



Give this a try if you have a light that needs more than 3 bytes to make work. Next project is a DMX controlled light that has x and y motion using DMX...



Edited by viscomjim 2016-10-13
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025