rs485 communication


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2007
    Posts
    3

    Default rs485 communication

    Hi i work on dmx receive code and some problem ,i want to receive 1 chanel dmx512 signal but what is my problem on this code ?



    DEFINE OSC 20
    CMCON = %00000111 TRISA = %11111110
    TRISB = %00000010
    OPTION_REG.7 = 1
    T2CON = %00000100

    ' Set receive register to receiver enabled

    RCSTA = %11010000

    ' Set transmit register to transmitter disabled

    TXSTA = %00000110

    ' Set baud rate

    SPBRG = 4


    led1 var portb.4


    Dummy var byte
    Adres con 20
    Break var bit
    Adresteller var word


    Ontvangbyte1 var byte

    PWMLED1 var byte

    pwmled1 = 0

    while 1=1
    if RCSTA.2 = 1 then ' framing error -> break

    dummy = RCREG ' rcsta.2 reset

    break = 1

    portb.8 = 1 zet led 4 aan

    Else

    IF PIR1.5 = 1 then

    if break = 1 then

    break = 0

    dummy = RCREG

    adresteller = 0

    else

    dummy = RCREG

    if adres = adresteller then

    ontvangbyte1 = dummy
    endif

    adresteller = adresteller + 1

    endif

    endif

    endif

    'PWM VOOR 1 LEDje:

    if pwmled1<=ontvangbyte1 then

    led1 = 1

    else

    led1 = 0

    endif

    pwmled1 = pwmled1 + 1

    if pwmled1 = 255 then pwmled1 = 0

    wend

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    CMCON = %00000111 TRISA = %11111110
    error here

    Code:
    while 1=1
    What?

    Code:
    portb.8 = 1 zet led 4 aan
    will never work, well it might, but not the way you'd expect

    Code:
    'PWM VOOR 1 LEDje:
    If that's meant to be a label, won't work...

    Code:
    if pwmled1 = 255 then pwmled1 = 0
    If you've got pwmled1 defined as a byte, no need to reset it, it'll just roll over to zero

Similar Threads

  1. USB / RS485 communication
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th May 2009, 19:36
  2. RS485 serial communication
    By mipie in forum Serial
    Replies: 5
    Last Post: - 10th February 2007, 13:15
  3. PIC to PIC RS485 with users the communication
    By x0914667 in forum Serial
    Replies: 2
    Last Post: - 21st July 2005, 00:20
  4. put an id adress on one pic for rs485 communication
    By ON4XAV in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th June 2005, 12:54
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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