µTasker Forum > MODBUS

Modbus RTU on TWR-K20D72M

<< < (2/4) > >>

mark:
Felix

I just checked on TWR-K20D72M with TWR-SER2 (I don't have a TWR-IND-IO).

1. The default Modbus UART is 1 - so doesn't need any change.
2. The default debug output is 1 so this would conflict - I set this to 0 just to free the Modbus UART.
3. I kept the TWR-SER in RS232 mode to check the connection (that is on the TWR-SER J17 set to pins 1-2 and J19 set to pins 1-2)
4. Using a Modbus master I could communicate via the DSUB connection on the TWR-SER  board - in ASCII mode at 19'200 Baud on slave address 33.

To use RTU one needs to change the settings in modbus_application.c
cMODBUS_default[]
from
(MODBUS_MODE_ASCII | MODBUS_SERIAL_SLAVE | /*MODBUS_SERIAL_GATEWAY | */MODBUS_RS485_POSITIVE),
to
(MODBUS_MODE_RTU | MODBUS_SERIAL_SLAVE | /*MODBUS_SERIAL_GATEWAY | */MODBUS_RS485_POSITIVE),

To change the Baud rate
SERIAL_BAUD_19200,                                               // baud rate of serial interface - serial port 1
can be changed to the one that is desired.

Beware that these settings are stored in Flash and new values are only valid after deleting flash (the parameter system) or by changing the value of MODBUS_PAR_BLOCK_VERSION in case they are saved in flash and taken as valid settings.


When using this interface the tower board should be supplied by USB connection connected to the active elevator board - if supplied by the debug connector the board will switch the UART connection to the VCOM port in the debugger and so the TWR-SER board UART won't work (rx will not be connected).

When using RS485 the RTS signal will need to be connected. The output on PTE3 is driven high (controlled by the setting MODBUS_RS485_POSITIVE) when transmission is in progress but the TWR-K20D72M doesn't connect this line. It also has a non-connected 0R resistor in the path. For some reason, if the 0R resistor is inserted, it connects to PTC3 which is a GPIO and has nothing to do with the UART. However the RS485 on the TWR-SER board is a full-duplex one and I don't think that this signal is needed.
In addition, the RTS is connected to the receiver enabled (normally I expect it to control the transmitter (?)).

In any case I don't find any problem with the operation as long as you use the correct Modbus settings (Baud rate, Slave address and RTU/ASCII mode).

Regards

Mark



Felix:
Hi Mark,

thank you a lot for checking this for me on your board. This is really great support!
But sorry, I still havn´t got it.  :-\
I prefer TWI-IND-IO because it has a half-duplex transceiver on it and I just have a two-wire converter. But I also tried the TWI-SER board. How do you connect the full-duplex board to the master? Do you have a 4-wire-RS485 to USB converter? I did´t find such a device. Do you think it could be okay to connect the positive and negative pins each togehter to get half-duplex transmission?

To my current issue: I think you´re right, that it has something to do with the RTS pin. I´ve now connected PT3 direct to the transceivers DE pin but there´s no signal (0 V) on it.
The above described toggling was on pin PTC7 which is defined as RTS1 on both serial tower boards. I´m a little confused about your explanation of the RTS pin connection.
On my board (TWR-K20D72M) there´s no 0R resistor on this path and PTE3 goes direct to the expansion header. I also did not find the descibed connection to PTC3 on the schematics.
By the way I soldered R35 on the mainboard to connect PTE0 as TX. UART1 (RTS,RX,TX) is now directly connected to the transceiver via expansion header.

In the original software I changed just the following things:

* swap comments of #define FRDM_K64F and #define TWR_K20D72M in config
* in config.h: uncommented USE_MODBUS
* in app_hw_kinetis.h DEMO_UART from 1 to 0
* in modbus_app.c: MODBUS_MODE_ASCII to MODBUS_MODE_RTU                                                    
With an USB-to-RS485 converter I try to poll slave adresses 0 to 254 (19200 Baud) without any response and I can´t see any signal on RTS or TX.
Did I miss something or do I need a new mainboard? ;-)

Best regards
Felix

mark:
Felix

I would check signals directly on the K20's pins (1, 2 and 4) to be sure that signals are really there. A lot can go wrong with the Tower boards since signals have to be traced across at least three boards with various jumpers in the chain.

If the RX signal arrives (with correct settings) you will see transmission shortly after, with pin 4 pulsing high (this is what I measured to be sure, although I was using RS232 for the actual Modbus communication connection). Since RS232 and RS485 differ only at the electrical level the test that I did will have verified the operation up to the chip's pins.

Beware that PTE3 is connected to the back-plane (elevator) directly but is not used by the TWR-SER board.

I'll take a look at the TWI-IND-IO diagram to see whether it needs different routing or not.

Regards

Mark

mark:
Felix

I checked the TWR-IND-IO diagram and it doesn't look as though its isolated RS485 works together with the TWR-K20D72M.

For example, the receive signal is connected to C41 of the secondary elevator, meaning that the correct secondary elevator needs to be used (not a dummy one). However, the TWR-K20D72M doesn't support any connections on the secondary elevator.

Do you agree with my observations?

Regards

Mark

Felix:
Hi Mark,

I double checked the connections. All three lines are connected between RS485 transceiver and uC via UART1.
On RX there´s some data transmission during polling. TX is permanently high and RTS is low.
I agree with you that the connection of the transceiver is similiar on both serial board, so in my opinion both of them should run with the right connection of RTS. Although I have no idea at the moment, I will give it another try later. Maybe I will look for another hardware.

Regards
Felix

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version