Jump to content
SvjatoslavsKrasnikovs

Modbus connection to Arduino through RS232 interface problems

Recommended Posts

 

Hi. I have a Unitronics JZ20-R16 (Jazz2) controller I’ve programmed to run a simple air ventilation system in my house (The thing is running great btw.). I also have a self made Arduino based data logger (I use it to monitor and log my energy consumption, temperature, etc.) I’m not building those things or mass producing, Arduino electronics is my hobby - I just use it to stay sharp.

 

So I decided to cross-integrate my air vent. Controller with my data logging unit (I want to see the status of my air vent. Controller unit on Arduino). So for starters the task is to simply send a 16bit int to Arduino and receive another 16bit int from the Arduino.

 

The communication protocol of the choice was MODBUS through RS232 interface (as I already have MJ20-PRG; MJ20-CB200 and a MJ10-22-CS10). I’ve decided to use JZ20-R16 as a Master (Arduino as a Slave) in a 9600 baud 8N1 configuration (default for JZ20-R16). For Arduino’s RS232 interface I’ve used TTL-RS232 converter (MAX3232 based) :

t6NhpTTctm6qdH_WrvF2zlJCRbwVPDSTg4nyyz6FAd1AbHubgJLQmXGtuX7dAfycWHi9w6l-diJt-tahqyxoghL5G3jsOyuLo2fu31eNAoTLzUQClAPW8VG1OpsOOjUp7qtdOw38vnzeOIRn48ACVcILzJYbR0uTTFv1XEPoKj-zet25eP3_bH8wC2uIQoaNnabOq1Wp_XRbC5mfBUUHhSLla3nBEgca3bP2RDsjqd3cBHH0E64XJ5a9zHHQ_wLPu2SqzmAkkRvXFlh0

Experiment 1:

