Jump to content

Recommended Posts

Hi everyone,

I am trying to connect the V350 PLC to an ESP32 Wrover-E T-SIM7600G-H using RS232 Serial communication, now the RS232 from the plc is connected to a MAX3232 which shifts the logic level from RS232 to TTL.

Now I've already tested the communication of the ESP32 & MAX3232 through loopback method.

Now, I am trying to send a series of string from the plc, to the ESP32. Here is the initialization of the com FB, I copied the Example for V130_send_string_in_seriesimage.thumb.png.a7aaa1ff013416bd64164bc2c3f294d6.png

Here is the code for sending the data,

image.thumb.png.6d034cc4287089036a3fc3d6b871c8c7.png

And here is the DIP configuration.

 

I would really appreciate your help to figure this out, I have been running in circles for the past 3 weeks.

IMG_1417.jpg

Link to comment
Share on other sites

  • MVP 2023

Hi.

You must know that working with Visilogic over port1 disables port1 from working over other protocols. You can check current port settings via Info mode.

Even when using the USB port  port1 is disabled ( through the USB - COM adapter in the PLC).

Best option - use second com port add on card for connection  or use Ethernet card for Visilogic communication.

You can also connect PLC with PC Terminal software for check communication.

 

P.S.  Sometimes RX and TX wire swap is problem - TX1 go to TX2 and RX1 go to RX2 - result - no connection.

 

  • Like 1
Link to comment
Share on other sites

  • MVP 2023

Further to what Kratmel has said, if you are stuck with no other ports for the moment, start from very basics and also do a test screen that will show and let you do all you want, with the plc not connected to the PC.

Also, how are you powering the Max?

A quick look at your ladder and there is not enough shown to confirm this, but it looks like it is capable of doing a repeat send of something different each scan.  232 and internal buffers will not like the speed of  this.

 

  • Like 1
Link to comment
Share on other sites

Hi all, thank you for your prompt response!

Yes Kratmel I’ve read the documentation extensively it said that Com 1 has both rs232 and usb.

The second port is an IO expansion port.

I can try the Rs485 on Com1.


I’ve triple checked the wiring, and Ausman, that is correct, it is running in a loop, pretty quickly as well. 
 

I’ll try to include the 1 second pulse to slow it down and test. Also I’ve connected the Rj11 to DB9 cable to a DB9 to USB and connected that to the pc and I was able to read the data easily.

I am powering the max3232 with 3.3 V.

I didn’t quite understand this statement Ausman:” Do a test screen that will show and let you do all you want”

I am thinking;

- Buy a usb gender changer.

- Connect usb mini on plc to USB to DB9.

- Connect that to Max3232.

- Connect that to ESP32 and test.

Link to comment
Share on other sites

  • MVP 2014

Hi Jalal,

Jus to back things up a little, the second port is not fitted by default to the PLC. From the photo you sent I can see that the port 2 slot is empty:

image.png

 

The expansion port is completely separate to the add-on COM port. When you are trying to run serial comms and also debug the program using Visilogic, a second port is almost essential. Part number is V100-17-RS4 or V100-17-RS4X. I'll take a guess at who you are working for, but please direct message me to confirm and we will try to help you out.

You won't get anywhere trying to connect a USB to serial adaptor into the USB programming port of the PLC.

I hope this helps,

Kind Regards,

Simon

 

 

 

  • Like 1
Link to comment
Share on other sites

  • MVP 2014
12 hours ago, kratmel said:

Hi.

You must know that working with Visilogic over port1 disables port1 from working over other protocols. You can check current port settings via Info mode.

Even when using the USB port  port1 is disabled ( through the USB - COM adapter in the PLC).

Best option - use second com port add on card for connection  or use Ethernet card for Visilogic communication.

You can also connect PLC with PC Terminal software for check communication.

 

P.S.  Sometimes RX and TX wire swap is problem - TX1 go to TX2 and RX1 go to RX2 - result - no connection.

 

Hi Jalal,

Thanks for getting in touch. I now understand what you are trying to do. The above comment from @kratmel is the essence of the issue. It sounds like you are using the programming cable that has the MJ10-22-CS25 adaptor on it. The alternative adaptor MJ10-22-CS76 achieves the RX to TX wire swap and also has the opposite DB9 connector.  I can organise a MJ10-22-CS76 for you to try.

Kind Regards,

 

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
Posted (edited)

Hi there everyone, 

Thank you @Simon for your advice it is working well! 
 

As I am still new to serial read/write on V350.

I am wondering if I can ask for guidance on how to read incoming data on the PLC?

The only problem I am facing is sending and recieving text from and to PLC. How do I do that?

 

Edited by Jalal_Flo_Smart
Link to comment
Share on other sites

Hi Jalal;

Sending and receiving text over serial :

      Under   FB's       Protocol Send and Protocol Receive  - Text and variables

      Under Help  - V9_0_0_   Project Examples - Communications -  FBProtocol          some examples

