Sign in to follow this  
Followers 0
wal

Is it possible to use FX3u-485ADP-MB as a Modbus master or as a slave in one program?

21 posts in this topic

Dear colleagues, is there need for two different PLC programs (one program will use FX3u-485ADP-MB as a Modbus master and another as a slave) if we don't know what will be used? Is it possible to combine both options in one program? I have to prepare solution for Modbus communication, and don't know, if the future customers will ask for slave or master. Regards, Waldemar

Share this post


Link to post
Share on other sites
Sorry, not you cannot combine serial master and slaves on the same unit. This is becuase there is only one "input" line and one "output" line. On for example Ethernet you can combine server/client (master/slave) since you can use multiple separated sockets but that's another story...

Share this post


Link to post
Share on other sites
If I'm understanding you correctly, and you want to realize in the combined program either Modbus Master or Modbus Slave communication, depending on the customer's choice, yes, it's possible. One way of several, allowing it, is to pack each of both communication routine into subroutine and to call the necessary subroutine depending on the communication settings, choosen by customer.

Share this post


Link to post
Share on other sites
Will it really work ? I once tried to change the settings (baud, parity, stop bits) from the operator panel during run, but the PLC needed to be restarted before each change would work. But, that might be another thing ......

Share this post


Link to post
Share on other sites
Yes, Bryll, it's really work. Of course, it's need to take into account that there are need to provide some procedure issues to change the communication channel settings, but it will work. In topicstarter's case the default settings must be for Slave, then the customer can change it to Master and to restart the PLC, after the device will works as Master. In other case, for example, if is need to change the communication mode from Slave to Slave (another communication settings or another communication protocol), it could be done even without restart.

Share this post


Link to post
Share on other sites
I agree with Inntele, it is possible if you have a common baudrate/bitsetting section (always the same independant of slave/master). You could then call the correct subroutine depending on the customers choise. However, in practice you will really need two different programs. Remember that when using Modbus Master you will also need to process all the send/receive data accordingly with an approperiate program. So all in all it will require a lot of work, and in essence two separate programs in subroutines. Maybe even more work that having two different programs. I would recommend two almost similar programs in different files instead, but that's just my opinion.

Share this post


Link to post
Share on other sites
Also agree with you, Kaare, that it's not so simple to combine, however is possible and not so difficult. To change the communication format settings to any necessary value is just enough to turn off (to prohibit) the RS-instruction for one program scan, when you do it

Share this post


Link to post
Share on other sites
Did they change the initialization procedure for the ADP cards? I remember that with the BD cards for FX2N and lower you had to power off/on the PLC... Or maybe I'm missing something?

Share this post


Link to post
Share on other sites
Sorry, Kaare, you are missing. If to use the sequence, for example, like this: LD M8002 MOV D1000 D8120 INV RS ..... or if to use the communication settings by PLC parameters, that yes, it will require to power off/on. However the programmer could use another command sequence and to change the communication format without power off/on at any moment when he would need to make it. The simple samples are described in the manuals (Communication, Programming).

Share this post


Link to post
Share on other sites
Nice to know, thanks Inntele!

Share this post


Link to post
Share on other sites
Don't mention it, Kaare Once I've implemented such combined: eight different protocols and arbitrary communication settings. The desired can be easy selected with MAC E300 by customer. Edited by Inntele

Share this post


Link to post
Share on other sites
Thank You very much for the help. What is not clear, should I use RS command for settings? In Mitsubishi manuals for ADP Modbus, the RS is not mentioned.

Share this post


Link to post
Share on other sites
In contrary, I wrote, that the RS-instruction, if it is used, must be prohibited at the moment when is necessary to change the communication settings. It means that the communication port is off at the moment. Even in case the RS-instruction is not used, anyway all communication through the port should be stopped. I can look the manuals, and then could give you specific recommendations what steps you should make for ADP-MB module to change mode from Slave to Master.

Share this post


Link to post
Share on other sites
Based on the conditions of usage for M8411 flag, that described in JY997D26201 document, the best way is to create two subroutines (one for Master communication, one for Slave communication) and activate the desire subroutine with a battery latch flag. For example: M3000 = 0 the module should work as a Slave M3000 = 1 the module should work as a Master and in main program should be: LD M8002 AND M3000 SET M0 LD M0 CALL P0 ; Master communication INV CALL P1 ; Slave communication. When you supply the equipment to the customer, M3000 flag is off on default, i.e. the device will communicate as Modbus Slave. When the customer power on the equipment, then he can perform the communication setting via HMI and to choose the Modbus Master mode. Then he has to STOP-RUN PLC and after that the equipment will work as Master. If he would want to return to Slave mode, he must repeat the procedure. Hope the explanation can help you Edited by Inntele

Share this post


Link to post
Share on other sites
You are welcome!

Share this post


Link to post
Share on other sites
Tried to configure Modbus from HMI. PLC used-FX3G +FX3u-485ADP-MB. No success. It works fine when: M8411 ---||------------MOV H1097 D8400 but it does not work if: M8411 ---||-----------MOV D128 D8400 despite the value H1097 was previously written to the D128. What is wrong?

Share this post


Link to post
Share on other sites
The information, you published, is insufficient to understand what is a root of the problem. Could you publish completely a piece of code.

Share this post


Link to post
Share on other sites
wal, see the Item 4 in Chapter 5.4. How to bypass these restrictions: First of all, try to use indirect constant as an operand of MOV command, like this MOV H...Z D8400. If such structure will not work too, because it's also probited by this item, then you can circumvent the restrictions using a set of subrotines, in each of which the operands are constants, and to call the necessary subroutine by CALL command with indexed pointer as its operand. Edited by Inntele

Share this post


Link to post
Share on other sites
Thank You very much Inntele. I tried subroutines. First impresssion is good. I did not try to play with parameters, but generally it works. Not clear with indirect constants. How does it look like?

Share this post


Link to post
Share on other sites
Indirect constants= indexed constants, i.e., for example, MOV H0Z D8400, where Z is the index register, that stores the variable value which must be written to D8400. Don't sure, but may be it will work. So try to test it, before to create a lot of subroutines.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0