String Problem

roxtech

Member
Join Date
Mar 2008
Location
Township Lahore
Posts
198
Hi,
Happy new year. I have a problem in reading string from weighing indicator. I am useing Micrologix 1400 plc for string reading in ST9 file. I read value of ST9.4 is = 009.75^A =009.75^A . My problem is every switch (off to on)of indicator String chr. change its place. For example of one time off to on new value will 09.75^A= 09.75^A=. next time value for on/off indicator .75^A= 09 .75^A= 09. For this I am not able to convert string to intiger properly.
Best regards,
 
The problem occurs because the processor will begin reading when the program starts but this may not be at the same time as the weighing device sends out the string.

Maybe the easiest answer is to have the scale powered off until the program is up and running. If you have an extra output you could use it to drive a relay that powers the scale.

If you have to leave the scale on all the time, you will have to write a routine that synchronizes the PLC reading with the string output by the scale.

To do this read the string into a temporary string buffer first. Then scan the buffer for the location of a known delimiter such as the "^A" in your string (ASC String Search Instruction).

Then you need to extract (AEX String Extract Instruction) the good portion of the string and move it to the string buffer that you are using in your program. You will have to do some math on the result from the ASC instruction to calculate the Index value you use in the AEX instruction.
 
Dear Lancie1,
Yes you are right. According to reading string, I solved problem. But now problem is diffrent string reading extract correctly. But in running plc if I power on/off weighing indicator the final result change. String shift there place for every on/off power at indicator while plc on run. Now i am using ARD command. If I use ARL command will it solve my problem?
Best Regards.
 
Last edited:
But in running plc if I power on/off weighing indicator the final result change.
An easy obvious solution would be to stop powering the weighing indicator on/off - just leave it on while running.

Your PLC can only read and translate the data that comes into its RS232 ASCII buffer. If the data is not communicated correctly, then you have an error in the beginning of your process.
ARL [ASCII Read Line]
Rockwell Software

Use the ARL instruction to read characters from the buffer, up to and including the end-of-line (termination) characters, and store them in a string.

Entering Parameters
Channel is the number of the RS-232 port (must be 0)
Destination is the string element where you want the characters stored.
Control is the address of the control block used to store data for the ARL instruction.

String Length (.LEN) is the number of characters you want to read from the buffer. The maximum is 82 characters. If you specify a length larger than 82, only the first 82 characters will be read. (A 0 defaults to 82.) This is Word 1 in the control block.

Characters Read (.POS) are the number of characters that the processor moved from the buffer to the string (0-82). This field is updated during the execution of the instruction and is display only. This is Word 2 in the control block.

Error is the hexadecimal error code that indicates why the ER bit was set in the control data file. Refer to ASCII Error Codes for an explanation of any displayed error code.

Operation
1 The ARL rung goes from false-to-true, setting the EN (Enable) bit.
2 The instruction is put in the ASCII queue, setting the EU (Queue) bit.
3 The instruction executes and the RN (Run) bit is set.
4 The requested number of characters (including the end-of-line characters) are moved from the buffer to the destination string.
5 The number of characters moved is placed in the position field (control element Word 2).
6 The number in the Characters Read field is continuously updated, and the DN (Done) bit is set once all of the characters have been read. If the processor finds termination characters before reading is done, the number of characters found is stored in the POS word of the control block in addition to setting the DN (Done) bit.
7 When the program scan finds the DN bit set, the processor sets the EM (Synchronous Done) bit.

Execution Errors
The ER (Error) bit is set during the execution of the instruction if:
the instruction is aborted - serial port not in User mode
the modem is disconnected (control line selection is other than NO HANDSHAKING).
the instruction is aborted due to channel mode change.
the UL (Unload) bit is set. The instruction stops executing, but received characters are sent to the destination.
an ACL to clear the receive buffer is executed, removing the ARL instruction from the ASCII queue.
 

Similar Topics

Hello folks, Using AB RSLogix micro.. I have a 6 digit ASCII text string and Im looking to convert the 4 most significant digits to an integer...
Replies
2
Views
1,451
I have a Red Lion G310 that im programming with Crimson 2.0 I have a internal string Tag that needs to be retentive. I have a string text with...
Replies
6
Views
3,953
hello, i am new here and have this problem that have driven me crazy, i have a lot of string edits in one display to control all the string...
Replies
0
Views
1,255
Hi, I have configured a tag of string with length 6. Ie N16:1 to N16:6. When that string is displayed in panel view it is showing in reverse...
Replies
9
Views
2,786
Ran across a problem with the TwinCAT Real_To_String conversion today. I have found that if my real is 0.12345 it converts to '1.2345' It also...
Replies
2
Views
1,728
Back
Top Bottom