VisiLogic does have some string processing functions.

Strings and ASCII   Characters  are stored in MI's    -  Best read  as   HEX  -  have an  ASCII chart handy

Search   HELP   -  Contents-Communications-Communications FBs  - FB Protocol

DanT

 

Link to comment
Share on other sites

  • MVP 2023

Hi Jalal, further to all of the above, I've attached a pdf which includes much of your need, without involving the use of the help files. 

It is essentially the help file, but as a pdf which makes it a fair bit easier to use.  In your case, go to page 128 and read onwards!  Please also note that because the pdf was made some time back, perhaps some things have changed since it was first issued.  When you can, read the rest of the pdf for other useful info to further reduce brain storage capacity....🙂

cheers, Aus

VisiLogic - Function_Blocks.pdf

Link to comment
Share on other sites

Hi DanT and Ausman,

 

Thank you for your prompt response appreciate the help.

11 hours ago, DanT said:

Under   FB's       Protocol Send and Protocol Receive  - Text and variables

I cannot find that.

1 hour ago, Ausman said:

Hi Jalal, further to all of the above, I've attached a pdf which includes much of your need, without involving the use of the help files. 

It is essentially the help file, but as a pdf which makes it a fair bit easier to use.  In your case, go to page 128 and read onwards!  Please also note that because the pdf was made some time back, perhaps some things have changed since it was first issued.  When you can, read the rest of the pdf for other useful info to further reduce brain storage capacity....🙂

cheers, Aus

VisiLogic - Function_Blocks.pdf 3.7 MB · 1 download

I've read the Help section, it is all similar. There are nothing that referes to Send/Recieve Text.

11 hours ago, DanT said:

Strings and ASCII   Characters  are stored in MI's    -  Best read  as   HEX  -  have an  ASCII chart handy

You mean that whatever if I am sending a DW, I should convert it to MI, and send it as "Hex as ASCII"? 

 

Link to comment
Share on other sites

  • MVP 2023

Setting up your own serial communications is a little daunting.

Step 1 - You have to initialize the COM port so you can access it from within the program.  I heavily recommend getting the second serial port Simon mentioned so you have a COM 2.  Otherwise you're using your programming port for communication and you won't be able to be online and do serial communication at the same time.

Protocol Receive is cleverly named Protocol Scan and is a little complicated.   The Protocol collection is located under FB's -> Protocol.

Getting to the Help topic is a little tricky; under the Contents tab go to Ladder -> FBs Library -> FB Protocol.   Once you're there you should be able to navigate it.

Step 2 - Drop a Protocol Config block on the same rung as your COM INIT block.  This block assigns a "Busy" bit and a Status register for use in the program.

Step 3 - Drop a Protocol Scan block.  This is where the fun begins as this one block contains a table of all possible receiving actions.  I always make the first entry a block of MIs that will be the receiving buffer.  You'll need to take this buffer and do something with the received string when the Session Complete bit you assign comes on.   You'll have to clear that bit after you process the string to re-enable the block.

Step 4 - To send, simply use the Protocol Send block.  You can embed variables in your strings.

 

Read the Help a couple of times and practice with a terminal program.  Have swing at it and post your program here with questions.

4 hours ago, Jalal_Flo_Smart said:

You mean that whatever if I am sending a DW, I should convert it to MI, and send it as "Hex as ASCII"? 

ASCII characters are always in hex and take one byte.  That's two per MI and four per DW.  The Protocol block doesn't care which one you use.

There's a tab at the bottom of Visilogic called "Memory".  Use this area to monitor the ASCII values in your MIs and DWs.  You can toggle the Format to ASCII while you're online and it will convert the hex values to ASCII for you.

I've attached a program you can look at and play with to get started.

Joe T. 

Basic Protocol example.vlp

Link to comment
Share on other sites

Hi Jalal;

  Picture below shows the way  to the FB  Protocol Help

  Know the structure of the incoming message  to be able to "decode" it  

  If there are different messages coming in, set up a protocol Scan Line  to look for the keys  and  the data  -- see the PDF attached

 

DanT

FB Protocol.jpg

FB Protocol Scan Details.pdf

Link to comment
Share on other sites

Posted (edited)

Hi all,

Thank you all for your advice, here is the code I am currently testing, I am able to send and recieve integer, and string. 

It is all dependent on the length of the message, as long as the length of the message is = to the one defined then it appears on my screen. 

In regards for the recieving a list of Strings/ ASCII. Do I add a message below/ above this message and define the length of that message to the left of it?

My goal is to show the list of Top 4 Available Wifi networks in close proximity to the PLC, logic will be handled on the ESP32 in regards for choosing the top 4 networks, but listing 4 strings for users to choose from is tricky at the moment.

image.thumb.png.527377b28477a8c5168edca2108439fc.png

 

Thank you all for contributing,

