PDA

View Full Version : Simple 4 channel DMX controller



eggman
- 8th February 2008, 22:59
'simple 4 channel DMX controller
'reads 4 potmeters to control 4 lights
'08-02-08 Kees Reedijk
@ DEVICE PIC16F88, MCLR_OFF, HS_OSC, WDT_ON, LVP_OFF, PWRT_ON
DEFINE OSC 20 ' 20MHZ crystal
DEFINE ADC_BITS 8 ' Set number of bits
DEFINE ADC_CLOCK 3 ' Set clock source
DEFINE ADC_SAMPLEUS 50 ' Set sampling time
DEFINE HSER_SPBRG 4 ' 250 KBaud

DEFINE HSER_CLROERR 1 ' Clear overflow automatically

RCSTA=%01010000 '9 bit data,usart disabled
TXSTA=%01100101 'Enable transmit, BRGH=1, 9 bit data

PORTA= %00000000
TRISA= %00001111
PORTB= %00100000
TRISB= %00000100
ANSEL= %00001111
CMCON= %00000111

DMX VAR PORTB.5 'DMX output to SN75176 bus driver
level1 VAR BYTE
level2 VAR BYTE
level3 VAR BYTE
level4 VAR BYTE

CLEAR

loop:
ADCIN 0,level1 'read level potmeters
ADCIN 1,level2
ADCIN 2,level3
ADCIN 3,level4
LOW DMX
PAUSEUS 100
HIGH DMX
PAUSEUS 12
RCSTA.7=1 'usart enabled
HSEROUT [0,level1,level2,level3,level4]
PAUSE 10
RCSTA.7=0 'usart disabled

GOTO loop

END

bcd
- 10th February 2008, 01:56
Very nice.

One thing to be aware of is the DMX spec says there must be a minimum of 24 channels in a DMX message, so some cheaper devices might not be able to receive the dmx channels correctly.

One option is to send out 20 '0's at the end of the HSEROUT statement.

bill

skimask
- 10th February 2008, 02:18
Very nice.
bill

So, if I understand your comment correctly, this simple implementation really works (aside from the 24 channel minimum that you mentioned) ?

I don't know how DMX works, don't know the actual protocol, never used it, never had a need to use it (can't be too crazy hard as long as a guy reads the protocol documentation thoroughly).
BUT, every once in awhile, about once or twice a year, usually before Christmas, a few new folks log on here, and make a big to-do out of this, that, and the other thing, and can't get a DMX controller to work.
I guess I'm just wondering what the big deal was...after all, if code above works, well, jeeze, that's not so tough...

Darrel Taylor
- 10th February 2008, 04:25
I guess I'm just wondering what the big deal was...
This is the Transmit end of the DMX system.

The "big deal" comes on the Receiving end.
It's struggling to PWM some large number of channels at the same time it's receiving the DMX data at 250Kbaud.

Seems to be a favorite "First Time" project. :rolleyes:


eggman,

Short, sweet, and to the point.
Very nice indeed. http://www.picbasic.co.uk/forum/images/icons/icon14.gif

skimask
- 10th February 2008, 04:34
This is the Transmit end of the DMX system.
The "big deal" comes on the Receiving end.
It's struggling to Dim some large number of channels at the same time it's receiving the DMX data at 250Kbaud.
Seems to be a favorite "First Time" project. :rolleyes:

I suppose it would be a struggle, for the noob, trying to keep the RCREG from overflowing, while performing other tasks.
At any rate, I'm bookmarking it. It may 'only' be the TX end, but reverse engineering some useful RX code doesn't look too difficult.

charudatt
- 1st May 2011, 18:45
This thread code looks goofed up any chances of including a txt file for the benefit of others.

Thanks.

mackrackit
- 1st May 2011, 18:58
Check it now.

charudatt
- 1st May 2011, 19:02
Thanks DAVE.

aratti
- 7th May 2011, 11:20
The vertical scroll bar is missing in the code area! So I can see only the few initial Lines of the code.

From what i understand reading the various Posts, it seems I am the only one with this problem.

Al.

mackrackit
- 7th May 2011, 11:48
Is anyone else missing the scroll bars? I can see them.

Ioannis
- 7th May 2011, 12:24
I see them fine.

maybe is your browser Al. Try some other, Opera for instance. I test it and seems a little faster that IE9.

Ioannis

aratti
- 7th May 2011, 13:16
maybe is your browser Al. Try some other, Opera for instance. I test it and seems a little faster that IE9.

Ok thanks. Problem seems to be with ipad browser, I can see it with firefox.

Al.

cncmachineguy
- 7th May 2011, 14:59
Hi Al. assuming your iPad is like my iPhone, have you tried to "2 finger scroll" in the code window? On my phone I get no bars, but I can scroll the code windows using 2 fingers.

aratti
- 7th May 2011, 19:41
Tank you Bert for the tip. 2 finger scroll in the code window works fine.

Cheers

Al.

ELZEMEFE
- 31st January 2012, 22:51
_ Is this software works the same way hserin ?

ScaleRobotics
- 1st February 2012, 02:31
The DMX protocol uses 250k baud RS-485. There are some start pulses and such that need to happen. That what the HIGH/LOW DMX and pauses are doing. Here's an app note from Microchip that explains a bit more about it http://ww1.microchip.com/downloads/en/AppNotes/01076A.pdf

wagnerandreotti
- 25th April 2012, 22:39
What is language? Basic?, C?, mikrobasic? Please help-me! thanks

ScaleRobotics
- 25th April 2012, 23:05
Depends which one you are talking about. The first post example is in PicBasic (check out www.melabs.com for software). The application note example for AN1076 is in assembly: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en527825

wagnerandreotti
- 26th April 2012, 03:36
thanks!!!!

comwarrior
- 18th July 2012, 02:40
personally... i hate the DMX protocol... but i'm sure their is a reason for it...

running at 250K baud is going to be fun for anyone new...

I recommend double buffering the data and using interrupts both for the USART and the ADC... ;)