without communication modbus


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Am I reading your code correctly? You have an interrupt inside an interrupt?

    If so, I do not think that will work?
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    It may be possible the problem is in your crc16 or some other related section. In the code you posted, I do not see any led(did I miss it?)

    This code appears Ok to me.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    I have noticed that if the frame or the values are very large, I lose communication
    Define very large. Your buffer length seems to be 20 bytes so if the frame is longer than that I imagine you'll be in trouble. It shouldn't stop interrupting though.....

    I can't seem to find where you turn on the LED you mentioned.

    /Henrik.

  4. #4
    Join Date
    Jun 2010
    Location
    Venezuela
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Am I reading your code correctly? You have an interrupt inside an interrupt?

    If so, I do not think that will work?
    Hello everyone sorry did not reply earlier.

    hello mackrackit , is enabled every time it happens the serial interrupt. is used to determine if there are no more characters to read and works. original code from modbus.pl

    If (NewFrame = 1) OR (Length = 0) then 'New modbus frame start
    NewFrame = 0
    T2CON.2 = 1 ' Enable Timer2
    Length = 1
    EndIf

    hello Jerson, the crc16 is working, the led is switched off in the Main, is switched on every time PIR1.5 = 1. when the fault occurs, the LED lights (I'm in the interruption) and then turn off.

    hello HenrikOlsson, explain why "Define very large", look:

    while (PIR1.5 = 1) 'Write modbus frame to buffer
    buffer[Length] = RCREG
    Length = Length + 1
    if Length >=20 then ' here check buffer
    Length = 0
    EndIf
    wend
    Last edited by scrwld; - 16th September 2010 at 20:28.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    You said that the problem occured when the frame was large and I was asking HOW large.

    The reason I asked is that your buffer wraps around when Length is 20 you only have space for 21 characters in your buffer.

    You get you characters from RCREG and put them in Buffer[0], Buffer[1], Buffer[2].......Buffer[20]. When Length reaches 20 it wraps around to 0 and you overwrite what's in Buffer[0] and because you said the problem occured when the frame was "very large". So, is it when the frame is larger than 20 bytes?

    /Henrik.

Members who have read this thread : 2

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