Also I am getting status "1" for the protocol configuration quite often, how do I resolve it without having to reset the PLC?

 

 

SendData.vlp

Edited by Jalal_Flo_Smart
Link to comment
Share on other sites

  • 1 month later...

Hi All, 

 

Thank you for your guidance and advice, I am able to send and recieve data from and to the V350 with ease.

I am facing an issue though, we've got a bunch of V350 plcs all of them have on Port 1: Com port and RS232. Where it can only work one at a time. So debugging capabilities is minimal.

One of the PLCs'  protocol status is stable and stays at 0, almost all the time we're working with it, and when I download the same code to another PLC, the status lingers on status 0, until it recieves 8 bytes, then drops to status 1, we require to reset the plc to get status 0 again, but the same issue is thrown after it recieves 8 bytes.

I am preplexed, it seems to me like we have minimal control over the connection of the RS232, within the PLC.

Any advice would be much appreciated,

Kind regards,

Link to comment
Share on other sites

  • MVP 2023
On 5/9/2024 at 8:55 PM, Simon said:

The expansion port is completely separate to the add-on COM port. When you are trying to run serial comms and also debug the program using Visilogic, a second port is almost essential. Part number is V100-17-RS4 or V100-17-RS4X. I'll take a guess at who you are working for, but please direct message me to confirm and we will try to help you out.

Get a second port and use that for your communication.  You need to be online via port 1 to do any kind of troubleshooting.

Joe T.

Link to comment
Share on other sites

  • MVP 2023
On 7/17/2024 at 8:42 AM, Jalal_Flo_Smart said:

I am preplexed,

Wondering whether you have checked the port jumper settings in the offending units?  Perhaps they are not set correctly, better suited to previous connection attempts/usage?

cheers, Aus

  • Like 1
Link to comment
Share on other sites

17 hours ago, Joe Tauser said:

Get a second port and use that for your communication.  You need to be online via port 1 to do any kind of troubleshooting.

Joe T.

We have bought more than 10 plcs, all with the same port connections.

2 minutes ago, Ausman said:

Wondering whether you have checked the port jumper settings in the offending units?  Perhaps they are not set correctly, better suited to previous connection attempts/usage?

cheers, Aus

I have, also have listed the jumper connections above.

Link to comment
Share on other sites

  • MVP 2023
1 hour ago, Jalal_Flo_Smart said:

We have bought more than 10 plcs, all with the same port connections.

I figured you have multiple PLCs.  But they are all the same piece of hardware - there is something in your code that is probably based on a timing issue that you have to track down.  It actually takes  a little time to clear out the serial buffer since that is a different processor on the board, so you can't call reads and writes right after each other immediately in your code.  I've been guilty of this, and have solved the problem by putting very short (50 ms) timers between serial calls.

You need at least one PLC with a second port test things in real time while you watch the code work.  Modify the code temporarily to use COM 2 for your test setup.

Joe T.

  • Like 1
Link to comment
Share on other sites

9 minutes ago, Joe Tauser said:

I figured you have multiple PLCs.  But they are all the same piece of hardware - there is something in your code that is probably based on a timing issue that you have to track down.  It actually takes  a little time to clear out the serial buffer since that is a different processor on the board, so you can't call reads and writes right after each other immediately in your code.  I've been guilty of this, and have solved the problem by putting very short (50 ms) timers between serial calls.

You need at least one PLC with a second port test things in real time while you watch the code work.  Modify the code temporarily to use COM 2 for your test setup.

Joe T.

I have been able to read, then write immediately on one of the plcs. But the second plc, the status integer stays at 1.

 

i’ve attached the current code, incase you’d like to see what i’m working with.

 

kind regards,

jalal

DATA COMM.vlx

Link to comment
Share on other sites

  • MVP 2023

Menu

Connection > Export PLC operand to text file for connected  working PLC. (You need to enter a file name)

Then connect to  nonworking PLC  Menu->Connection > Import PLC operand from text file.  Then reboot PLC and test. 

 

  • Like 1
Link to comment
Share on other sites

  • MVP 2023
23 hours ago, Jalal_Flo_Smart said:

I have, also have listed the jumper connections above.

Yes, I saw that, but have you double checked them all?  It's so easy to miss something like this.

And a + to Joe's buffer comments.  If you don't allow sufficient time you can have a system that will work fine for ages, then suddenly something happens that extends the time needed for correct comms, and it all falls over because you still don't have enough time between calls. Been there, done that, months after leaving a thing working perfectly.   I actually now use a count system based on +1 per scan.  It can try to self-correct that way, through some adjusting logic.  Generally my scan times are fairly constant.  And on this note which essentially deals with timeouts, don't forget to allow for retries in the intervals needed.  You need to allow for everything that might happen in a worst case scenario, and then add some more for the buffer clear.

cheers, Aus

  • Like 1
Link to comment
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
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.