In order to see if the Arduino’s MODBUS feature is working I’ve connected Arduino to my PC using the given connector and a RS232-USB converter. Arduino was configured as a slave and ModbusPoll software (http://www.modbustools.com/modbus_poll.html) simulated a master. I was able to both read a holding register from Arduino (03) and also write a register (06). Those are the desired options.


 

Experiment 2:

In order to see how MODBUS is working on JZ20-R16 I’ve hooked it up to my PC using my MJ20-PRG; MJ20-CB200 and a MJ10-22-CS10 later connected to RS232-USB converter. I’ve uploaded a program (by pressing buttons 1 and 4 I send an int or correspondingly request an int from slave):

(see in uploaded files)

It make the JZ20-R16 work as a Modbus master on a RS232 interface. In order to simulate a slave I’ve used ModbusSlave software (http://www.modbustools.com/modbus_slave.html) . Once again, the combination worked perfectly. Once again all the required commands worked.

 

Here’s the photo of my hookup:

EuVUNLGyouHYuc8vNwtj1YGtuay0IXoEpgbpB2CKzid-93-MVMByfFMuEUiYKVpWtqzw1od-jZ4eSnT-pR3TTppzH2szkIFEfo1qO12lUJvnQIcHUPSYV_c8genzSVJrtHeLQn88

Then I’ve noticed a possible cause for future problems : lines 4 and 7 of my MJ10-22-CS10 are actually used in this communication. It turned out that the RS232 communication with JZ20-R16 require 6 wire communication instead of 3 wire communication I’ve expected from RS232 interface. Due to the requirement of RTS and DTR signals!

 

I’ve turned on my scope and actually saw those signals on pins 4 and 7 of MJ10-22-CS10 connector going high after the “handshaking” with my slave simulator was done.

With PC USB disconnected:

-qx-3p2TOx9D9S5QZroYhUsQke1tVT9_kk0bYIR2V5qpOlsBOE8xciDKXLeHa8Miu6Gj7Eg7aeo98FsMMhhK89lfe5Pyme6ZRly1dhKiTEhIr5ViwrDFh0kBrvWfxQrXazm5fp2f

PC USB Connected:

7DhrNBf6Cifd7T9MHA7e_CfZK9sOS12U1wSHLc8PREu4HP81b5kkk3tvI59VftmrCbodrxwf4kBT442C7NUMvfCykC3LlONAsoAaUfWMXPTNYtm8n7pnKHm8hPEigC6hnM1ig5TV

MudbusSlave  after “handshaking”:

q4qgimB6E85k1e5l3esdE3rR7GeHLn5DCCLGp9yqcRWhui0JjSyI_zRYhWnAqGUtP1r0yA8glzCIqrJfaNzbUVAtVob7zCXgudtB43c0FWkHBK3VycA9rImIjL-EbZL50Z1rqX7T

Successful communication:

483LWepHAcc7PbfVatoCXlM9xjQ4p_HKi6HfUPTEvcjYYJWOwmcKriW_0iTXRloknOx-zpIzpvhJlFP-FBX1x-FmFqQFxHflnyP0I_Q2szW_VrJTAxvr4rUgvYsmho7vVXkISX95

CH3/4 are the DTR and DTS signals correspondingly. At this point I’ve realizes that sue to those signals I would not be able to connect my Unitronics to my Arduino, as the TTL-RS232 connector simply do not support DTR and DTS signals. So after hooking up my Arduino to Unitronics I see the following on the scope:

6L7BW1-zVpc5ibVxoEZDPThgBzdXrl8TPZHAugjBGTYzer0TZiqtoXEph7MVgu46v2IrDZAkQXQh-UCYSbFL1aTo62vPPDCQkdZhY6MhYqdAyfhbb4NZHXIBoJE482-1cUibJb2W

Both DTR and DTS signals are on 0 instead of HIGH, which prevents the JZ20-R16 from accessing the modbus.

 

The questions:

  1. Is there any chance to make JZ20-R16 communicate over RS232 without use of DTR/DTS signals?

  2. Is there an option to tweak those signals (connecting them to +5V permanently)

  3. Use of other TTL-RS232 converter?

  4. Any other way to make Arduino and JZ20-R16 communicate over RS232 interface using MODBUS

 

Thank you for the patience.

samplemodbusmaster232.U90

Share this post


Link to post
Share on other sites

Hi,

MJ20-PRG module require external power on pins 1 & 6, and it use MJ20-CB200 and MJ10-22-CS10 for this.
And it cannot use DTR and DSR signals.

Use MJ20-RS module instead of MJ20-PRG. It require 4 wires cable from RS232-CB1 set.
*This cable is crimped as "cross". 2-3-4-5 pins of one connector crimped to 5-4-3-2 pins of other connector.

Everything should work.

Share this post


Link to post
Share on other sites

Thank You for the reply. Well, I do not have an access to MJ20-RS module at the moment. All I have is MJ20-PRG, MJ20-CB200 and MJ10-22-CS10.

If I'll power up pins 1 and 6 of a MJ20-PRG through MJ10-22-CS10 (just like in a picture attached) will I be able to use my MJ20-PRG as a RS232 module ? Or do I need to change the schematic in any way (attach series resistor to +5V line, etc.) ?

Thank You

 

 

IMG_20170719_165938 (1).jpg

Share this post


Link to post
Share on other sites

Hi Svjatoslavs,

Please use next documents for PRG adapter:

https://unitronicsplc.com/wp-content/uploads/2016/06/MJ20-PRG_TECH-SPEC_10-09.pdf

https://unitronicsplc.com/wp-content/uploads/2016/06/JZ-PRG_INSTL-GUIDE_10-09.pdf

Last one include CS10 adapter wiring.

I will recommend to connect contacts 1 and 6 of a MJ20-PRG to contacts 6 and 1 ofh MJ10-22-CS10, connected to RS232 port of PC.
Or connect contacts 1 and 6 of MJ20-PRG to +24 V by resistor (24-5.5)/0.1~=185 ohm.

You have to use GND with Tx and Rx signals.

Tell us how it works.

 

Share this post


Link to post
Share on other sites

Thank You so much for trying to help me. I've sketched a rough connection schematic, according to what You've suggested. Is it right ?

On the JZ20-PRG to JZ10-22-CS10 side, the connection is standard (through MJ20-CB200 cable). However, after the DB9 of MJ10-22-CS10 I'm braking the connector (DB9) into individual cables (on a breadboard). The +24V will be used from the PSU (I'll use bench PSU , with GND connected). 

IMG_20170727_103744.jpg

Share this post


Link to post
Share on other sites

Hi Svjatoslavs,

Schematics seems to be right.

What your test show? Is communication working?

By the way, what Arduino MODBUS stack do you use?

Share this post


Link to post
Share on other sites

Hi Svjatoslavs,

Resistor of 180 ohm with current 0.1 A dissipate 18.5 V* 0.1 A=1.85 W. You should use 2W resistor.

So variable resistor should be powerful...

B.R.

Share this post


Link to post
Share on other sites

I used 3x560 ohm resistors in parallel. This equivalent to ~187 ohm.

Resistors connected between +24 V and contacts 1 & 6 of PRG adapter. *Wires 1 & 6 cut in the middle of cable.

Wires 2 and 5 connected to 0V of PLC.

*I used 6 wires phone cable (cross-crimped) and open it in the middle.

Opposite to PLC cable end connected to MJ10-22-CS25 adapter, then to USB-to-Serial converter.

Following is Get result from PLC

PRG.jpg

Additional to this, I tested 560+560=1120 ohm resistor.  Online (Debug) mode works.

Please use 1.1 kohm 2W resistor and test communication. I hope it will work.

*MJ10-22-CS25 adapter include inside 2 diodes, Zenner diode and electrolytic capacitor.

Please post your results for feature readers.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...