PIC24fj256GA406 RS-485 Based Modbus RTU

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
seokgi
Posts: 148
Joined: Fri Jan 13, 2012 4:21 am
Contact:

PIC24fj256GA406 RS-485 Based Modbus RTU

Post by seokgi »

Hi!
I am working on a project using PIC24fj256GA406.
MODBUS Slave mode does not work.
I checked RX and TX using RS-232 port and RS-485 converter.
I upload my program.
Please review.
Thank you.[/b]
Attachments
SUN_Main_Test.fcfx
(29.77 KiB) Downloaded 6 times

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC24fj256GA406 RS-485 Based Modbus RTU

Post by Benj »

Hello,

Have you confirmed your hardware is setup and running at the correct frequency with a 1 second flasher test. You will need to do this to ensure your UART baud rates are correct.

https://www.matrixtsl.com/wiki/index.ph ... ED_flasher

The values you have assigned to the holding registers are too large for the registers, the valid range is 0 to 65535.

seokgi
Posts: 148
Joined: Fri Jan 13, 2012 4:21 am
Contact:

Re: PIC24fj256GA406 RS-485 Based Modbus RTU

Post by seokgi »

It was recognized by RS-232 communication. 1ms 1s timer works well.

seokgi
Posts: 148
Joined: Fri Jan 13, 2012 4:21 am
Contact:

Re: PIC24fj256GA406 RS-485 Based Modbus RTU

Post by seokgi »

I have used several methods, but it doesn't work.
Replaced in anticipation of a defective chip. And I changed Read DDR from Low to Hihg. The received signal comes in as a result. However, it is not received from the communication program (Modbus Poll). If set serial TTL instead of Modbus mode, transmit Direction Pin in High state and receive it with RS-485 converter in Low state, it works well. For what reason? Please help me

Thank you.
Attachments
SUN_Main_RS485_Test.fcfx
(38.66 KiB) Downloaded 4 times

TaliG
Posts: 49
Joined: Fri Apr 07, 2017 1:55 am
Location: Greece
Contact:

Re: PIC24fj256GA406 RS-485 Based Modbus RTU

Post by TaliG »

Hi!

Can you explain what you are trying to accomplish please?
eg, I would like to read something from my hardware and see it on modbus poll.

Can you also confirm the following please?

1. Modbus poll is the master and PIC24 hardware is the slave.

2. Connection from your PC is a usb to rs485 dongle to an rs485 to uart converter to PIC24 uart.

If not, explain how you connect your PC to your hardware.

eg. PC to rs232 cable to rs232-ttl converter to PIC24, or any other way.

George

seokgi
Posts: 148
Joined: Fri Jan 13, 2012 4:21 am
Contact:

Re: PIC24fj256GA406 RS-485 Based Modbus RTU

Post by seokgi »

Thanks for your interest. Sometimes I make mistakes without my knowledge. But I've been working in industrial automatic control for 30 years. Therefore, I am well aware of what I told you.
Thanks for the advice.

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC24fj256GA406 RS-485 Based Modbus RTU

Post by Benj »

Hello,

Maybe worth increasing the reply delay to ensure the transmit state has time to ripple through to the master?

In your Modbus_Slave_2 macro each write is to the same holding register 0.

Post Reply