DMX on 250000 baud receive


Results 1 to 17 of 17

Threaded View

  1. #1
    Join Date
    Mar 2007
    Posts
    16

    Default DMX on 250000 baud receive

    Dear friends i have found a example in the forum.

    i want to receive dmx512 signal from the tranmitter. i have an lightingdesk for dmx512 ch control. and i will build and device to receive it

    i have pic 16f628 and 20 mhz osc i use mcs 2.3 and pbp2.47 for programming. i searched in the forum and saw many examples thanks for help . is this true to receive for ; İ HAVE PIC16F628 and it will be dimming 1 led

    Which command we have to use here "Pulsin" or " Hserin" ? u use here pulsin


    INCLUDE "modedefs.bas"

    DEFINE OSC 20 ' osc for pic 16f628
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_SPBRG 4
    DEFINE HSER_BAUD 250000
    DEFINE HSER_CLROERR 1
    ASM
    ERRORLEVEL -306, -302
    ENDASM

    CMCON = 7

    ' Variables diverves

    counter VAR word ' Variable de travail WORD
    idleflag VAR WORD
    dummy VAR WORD
    RCIF VAR byte
    startcode VAR WORD
    aminus VAR WORD
    adresse_grada VAR WORD
    x VAR WORD
    newlevel1 VAR WORD
    newlevel1 = RCREG 'This is your target channel data

    adresse_grada = 20 ' my adress for exemple 20

    'This next routine is called on a gosub from my main housekeeping loop:

    checkdmx:

    counter = 1 'just a dummy variable
    pulsin portB.1,0,counter 'here I'm looking for the break signal

    if counter = 0 then
    idleflag = 1 'either no dmx, or break was too long to count
    'return
    endif


    if counter < 40 then checkdmx 'watching for 'break
    'if you get here, an active low pulse was detected, but it was too short.
    'probably just part of the datastream. So go back and look again.

    'otherwise, a valid break was found and it's time to read the start code

    dummy = RCREG 'clear out any garbage which may be in the USART
    dummy = RCREG
    SPBRG = 0
    TXSTA.2 = 0 'brgh = 0
    TXSTA.4 = 0
    RCSTA.7 = 1
    RCSTA.6 = 0 'setting 8 bit receive mode, no parity, etc
    RCSTA.4 = 0 'check the datasheet to see what all these bits do
    RCSTA.4 = 1 'now, the USART is on and ready to receive

    while RCIF = 0:wend 'hover here after break, before start code

    startcode = RCREG 'This is the first byte received after the break

    if startcode <> 0 then checkdmx 'do your own stuff here on a non-zero code

    aminus = adresse_grada - 1 'address1 is my target address

    for x = 1 to aminus 'set up a loop to count almost to the address
    while RCIF = 0:WEND 'sit here until a byte is received
    dummy = RCREG 'stash the byte somewhere unimportant
    next x

    newlevel1 = RCREG 'This is your target channel data
    portA.2 = newlevel1 'i want dimming a LED on PORTA.2
    RCSTA.7 = 0 'turn off the USART

    goto checkdmx
    return
    Last edited by syscoder; - 5th March 2007 at 13:32. Reason: edit

Similar Threads

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