Communicating between STM32F4 and energy meter using mod bus-RTU.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-16 4:20 AM
we are trying to read the line voltage register in the energy meter(em6400ng) using mod bus RTU over RS-485 protocol. we are assembling the packet in an array and sending it to the energy meter using DMA. also we are receiving the packet in a buffer using interrupt. The energy meter is only sending the first byte that is slave id in response. we are not able to find out the reason this occurrence, please point out the problem in our code. The code is attached below.
- Labels:
-
STM32F4 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-16 4:44 AM
> we are trying ...
Who is "we" ... ?
To get an USART interrupt, you would need to configure and enable this interrupt somewhere.
I guess your reception stops at the second byte with an OV flag.
> The energy meter is only sending the first byte that is slave id in response.
Have you checked this with a scope, or is this an assumption ?
Modbus RTU is timing based.
I had written code for an implementation, too.
I did not start to evaluate receive package contents until the package was complete, i.e. the 3,5 character times had expired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-16 11:44 PM
I checked it in watch window on debugger, also I tested my code with mod bus slave software with which my code is working fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-17 1:06 AM
A physical scope, at the physical Rx/Tx lines. Sometimes, assuming is not enough.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-17 1:27 AM
Ok, will check with the scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-17 2:48 AM
Checking the whole sequence of devices/events in your scenario first is a good method to tackle a problem.
Assuming a commercial device (your energy meter Modbus slave) will respond with incorrect/corrupted messages out of the bow will not get you far.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-17 9:23 PM
I can see the whole packet length on the scope on Tx line, But can only see one byte on the scope for Rx line from the energy meter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-17 11:51 PM
There is no valid RTU single-byte response.
Perhaps you have a half-duplex configuration, and grap the line after receiving the first byte ?
Like a RS-285 transceiver, using RTS to manage the transfer direction ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-18 12:15 AM
I am using RS485 configuration, I am not using RTS to manage transfer, I am having a receive and transmit enable pin instead to manage transfer direction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-18 1:05 AM
> I am not using RTS to manage transfer, I am having a receive and transmit enable pin instead to manage transfer direction
And RTS of the MCU's UART interface is often used to control this receive/transmit enable pin of the transceiver.
However you control it, double-check it.
If you have any working RTU master, you can verify if your slave (metering device) works correctly. I bet it does.
