PIC24fj256GA406 RS-485 Based Modbus RTU
Moderator: Benj
-
- Posts: 164
- Joined: Fri Jan 13, 2012 4:21 am
- Location: South KOREA
- Has thanked: 18 times
- Been thanked: 16 times
PIC24fj256GA406 RS-485 Based Modbus RTU
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]
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 265 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 164
- Joined: Fri Jan 13, 2012 4:21 am
- Location: South KOREA
- Has thanked: 18 times
- Been thanked: 16 times
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
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.
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 259 times
-
- Posts: 52
- Joined: Fri Apr 07, 2017 1:55 am
- Location: Greece
- Has thanked: 16 times
- Been thanked: 14 times
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
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
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
-
- Posts: 164
- Joined: Fri Jan 13, 2012 4:21 am
- Location: South KOREA
- Has thanked: 18 times
- Been thanked: 16 times
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
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.
Thanks for the advice.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 164
- Joined: Fri Jan 13, 2012 4:21 am
- Location: South KOREA
- Has thanked: 18 times
- Been thanked: 16 times
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
I changed the MCU to PIC18F47Q10 and tested it.
However, the result is not good.
When I used MAX485 and tested it in RS-232 TTL mode, the data is not perfect due to timing problems, but it works well.
However, MODBUS RS-485 mode does not work.
PIC18F47Q10 has UARTINT0, but UARTINT1 is not visible.
Sorry for just asking questions every time.
Please help me.
I upload my program.
However, the result is not good.
When I used MAX485 and tested it in RS-232 TTL mode, the data is not perfect due to timing problems, but it works well.
However, MODBUS RS-485 mode does not work.
PIC18F47Q10 has UARTINT0, but UARTINT1 is not visible.
Sorry for just asking questions every time.
Please help me.
I upload my program.
- Attachments
-
- MAX485_Serial_TTL_Test.fcfx
- (14.45 KiB) Downloaded 239 times
-
- MAX485_ModTest.fcfx
- (15.26 KiB) Downloaded 244 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
Hello,
Thanks for letting us know regarding the Q10 device missing it's channel 2 interrupts, these have now been added for you.
Let us know if you spot anything further using RS485, can you share your hardware setup with a simple schematic just to make sure everything here is ok?
Thanks for letting us know regarding the Q10 device missing it's channel 2 interrupts, these have now been added for you.
Let us know if you spot anything further using RS485, can you share your hardware setup with a simple schematic just to make sure everything here is ok?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 52
- Joined: Fri Apr 07, 2017 1:55 am
- Location: Greece
- Has thanked: 16 times
- Been thanked: 14 times
Re: PIC24fj256GA406 RS-485 Based Modbus RTU
Hi,
In your schematic you are using a max13487 transceiver.
This chip has a build in state machine for auto direction control.
You do not need to use the DIR pin from your microcontroller.
Just connect the the RE and SHDN pins according to max13487 datasheet and use RS232 ttl method instead RS485 in your flowchart.
George
In your schematic you are using a max13487 transceiver.
This chip has a build in state machine for auto direction control.
You do not need to use the DIR pin from your microcontroller.
Just connect the the RE and SHDN pins according to max13487 datasheet and use RS232 ttl method instead RS485 in your flowchart.
George