How to assign Modbus ASCII address into a chip ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to assign Modbus ASCII address into a chip ?

1,303 Views
joonsinchu
Contributor II

Dear all,

 

does anyone has the experience on assigning Modbus address into a chip ? i been trying to send out the Modbus ASCII frame for MOXA gateway to recognize it from my chip. Unfortunately, moxa gatway unable to recognize it. 

 

154409_154409.pngpastedImage_0.png

 

i did send out the frame ":F7031389000A60<CR><LF>" , in order to communicate between my chip and the gateway. but, it shows illegal packet.

 

154410_154410.pngpastedImage_25.png

 

Anyone has any experience or some sharing on this ? i do need your help.

 

Thank you. Hope to hear from you soon.

Labels (1)
Tags (3)
0 Kudos
Reply
4 Replies

1,158 Views
scottm
Senior Contributor II

Hi,

It looks like this is the message you're sending:

:1103006B00037E

That would be station 17, function 3, data 0, 107, 0, 3.  The checksum looks OK to me, but I have no idea how your gateway is set up.  What is the MCU connected to?  It would be best to see the raw output of the MCU's serial port so you can see if the problem lies there or in your gateway setup.

Also, keep in mind that arrays in C are zero-indexed.  If you declared ch[] as ch[17] then that last byte isn't going to be within the array.  You should start with ch[0] unless there's a good reason not to.  For simplicity you could define ch[] as:

char ch[] = ":1103006B00037E\r\n";

And since you're using Processor Expert for your serial interface, depending on your buffer setup and what mode you're using AS1 in, you should probably be checking the result of the SendChar call.  I use something like this:

// Send character to serial port

void sci_outc(unsigned char c)

{

  while (AS1_SendChar(c) == ERR_TXFULL) {};

}

I would also recommend using the PE functions (like AS1_TurnTxOn()) rather than accessing the SCI registers directly since you're already using PE.

What kind of RS-485 transceiver are you using?  I used an ADM483 in my project and had a couple of I/O pins assigned to control the transceiver's receiver enable and driver enable pins as it switched between TX and RX mode.  I think some of the MCUs at least can automatically control an external transceiver, but you'll need to make sure that part is set up properly.

Scott

0 Kudos
Reply

1,158 Views
scottm
Senior Contributor II

Ok, that's Modbus ASCII and not Modbus-RTU, but it should be easier to debug.  What's the full text of that error message?  Looks like maybe the start character is invalid.

How about capturing the raw data using a terminal program on that RS-485 port?  That will at least let you check that the baud rate and everything is correct.

If you're using that sample frame, make sure you're sending the actual CR/LF (0x0d, 0x0a) values and not a literal <CR><LF>.  If you could post the code that's sending the frame that might help too.

Scott

0 Kudos
Reply

1,158 Views
joonsinchu
Contributor II

Hi Scott,

Thanks for the reply.

Here is what i got:

1st test on ASCII.PNG2nd test on ascii.PNG

here is my code for sending out the signals, but it seems like the gateway doesn't getting any response from the chip.

ascii1.PNGascii2.PNG

I am looking forward to your advice.

thank you. Hope to hear from you soon.

Chu

0 Kudos
Reply

1,158 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

HI.

now the GUI Traffic monitor shows the error message of your modbus frame data.

who is the GUI producer?  I myself never use this tool, but from my experience, if you have the tool source project, you need check the GUI code with debugger why it produces the error?

if don't have the GUI source code, you need check the GUI help manual for this error massage.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply