Jump to content

Sending Command codes via RS-232


Recommended Posts

I am attempting co connect a Unitronics V700 to a Keyence Vision system by serial cable, in order to send the "change to program X" command to the vision system when the PLC is instructed to change to a new cap style.  I have a cable connected from Port 1 on the PLC (Which should be COM2, since activating COM1 shuts down the micro-USB port) to the Keyence's RS-232C port, I have confirmed thw wiring, baud rate, parity, etc.  The command is "prepackaged" in a set of MI registers (so the "X" of program X can be adjusted before the command is sent) and I have a subroutine that uses the Protocol Send Function block to send the data.

In theory, at least.

In practice, I see no data show up on the Keyence's RS-232 monitor, which should show all traffic in both directions; it is as if the function doesn't activate when called.

What am I doing wrong here? Do Function Blocks need to be scanned every cycle in order to complete, or do they start a "forked process" that handles the multi-scan function after being triggered once?  Do they need to be "energized" for their whole fun time, or do they require only a one-cycle "trigger" to take off and complete their task?

Link to comment
Share on other sites

  • MVP 2023

Hi Adreasler,

I am wondering if you have interpreted things correctly.

<<<<<

Notes:
3. This model is supplied with a serial port: RS232/RS485 (Port 1). The standard is set to either RS232 or RS485 according to DIP switch settings. Refer to the product’s Installation Guide.
4. Note that physically connecting a PC to the controller via USB suspends RS232/RS485communications via Port 1. When the PC is disconnected, RS232/RS485 resumes.
5. The user may order and install one or both of the following modules:  
- A serial RS232/RS485 isolated/non-isolated interface module in port 2.   

>>>>>>

Are you leaving the usb connection in place during the trials?  Do you have ladder work setting the 232 port parameters properly?

If you have these in place and still have problems, with any 232 (or 485) communication issue that doesn't work as expected, I always go back to using the PC to send out strings to the item being talked to.  This is far easier to tweak a string to the correct solution rather than messing around using the plc.  Once the string works correctly, it then gets transposed into the plc.

Hope this might help

cheers, Aus

  • Like 1
Link to comment
Share on other sites

To answer your quoting of the manual:

3: I have confirmed that the dipswitches are all set correctly for RS-232.

4: I do NOT have the PC connected to the USB port, I am communicating with the PLC over Ethernet for programming.

4: Also, the manual is wrong, when the PLC has configured COM1, the USB port WILL NOT respond to PC communication unless the PLC is in STOP mode.  This was an earlier hiccup I had with the system, where I had accidentally deleted the "PLC Name" rung while clearing out unused code and could not communicate with the PLC for programming after that. (The warnings that kept showing up on the download windows had let me to believe that I needed to "burn" the download to keep the program in the PLC after power-cycling.) (The information of "The PLC needs to have a working battery installed to retain program data after shutdown." is at best a Note, not a Warning.")

5: As there is only one device being communicated with via serial, there is no need to add a second serial port.

Finally, the receiving equipment has a built-in Serial Port monitor, as I stated in the original post, so I can clearly see that it is not a case of garbled strings being ignored, the problem is that there is NO TRANSMISSION of data from the PLC.

Edited by Adreasler
corrected terms, "upload" to "download"
Link to comment
Share on other sites

On 9/24/2018 at 8:55 PM, Cam said:

Can you post your code??

Here are the pertinent sections that work on the serial port. One initializes the port, one preformats the data to be sent, one sends the preformated data.

In this version of the HMI program, I lowered the baud rate to 9600 to give me a better chance to see activity on the line with an old-fashioned RS-232 Line monitor and the MK I Eyeball.

Communication - Format Serial Command.vlx

Communication - Initialize Serial Port.vlx

Communication - Send Serial Command Message.vlx

Link to comment
Share on other sites

I loaded them into a V700 and can send a serial command that my PC will see in Hyper terminal.

I've got three subroutine calls in the main routine and then changed SB1 in both the Initialize and send  subroutines.

I suspect you've got an issue with how the subroutines are being called, but can't help as you didn't provide the full code.  Are you using conditional subroutine calls??

Link to comment
Share on other sites

3 hours ago, Cam said:

I loaded them into a V700 and can send a serial command that my PC will see in Hyper terminal.

I've got three subroutine calls in the main routine and then changed SB1 in both the Initialize and send  subroutines.

I suspect you've got an issue with how the subroutines are being called, but can't help as you didn't provide the full code.  Are you using conditional subroutine calls??

The initialize and format subroutines are conditionally called on a SB2 [start-up bit] signal, which should be correct, those only need to be called once at the beginning.

The Send subroutine is called by a subroutine that sets the SD card and Program Number values just prior to the Send routine.  The Sequence is as follows:

1. Operator selects "Product Change" from the main menu display.

2. The display changes to a Selection screen with buttons for the various products to inspect.  This Selection Screen has a subroutine that runs while it is active, said subroutine reads the buttons to determine what is selected. (This allows me to have multiple "pages" of selections while recycling the Memory Bits for the buttons, also allows making new pages easy when expanding the selections available)

3. The Selection subroutine attached to the page has a series of rungs for each button. The rungs for a button will, in sequence from top to bottom:

 3a. Write the correct SD card slot and program number into the appropriate slots in the preformated data in the MI bank.

3b. Call the Send Data subroutine.

3c. Change the Active Display to the Main Menu Display, thus exiting the subroutine.

I but the Send function into its own subroutine to avoid duplicating code in multiple subroutines. Should I instead have the selection screens set a MB "flag" to signal a rung in the main routine to call the Send subroutine, and continue to call the Send Subroutine until the "Sending" MB goes low?

Link to comment
Share on other sites

  • 4 months later...

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...