DMX receive issue


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Default DMX receive issue

    I consider myself a newbie with PIC programming but have been using dmx devices for years. It's now time to try and build my own. I have done a few projects with microcontrollers but most of my projects have been stand alone PWM and ADC projects.
    I've got my USITT /ESTA DMX info book and code that sort of works.
    I'm just trying to receive the data and look at it on my serial display. For now, I'm just trying to receive channel one. I'll graduate up to counters and dip switches later.
    When I receive the data, the numbers come in correct until I get to 3%, then it hangs up but recovers at 5%. Then it hangs up from 14% on up to 19. There are other places that it hangs up all the way up to 100.
    I have tested my controller (A Swisson DMX tester) and looked at it on my scope.
    It gets weirder. When I take channel two up to 4% (not 1,2,or 3, just 4 and some other numbers above that) the code works perfectly for channel one.
    Timing issue?
    Missing break detection?
    Thanks for your help...........
    Here's my code:

    It's on a 16F876A


    Code:
     '****************************************************************
    '*  Name    : DMX21LCD.BAS                                      *
    '*  Author  : Noah Davis                                        *
    '*  Notice  : Copyright (c) 2009                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 7/28/2009                                         *
    '*  Version : 21.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    init:
    
        DEFINE OSC 20
        Include "modedefs.bas"
    
    
        DEFINE CHAR_PACING 1000 
        define HSER_TXSTA 24H 
        DEFINE HSER_BAUD 250000
        DEFINE HSER_CLROERR 1
        TXSTA.2 = 1 'brgh = 0  1= high speed   
        SPBRG = 4  
      
        Symbol DmxIn = PORTC.7
        Symbol TestLed = PORTA.0
        
        counter var byte
        BreakDet var word
        dummy var word
        startcode var byte
        newlevel1 var byte
        ADCON1 =%00000111           'Turns the A/D converters to digital 
        
    main:
        
        
        pulsin DmxIn,0,BreakDet     'measure the break
        if breakdet < 40 then main  'if break is less than 80uS then try again
        dummy = RCREG
        dummy = RCREG
        RCSTA.7 = 1  'sets SPEN
        RCSTA.4 = 0 'Clear CREN
        RCSTA.4 = 1 'Sets CREN
        while PIR1.5 = 0 'wait for USART receive flag   
        wend
        startcode = RCREG 'that lovely 0 start code
        while PIR1.5 = 0    'wait for channel one
        wend
        newlevel1 = RCREG   ' my data
        RCSTA.7 = 0         'shut off the USART
        RCSTA.4 = 0 'Clear CREN
        Gosub SendCommand   
        goto main
        
        SendCommand:
        serout PORTC.6,T9600,[$FE,$01] ' clear the screen
        Serout PORTC.6,T9600,[#newlevel1] 'send data to screen
        return
    Last edited by NoahLD; - 29th July 2009 at 03:16. Reason: Forgot something

  2. #2
    Join Date
    Jul 2009
    Posts
    2


    Did you find this post helpful? Yes | No

    Default I figured it out....

    I should start by saying thanks to folks like JEC for posting their code snippets to help get me started.
    When I changed the BreakDet variable to byte sized, everything worked fine. I don't know why it worked but I do know that the proper break length would not need to be measured with a ruler that goes up to 65535.
    I assumed you use the largest variable that will get the job done but I was wrong.
    Perhaps someone can explain how to properly select the variable size.
    Thanks folks.

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


    Did you find this post helpful? Yes | No

    Default

    If you use DEFINE, you need to use HSERIN/HSEROUT unless, there's no big chance that your USART will be configured properly. However, with DMX, you want to stay away of HSERIN... so you'll need to manually configure the USART registerS manually. RCSTA, SPBRG, TXSTA.

    Next thing... there's several method to detect the DMX break and the start code.. pulsin MAY work.. but usually detecting a framing error is more valuable. There's a few Appnote on Microchip website about that. The one I remember of is AN1076.
    Steve

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

  4. #4
    Join Date
    Nov 2004
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    If you use DEFINE, you need to use HSERIN/HSEROUT unless, there's no big chance that your USART will be configured properly. However, with DMX, you want to stay away of HSERIN... so you'll need to manually configure the USART registerS manually. RCSTA, SPBRG, TXSTA.

    Next thing... there's several method to detect the DMX break and the start code.. pulsin MAY work.. but usually detecting a framing error is more valuable. There's a few Appnote on Microchip website about that. The one I remember of is AN1076.
    Agreed on all counts. HSERIN won't work very well for what you're trying to do.

    Many ways to skin this particular cat, and PBP's access to the processor's registers makes this easy.

  5. #5
    Join Date
    Aug 2014
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: DMX receive issue

    Hello, I am doing a project for a light which is used to dim/ brightness of LEDs controlled from a DMX 512 protocol .we r desidn our DMX receiver controller.for a single zone software works ok.but for multiple zone i don't know how to address dimmer

  6. #6
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: DMX receive issue

    Why not start a new thread with all your info instead of reviving a very old one?

    Please don't post in multiple places the same question.

    It's also very helpful for you to tell us what version of PBP you're using, post as much of your code as possible and a schematic. There are very smart people here who'll help but their not clairvoyant. At least I don't think they are.

Similar Threads

  1. Simple 4 channel DMX controller
    By eggman in forum Code Examples
    Replies: 19
    Last Post: - 18th July 2012, 01:40
  2. Dmx
    By electronicsuk in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th November 2008, 07:56
  3. DMX on 250000 baud receive
    By syscoder in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 19th November 2007, 09:50
  4. Big Problem in PBP To receive DMX
    By programmer07 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2007, 18:49
  5. 18F1320 ... Strange Memory
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 9th April 2006, 09:55

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