MODBUS Slave

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

Moderator: Benj

Post Reply
User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

MODBUS Slave

Post by AbhijitR »

Hello!

I am trying to use the Modbus Slave component (example attached, from the FC8 help), may I know if I could test/check the feedback/working of the hardware communicating with the computer using RS232, can someone suggest any program to test if the actual hardware slave is communicating with the program on computer, is it possible to write as well from the computer program to the slave hardware.

In that case what should be the parameters I need to set in the program to establish the communication with the slave hardware.

I tried to use MODScan32 with the below settings, but without success or may be I am wrong.
Baud Rate: 9600
Word Length: 8
Parity: None
Stop Bits: 1
Transmission Mode: Standard RTU

May I request someone to correct/help me.

Thank you.

Regards
Abhi
Attachments
ModBus_Slave_Example1.fcfx
(10.23 KiB) Downloaded 330 times

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times
Contact:

Re: MODBUS Slave

Post by EtsDriver »

Ill just keep the good work up!

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: MODBUS Slave

Post by Steve001 »

Hi Abhi

Had a quick look at your chart

Didn't see a "Modbus address" set .

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

Steve
Success always occurs in private and failure in full view.

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hello! Steve and EtsDriver

Many thanks for your notes.

My intention to work on this project was to check how does the target board (slave) responds to ModScan32 (master in this case), the examples from the FC V8 help Modbus Master and Slave will for sure work well as both flow chart complements each other, but my purpose was different, I wanted ModScan32 to be master.

I modified the “Modbus slave” flow chart and few properties as per my requirements,

1. “Timeout” previously it was 100 I changed it to 250
2. “Reply Delay” previously it was 200 I changed it to 20000
3. “Number of Addresses” in Modbus Coils previously it was 10 I changed it to 8

After making the above changes I was able to monitor the output bit B.2 from the attached flow chart toggling on ModScan32. I was happy to see that working. I will try with the digital as well analog Inputs too.

Steve if I have not mistaken to understand the “Slave Address” (28 in the example) is “Modbus Address” or the NODE address to monitor.

Thank you again.

Regards
Abhi
Attachments
ModBus_Slave_1938_23-08-2018.fcfx
(15.5 KiB) Downloaded 329 times

User avatar
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: MODBUS Slave

Post by Benj »

Hi Abhi,

Not sure if this is useful for you or not but I have just added a Modbus demo here using vNet so you can use one instance of Flowcode to control another instance of Flowcode. Please note I managed to fix a couple of bugs in the update related with the Modbus slave data receive in simulation.

viewtopic.php?f=76&t=20394&p=90244#p90244

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hi! Ben

Happy to hear you :), thanks for the suggestion, I will definitely try that and keep posted.

Thank you.

Regards
Abhi

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hello!

Trying to work with Modbus Slave, every thing works well with the below settings in the component properties

Channel: 1
Baud Option: 9600
Bus: RS232
Timeout: 250ms
Frame Type: RTU
Slave ID Bytes: 1
Salve Address: 99
Reply Delay: 20000us

If I change the Baud Option to 19200, the slave do not respond with the master (in this case I am using my computer as master with RADZIO software)

Can someone point out the mistake, any suggestions.

Thank you.

Regards
Abhi

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hello!

Following my below post there is some progress, everything worked well after I opened the coil of the wire which was more or less 150 meters and then did the connections between master and slave, all worked well, the coil of 2 core cable was the problem.

Hello! Ben

I have one more doubt, how can I change the "Parity" and the "Stop Bit" in the properties window of the Modbus Slave, sometimes it is necessary to change as the master may have different settings, any hint?

Thank you.

Regards
Abhi

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MODBUS Slave

Post by LeighM »

Hi Abhi,
Thanks for the update, glad you got it working.
As for parity, the device (16F1938) does not have hardware parity generation.
Hence we would need to make changes to the Modbus component to do this in software.
I'm not sure that we currently have the time to do this, but I'll see what Ben thinks when he is back in the office.
Leigh

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hi! Leigh

Thanks for the update regarding the Parity Generation, after you mentioned I read the datasheets ;)
To be honest I am not aware of so many things with respect to hardware and software but will learn quickly.
Okay regarding the same and as you said is it really very complex and time taking to amend this 2 parameters in the "Modbus Slave Component" properties window, it will help me to anticipate accordingly with my new upcoming project.

Thank you, hear you soon.

Regards
Abhi

User avatar
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: MODBUS Slave

Post by Benj »

Hello,

My take on this is it should be possible but it would certainly be a software addition to the CAL UART where we increase the data bits from 8 to 9 ( or 7 to 8 ) to allow us to add a calculated parity bit when sending data. For completeness we would also need to check the parity bit against received data and if incorrect then flag up a new error.

It's certainly possible but so far hasn't really been requested. At least not recently.

I wonder how much of a problem it will be in not having it. Certainly for the SCADA mode it might make sense to allow it to be included so we can communicate with all kinds of equipment.

I'll add it to the list and see how complex it would be to add to the base UART comms. From there adding it to the Modbus component etc should be a doddle.

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hi! Ben

Thanks for your comments, I will share few more observations with respect to Parity and Stop bit.

Regards
Abhi

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: MODBUS Slave

Post by AbhijitR »

Hello! Ben
good morning

Following your last post regarding the update about few settings for UART, may i request you to please help me solve this problem.
Benj wrote:
Mon Jan 07, 2019 1:39 pm
Hello,

My take on this is it should be possible but it would certainly be a software addition to the CAL UART where we increase the data bits from 8 to 9 ( or 7 to 8 ) to allow us to add a calculated parity bit when sending data. For completeness we would also need to check the parity bit against received data and if incorrect then flag up a new error.

It's certainly possible but so far hasn't really been requested. At least not recently.

I wonder how much of a problem it will be in not having it. Certainly for the SCADA mode it might make sense to allow it to be included so we can communicate with all kinds of equipment.

I'll add it to the list and see how complex it would be to add to the base UART comms. From there adding it to the Modbus component etc should be a doddle.
My customer is using 17 odd number of slaves in one loop of Modbus master (Computer in this case) and the parameters used are as following

Serial Port Settings
Baud Rate: 19200
Data Bit: 8
Stop Bit: 2
Parity: None
RTS: False
DTR: False
Scan Time: 1000mS
Time Out: 1000mS
Retry Count: 1
Auto Recover Time: 3S

The other slave devices (most of them are SIEMENS) in the loop works well on this settings except mine, kindly help me how can i change/add the Stop Bit setting, if it is required as 1 OR 2

Kindly do the needful.

May i also request other forum friends to shed some light if someone is aware of this problem.

Thank you.

Abhi

Post Reply