DMX on 250000 baud receive


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    Like most things there is more than one way to accomplish a task. Last year I saw the post from JEC about DMX. While it was nice to hear that DMX was possible with PICBasic I really wanted something that was interrupt based.

    After doing some research I found that all you need to do is look for a framing error, after which should be the start code (there may be several framing errors in a row). Over the last few days I have created the interrupt code snip below. While I haven't tested it exhaustively it seems to work.

    Code:
    DimmerCount	VAR WORD  ; Location in DMX string
    DMXStartAddr	VAR WORD  ; DMX start address
    DMXStartCode	VAR BYTE  ; DMX Start code (Dimmer=0)
    Dummy		VAR BYTE
    DMX_State	VAR BYTE  ; Stage of DMX reception     
    
    Valid_Break     CON 1
    Valid_SC        CON 2
    Valid_Data     CON 3
    
    Disable
    
    INTERRUPT_SUB:
    	IF OERR Then 						
    		CREN = 0
    		CREN = 1    			; Clear Overrun Errors
    		High Err_LED			; Notify user of overrun error
    		DMX_State=0
    		EndIF
    
    	IF FERR Then
            	FERR = 0
    		DMX_State=Valid_Break
    	Else
    		GoSub RX_DMX_Data							
         	EndIF
         	
        	Dummy=RCREG				; Empty UART of junk data
    	Resume	
    
    RX_DMX_Data: 
    	IF DMX_State=Valid_Break Then
    		HSerin 20,NoData,[DMXStartCode]	; Start code of 0 = dimmer data
    		
    		IF DMXStartCode=0 Then 
    			DMX_State=Valid_SC
    		Else
    			High Err_LED		; Notify user of Error in Start Code
    			DMX_State=0 
    			EndIF
    		EndIF
    		
    	IF DMX_State=Valid_SC Then
    		For DimmerCount=0 TO DMXStartAddr; Count incoming data bytes (frames) 
    			Dummy=RCREG		; Read unwanted values
    			Next DimmerCount
    		DMX_State=Valid_Data
    		EndIF
    		
    	IF DMX_State=Valid_Data Then
    		HSerin 20,NoData,[STR DataBuffer\Number_Of_Channels]
    		DMX_State=0
    		EndIF
    		
    	IF DMX_State=0 Then
    		Resume
    		EndIF
    	
    GoTo RX_DMX_Data
    	
    NoData:
    	DMX_State=0
    	Resume
    		
    Enable
    End
    Last edited by DynamoBen; - 8th March 2007 at 06:17.

  2. #2
    Join Date
    Nov 2004
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    Very elegant. Nice job, DynamoBen.

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


    Did you find this post helpful? Yes | No

    Default

    Well, I can see some potential problems with that program.

    So be ready for some more questions from programmer07, oops, I mean syscoder.
    <br>
    DT

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Assuming it's a snip and a ISR... first observation, something like a L?CALL have to be change but it's a first & fast observation.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    Its a first draft and I offer it up as-is so I make not warranties. I'm open to suggestions or improvements.

    BTW the question did seem familar.
    Last edited by DynamoBen; - 8th March 2007 at 06:18.

  6. #6
    Join Date
    Mar 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default thanks

    dear dynamoben thanks for your answer i will try it, is there anybody here that tryed it and working?
    and how can i use it for 16f628 and 20 mhz osc and i will use only 3 led to dimmer them imean 3 chanel ?
    Last edited by syscoder; - 14th March 2007 at 23:09.

  7. #7
    Join Date
    Mar 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default dmx

    ok friends thank you for helping i will try to make it and will see if it is working then i will post code here cause i see there is many people here need help to receive dmx signal like me
    i understand pulsin is for the break signal and hserin is to receive dmx

Similar Threads

  1. DMX receive issue
    By NoahLD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th August 2014, 14:51
  2. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 21:58
  3. Big Problem in PBP To receive DMX
    By programmer07 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2007, 19:49
  4. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 03:17
  5. Baud Rate and Timing Calculator
    By picnaut in forum General
    Replies: 3
    Last Post: - 23rd January 2004, 17:48

Members who have read this thread : 0

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