Sign in to follow this  
Followers 0
pszczepan

electronic scale ith RS232

54 posts in this topic

Hi, I have electronic scale with RS 232 output and I would like to transfer weight to my PLC system via RS232. Is it possible? What do I need - any data protocol or something and how I can make setup in PLC. Thanks in advance Pawel

Share this post


Link to post
Share on other sites
For starters, what CPU type ? And the scale unit; does it talk Modbus ?

Share this post


Link to post
Share on other sites
PdL has an excellent question! Also, take a look at the RXD instruction. Most of the processors support it. Depending on the cpu type, there may be better options. Hope this will help.

Share this post


Link to post
Share on other sites
Quite possibly, he'll need the TXD instruction as well. If the CPU supports it, a serial communications board with Protocol Macro would be easier to use for the implementation if the protocol is "messy". But it'll cost more as well...

Share this post


Link to post
Share on other sites
Hi Pawel, I use HBM 2108 weight metar with RS232 and CQM1H plc. It is posible but you mast know format of komand for weight meter and use RXD and TXD for send and receve data. If you use HBM modu in ther manual you will find all informacion for data format, and if you need I will send you my program example. Bay,

Share this post


Link to post
Share on other sites
Pawel, To summarise, you will need to get the following information about the Scale from the manual, documents on the manufacturer's website or the distributor/supplier : 1. Hardware Interface Connector - DB25, DE9, or other non-standard RS232 connector, etc. Gender - male or female Pin allocation - - DTE or DCE, or modified version Hardware handshaking - RTS/CTS etc Standard - RS232, RS485, etc. This, along with the PLC model and which PLC port you use (e.g. Host, Peripheral, etc.) will determine the cabling. 2. Communications Interface Data Rate (bps) (commonly, but erroneously, referred to as "baud") Number of data bits per character - 7 or 8 Character Parity - Odd, Even, or No Parity Number of Stop Bits - 1, 1-1/2, or 2 Handshaking - Hardware (RTS/CTS) - Software (XON/XOFF) - Both Hardware and Software - No Handshaking Normally these are configurable on devices but some may not be. You need to know how to configure them in the Scale or what the default values are. This information is required to set the PLC's communications parameters - the PLC's communications parameters must match the Scale's parameters. 3. Communications Protocol This could be proprietary or standard (eg. MODBUS). If the protocol is a standard protocol then the job may be easier depending on which protocol it is. The protocol will generally describe : Message Framing/Format (for both Transmitted and Received messages) - message block length - maximum size of message blocks - addressing - source and destination unit addresses, if used, and format - start sentinel (start of message character) - message block terminator (CR or CR + LF or other - error status - etc. Frame Integrity Checks Generally a "checksum" of some sort - CRC - CRC16, CRC32 - XOR across message characters - other Which characters are included in the check (i.e. start sentinel?, Data Format - ASCII or Biinary Timing Time from receipt of command from PLC to start of response Inter-character timing (not usually an issue these days) etc. Mode Master/Slave etc. - for this type of device the Scale will probably be a Slave polled from the PLC Data Representation Data Element description, for example : - Date - Time - Tare Weight - Weigh Number - Weight - Information entered from scale keypad - etc. Data Type and Size for each Data Element: - Date/Time - Floating Point (Real Number) - Short or Long - Integer - Byte, 16-bit Word, 32-Bit Integer, 64-bit long, - String (number of characters) - BCD - Hex ASCII - etc. Hopefully, as PDL suggested, the Scale uses a standard protocol that's easy to implement in the PLC (because someone has already done it) then all you need to worry about is processing the data elements specific to that scale or application. Initially I'd suggest that you reply to the forum with the detail of : - What PLC and PLC modules you are using/have available - The manufacturer and model of scale - Any details (as described above) relative to the Scale that you already have the information for Hopefully that will get you started and reduce the number of posts you need to create the solution. Eric

Share this post


Link to post
Share on other sites
Nice reply, Eric Point of interest: Has anyone used the string manipulation and comms support within Structured text FBs (V4.0 processors only)? It is a massive leap forward - very useful.

Share this post


Link to post
Share on other sites
Thanks for reply to everyone. Now I know what information about scale I need to make connection. When I have all of them I write it on the forum. I would appreciate Zoran, you could send me program example. Please attach it to this forum or send it to my email: patasystems@tlen.pl Thanks Pawel

Share this post


Link to post
Share on other sites
Hi guys Now I have manual for my scale. It has port RS232 with transmission parameters: 9600,N,8,1 I have CPM1A with CPM CIF01 attached. In the manual I have list of commands for PC (RS232) "T,CR,LF" - Tare "S,I,CR,LF" - Give a result immediatly "Z,CR,LF" - Make zero "S,CR,LF" - give first stable result "R0,CR,LF" - Stop continuos transmission "R1,CR,LF" - Start continuos transmission "S1,CR,LF" - Start weighting "S0,CR,LF" - Stop weighting "D,H,_xx.xxx,CR,LF - set down threshold (f.e: DH_0.700CRLF) "D,H,_,OK,CR,LF" - tha scale reply, that OK "D,H,_,E,S,CR,LF" - tha scale reply, that is fault "U,H,_xx.xxx,CR,LF - set upper threshold (f.e: UH_0.700CRLF) "U,H,_,OK,CR,LF" - tha scale reply, that OK "U,H,_,E,S,CR,LF" - tha scale reply, that is fault * ( string) when the scale is busy reply B It is everything. First I want to save some weight in PLC. Next I would like to set down and upper threshold - it will be +/-2%% of prototype weight After this setup I want to set some output in PLC when weighting will reach value between thresholds. Thank you for some clues, examples. Pawe? Edited by pszczepan

Share this post


Link to post
Share on other sites
Sorry, CPM1A does not support serial communication. You will need at least a CPM2A. You may want to look at the CP1H for the text handling instructions. Hope this will help. Edited by gtsuport

Share this post


Link to post
Share on other sites
I've not yet bought this CPM1A. I can change it to CPM2A. Do I need any adapter for CPM2A. I am still waiting for details about programming. thanks Pawel

Share this post


Link to post
Share on other sites
The CPM2A will have a peripheral port and an RS232 (DB9) port. If you have the CPM1-CIF01 you will be able to both your programming software and the scale connected to the plc at the same time. This would be recommended for troubleshooting your setup. Do you have the CPM programming manual (W353)? You should get the manual, you can download it from this website with this link You want to look at the TXD and RXD instructions. You will need to TXD the string information from your previous post, then use RXD to receive the response. Take a look at this download for examples of the instructions. You will also need the proper cable to the scale. I have attached the pinout information for the DB9 connector. This should get you started. Let us know if you need more information.

Share this post


Link to post
Share on other sites
Hi guys ! I read little bit about TXD and RXD and it is quite clear. I think first I have to put my command in DM area and later I can send this DM using TXD. Could you write example with command "S,CR,LF" give first stable result How I should write MOV to save command in DM area. I have no idea! Thanks for clue. Pawel

Share this post


Link to post
Share on other sites
Her is example for CQM1H and HBM wight modul 2108 CQM1H_HBM2108.cxp maybe help's

Share this post


Link to post
Share on other sites
Hi ! Thanks Zoran for example - it is helpful. Could you add the listings of commands for your scale - I could compare the commands and values which you moved to the DM area. Anyway I would like to know cross-reference between character nad BCD code. f.E. string "CR" - code BCD ....? "S" - code BCD...? Thanks for help Pawel

Share this post


Link to post
Share on other sites
Ok Pawel, I glade my example help you.It work's on several mashin. Data format for HBM komand is all in ASCI, so the value thet move is ASCI. In Programing manual at the end in appendix you find table with values for convertin to ASCI. I need some time too find elevtronic manual for HBM 2108 weight modul and sand to you,but maybe is on their internet too. Best regards.

Share this post


Link to post
Share on other sites
Pawel Her is manual for programing HBM2108 with RS232 port, I houp it helps. ba_we2108_pc_e.pdf

Share this post


Link to post
Share on other sites
Thanks a lot I looked at example and HBM manual and I know much more. The last question is about CR and LF. In HBM's manual I found description CR (0D Hex) LF (0A Hex) In the CPM2A manual I found extended ASCII, but there is not code for CR and LF. So this code for CR - 0D and LF - 0A is correct or just for HBM scale. f.e I attached example code for transmiting "S,CR,LF" - could you check if it is correct? Thanks Pawel

Share this post


Link to post
Share on other sites
... better copy of ascii table ... (google search will find one quick too!) nibroc

Share this post


Link to post
Share on other sites
Hi ! OK - Now I know all ascii codes. I attached the program example for "S,CR,LF" I think I made a mistake. I should add 2 x comma "2C" first MOV inst would be MOV #532C second MOV #0D2C third MOV #0A00 Should I transmit 5 bytes or 6? Thanks Pawel

Share this post


Link to post
Share on other sites
.. Transmit 5 bytes for "S,CR,LF" , (if commas are to be transmitted) - be careful to set TXD to transmit bytes in correct order. Nibroc

Share this post


Link to post
Share on other sites
Hi ! qtsuport attached picture with RS232 pin arrangment. My scale has connector NC516 with pinouts to connect with PC computer: Scale: ----------------------------------PC: 2 (RXD) ------------------------------- 3 (TXD) 3 (TXD) ------------------------------- 2 (RxD) 5 (GND) ------------------------------ 5 (GND) 1-6 - connected ////// /////////// 4-6, 7-8 connected So, which pinout should I use to connect PLC with scale? Thanks Pawel Edited by pszczepan

Share this post


Link to post
Share on other sites
Give this a try. Scale: ----------------------------------PLC: 2 (RXD) ------------------------------- 2 (TXD) 3 (TXD) ------------------------------- 3 (RxD) 5 (GND) ------------------------------ 9 (GND) 1-6 - connected ////// /////////// 4-5 connected Hope this will help. Edited by gtsuport

Share this post


Link to post
Share on other sites
Hi guys ! I started working with CPM2A and my scale and I got problems and questions I prepared cable to connect as qtsuport wrote Scale: ----------------------------------PLC: 2 (RXD) ------------------------------- 2 (TXD) 3 (TXD) ------------------------------- 3 (RxD) 5 (GND) ------------------------------ 9 (GND) 1-6 - connected ////// /////////// 4-5 connected First I prepared settings: Next I made rung to check if connection is OK. Even I disconnect cable from the RS232 port still I do not get any error in rung above - Why - - at least AR 8.04 should make LR 10.01 ON. Anyway I tried to zeroing my scale. When I use soft for PC to send data via RS232 with indicated parameters - everything works - scale is zeroing But when I transmit TXD with character Z (5AHex) and I set CRLF automaticly transmitted at the end I do not get any result What am I doing wrong - ???? Thanks PAwe? Edited by pszczepan

Share this post


Link to post
Share on other sites
I have sometimes had issues with "double differentiated" instructions. You are using a DIFU LR10.09 to initiate the the @TXD instruction. I would probably start by removing the @ from the TXD instruction and see what happens. Also, are you sure that the TXD instruction is being initiated. There are several conditions in the rung, and the LR10.09 is only on for one scan. For troubleshooting, you might want to set up a holding circuit for the logic in the rung initiating the TXD. Use the @TXD to make sure it only transmit once. If the logic turns on and seals, you know that is working. Then you can see if the TXD is working correctly. You did send the "Setting" to the plc and cycle power on the cpu? The "Setting" are only "read" at power up. Hope this will help. Edited by gtsuport

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