USART+PWM Problem


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by alex-x View Post
    :-) thanks

    i have made many projects with pic but dmx is not like "led open or close"
    it is different

    i wait answer only who knows about the dmx and who can help me to solve this problem and if you want i pay too
    It's not a matter of money...but if that's the way you want to go...so be it...
    Do you know what a good software developer charges for those services these days? It's not cheap for a good, reliable, bug-free product...
    (quite frankly neither do I...I've been paid for services before, but nothing with a contract, just a 'gentleman's agreement)
    Looks like this is one that gets fed the corn and never learns to farm...
    Last edited by skimask; - 16th May 2007 at 14:18.

  2. #2
    Join Date
    May 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default dmx

    it is ok friends , thanks for everything
    i decided to buy a small device for me
    Last edited by alex-x; - 16th May 2007 at 19:03. Reason: x

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


    Did you find this post helpful? Yes | No

    Default

    Jec, good find thanks for the info!

  4. #4
    Join Date
    May 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default 512

    @dynamoben

    Can you explain to me this code for 1 chanel?

    it was yours i have found it in the forum

    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

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by alex-x View Post
    DimmerCount VAR WORD ; Location in DMX string
    .................................................. ....
    End
    That is the same code that you put in post #1.

    As I explained before, that is only a code chunk, a small part of a much larger project. And quite frankly, if that code was the whole thing, it is fairly well commented and/or self-explanatory.

    Do you know how DMX works? Do you know the basics of it's protocol?

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


    Did you find this post helpful? Yes | No

    Default

    Skimask is correct. If you have a complete understanding of the DMX protocol the code I posted should make sense. The Microchip application note mentioned above has a document that talks about how to receive DMX. Their explanation and what I'm doing in my code match.

    You have to have a complete understanding of DMX before you can write/understand any of this code. Once you have that its pretty simple, a short cut would be to use Microchips example code in your project. (see ASM command)
    Last edited by DynamoBen; - 17th May 2007 at 18:26.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DynamoBen View Post
    Their explanation and what I'm doing in my code match.
    I got a question for you about this chunk of the code:

    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

    Does it just happen to work because the baud rate is fast enough that the loop almost can't keep up? How do you know that 'Dummy' always gets loaded with valid data (in this case the unwanted values) from RCREG instead of the same thing that was there last time around in the loop before the next byte actually arrives.
    I would figure that the code would at least poll the RCIF flag and THEN get a new byte from RCREG.
    Just curious...have no need to know, not building any projects anytime soon...(and this all ties back into my post #4 about the bugs...but you probably already figured that out...)

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  2. byte Tx w/ USART 16f876a problem
    By GargamelDigi in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th July 2008, 05:50
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  5. PWM problem CCP2 port
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th September 2006, 23:34

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