Simple 4 channel DMX controller


Closed Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45

    Default Simple 4 channel DMX controller

    Code:
    '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
    
    
    
    
    
    
    Last edited by mackrackit; - 1st May 2011 at 17:57. Reason: fix HTML

  2. #2
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bcd View Post
    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...

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    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.


    eggman,

    Short, sweet, and to the point.
    Very nice indeed.
    DT

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    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.
    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.

  6. #6
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    This thread code looks goofed up any chances of including a txt file for the benefit of others.

    Thanks.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    Check it now.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    Thanks DAVE.

  9. #9
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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.
    All progress began with an idea

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    Is anyone else missing the scroll bars? I can see them.
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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

  12. #12
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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.
    All progress began with an idea

  13. #13
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  14. #14
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    Tank you Bert for the tip. 2 finger scroll in the code window works fine.

    Cheers

    Al.
    All progress began with an idea

  15. #15
    Join Date
    Jan 2012
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    _Isthissoftwareworks the same wayhserin ?

  16. #16
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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/e...tes/01076A.pdf
    http://www.scalerobotics.com

  17. #17


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    What is language? Basic?, C?, mikrobasic? Please help-me! thanks

  18. #18
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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/id...pnote=en527825
    http://www.scalerobotics.com

  19. #19


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    thanks!!!!

  20. #20


    Did you find this post helpful? Yes | No

    Default Re: Simple 4 channel DMX controller

    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...

Similar Threads

  1. DMX receive issue
    By NoahLD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th August 2014, 13:51
  2. 4 Channel Thermostat using PID loops
    By malc-c in forum Code Examples
    Replies: 36
    Last Post: - 18th March 2013, 10:17
  3. 4 pin 4 x 4 keypad interface using pic basic pro
    By dunlao_john in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th January 2009, 05:21
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Simple 4 line LCD display with 18F4550
    By pic-ker in forum Code Examples
    Replies: 4
    Last Post: - 9th April 2007, 02:58

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts