DMX512 Problem ..Schema+Code


Results 1 to 22 of 22

Threaded View

  1. #1
    Join Date
    Feb 2007
    Posts
    12

    Default DMX512 Problem ..Schema+Code

    i want to make code for dmx512 protocol i have 9 dipsw on my project and 3 led i want to make 512 adres with the dips. and i will make pwm control for my 3 leds as a seperate it means dmx512 control with 3 chanel i have schema and code but not working can you help me please?


    ' 512 Kanal DMX SLAVE

    '******************** INCLUDE FILES **********************

    INCLUDE "modedefs.bas"

    '************************************************* ************
    '******************** REGISTER **********************
    DEFINE OSC 4
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_RCSTA 90h
    'DEFINE HSER_SPBRG 129
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1


    CMCON = 7 ' Disable analog comparator


    '************************************************* ************


    '******************** DEĞİŞKENLER **********************
    DipAdrr VAR WORD ' 512 Veya 1024 Adresle İçin WORD
    DipAdr_L VAR DipAdrr.Byte0 ' 512 Veya 1024 Adresle İçin
    DipAdr_H VAR DipAdrr.byte1 ' 512 Veya 1024 Adresle İçin

    DmxAdrr VAR WORD
    DmxAdr_L VAR DmxAdrr.Byte0
    DmxAdr_H VAR DmxAdrr.Byte1



    IntData VAR BYTE[4] ' Kesme Data Dizisi
    DmxData VAR BYTE ' Networkten Gelen Data
    DmxChanel VAR BYTE ' DMX Kanal
    DmxCom VAR BYTE ' Dmx Komut

    Addr VAR BYTE ' Genel Sayac
    KesmeSayac VAR BYTE ' Kesme Sayac




    '************************************************* ************



    '******************** ATAMALAR **********************
    Led_G VAR PORTB.0 ' Green Led
    Led_R VAR PORTB.3 ' Red Led
    Led_B VAR PORTB.7 ' Blue Led

    DipAdr0 VAR PORTA.0 ' Dip Swicht 0
    DipAdr1 VAR PORTA.1 ' Dip Swicht 1
    DipAdr2 VAR PORTA.2 ' Dip Swicht 2
    DipAdr3 VAR PORTA.3 ' Dip Swicht 3
    DipAdr4 VAR PORTA.4 ' Dip Swicht 4
    DipAdr5 VAR PORTB.4 ' Dip Swicht 5
    DipAdr6 VAR PORTB.5 ' Dip Swicht 6
    DipAdr7 VAR PORTB.6 ' Dip Swicht 7
    DipAdr8 VAR PORTA.5 ' Dip Swicht 8


    GIE VAR INTCON.7 ' Global İnterrupt Enable Bit
    PEIE VAR INTCON.6 ' Çevresel İnterrupt Enable Bit
    T0IE VAR INTCON.5 ' Timer0 İnterrupt Enable Bit
    INTE VAR INTCON.4 ' PORTB İnterrupt Enable Bit
    RBIE VAR INTCON.3 ' Up PORTB İnterrupt Enable Bit
    T0IF VAR INTCON.2 ' Timer0 Flag Bit
    INTF VAR INTCON.1 ' PORTB.0 Flag Bit
    RBIF VAR INTCON.0 ' PORTB Flag Bit


    RCIF VAR PIR1.5 ' Receiver Enable Bit
    TXIF VAR PIR1.4 ' Transmit Enable Bit

    SYNC VAR TXSTA.4 ' Usart Mode Select Bit 1=Senkron, 0= Asenkron

    SPEN VAR RCSTA.7 ' Serial Port Enable Bit
    RX9 VAR RCSTA.6 ' 9 Bit Receive Enable Bit
    SREN VAR RCSTA.5 ' Single Receive Enable Bit
    CREN VAR RCSTA.4 ' Continuous Receive Enable Bit
    ADEN VAR RCSTA.3 ' Address Detect Enable Bit
    FERR VAR RCSTA.2 ' Frame Error Bit
    OERR VAR RCSTA.1 ' Overrun Error Bit
    RX9D VAR RCSTA.0 ' 9 Bit Of Receive Bit


    '************************************************* ************


    '******************** PORT YONLERI **********************

    TRISA.0=1 ' IN
    TRISA.1=1 ' IN
    TRISA.2=1 ' IN
    TRISA.3=1 ' IN
    TRISA.4=1 ' IN
    TRISA.5=1 ' IN


    TRISB.0=0 ' OUT
    TRISB.3=0 ' OUT
    TRISB.4=1 ' IN
    TRISB.5=1 ' IN
    TRISB.6=1 ' IN
    TRISB.7=0 ' OUT


    Addr = 0
    KesmeSayac = 0



    PIE1.5 =1 ' Enable USART receive interrupt
    INTCON.6 =1 ' Enable peripheral interrupt

    ON INTERRUPT GoTo DmxKesme


    Main : GoSub DipOku

    DmxAdr_L = IntData[0]
    DmxAdr_H = IntData[1]
    DmxCom = IntData[2]
    DmxChanel = IntData[3]


    IF DmxAdrr = DipAdrr Then

    IF DmxCom = "1" Then

    IF DmxChanel = "1" Then
    High Led_G
    EndIF

    IF DmxChanel = "2" Then
    High Led_G
    EndIF

    IF DmxChanel = "3" Then
    High Led_G
    EndIF

    EndIF


    IF DmxCom = "0" Then

    IF DmxChanel = "1" Then
    Low Led_G
    EndIF

    IF DmxChanel = "2" Then
    Low Led_G
    EndIF

    IF DmxChanel = "3" Then
    Low Led_G
    EndIF

    EndIF

    EndIF



    GoTo Main



    '************************************************* ************
    '******************** ADRES OKU **********************
    '************************************************* ************
    DipOku : DipAdrr.0 = DipAdr0
    DipAdrr.1 = DipAdr1
    DipAdrr.2 = DipAdr2
    DipAdrr.3 = DipAdr3
    DipAdrr.4 = DipAdr4
    DipAdrr.5 = DipAdr5
    DipAdrr.6 = DipAdr6
    DipAdrr.7 = DipAdr7
    DipAdrr.8 = DipAdr8
    DipAdrr.9 = 0
    DipAdrr.10 = 0
    DipAdrr.11 = 0
    DipAdrr.12 = 0
    DipAdrr.13 = 0
    DipAdrr.14 = 0
    DipAdrr.15 = 0



    Return
    '************************************************* ************



    '************************************************* ************
    '******************** KESME **********************
    '************************************************* ************
    Disable INTERRUPT

    DmxKesme : DmxData = RCREG

    IntData[Addr] = DmxData

    IF Addr = 4 Then
    Addr = 0
    Else
    Addr = Addr + 1
    EndIF

    RCSTA=$90

    Resume

    Enable INTERRUPT
    '************************************************* ************





    End
    Attached Images Attached Images  

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  2. 16f887 44 pin demo board code problem?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th December 2008, 14:17
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. 4 Chanel Dmx512 ready assembly code to PBP ?
    By syscoder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st March 2007, 23:55
  5. Code problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th May 2006, 04:43

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