SLC500 ASCII strings

SteveC

Member
Join Date
Jul 2003
Location
Merseyside
Posts
13
Firstly great website guys!!

I am having difficulties copying an ascii string from an integer register to an ascii register.
In our system, a barcode reader writes a large ascii string into an intger register. I am trying to take part of the barcode data and put it in an ascii register ready to send to a printer. The idea is to record the six digit sequence number of the product, along with the time and date when there is a fault. I can put the date and time into a string, just not the number.

Ive tried COP #N200:0 #ST9:0 but it shows an error, too long. Whatever i seem to try with this doesnt seem to work, even with putting the string length in N200:0.
Ive tried MOV N200:0 ST9:0 DATA[0] but it moves the decimal equivalent of the ascii string, which is also the same as convert integer to ascii.
Is there something that I have missed? I cant find anything in the AB instruction set manual.
banghead

I am using an SLC5/05 processor.
 
If I'm understanding you, you've got a number, say 47, in N200:0, and you want ST9:0 to have the string "47".

If so, then you need to use the AIC (ASCII Integer to String) instruction. Be aware that this instruction truncates decimal places, and can't handle anything over 32767.

On the other hand, if N200:0 has the number 13367 when view with a decimal radix, or "47" when views as an ASCII radix, then the COP to DATA[0] produces what you want.
 
Thanks for the reply,

Allen Nelson said:
On the other hand, if N200:0 has the number 13367 when view with a decimal radix, or "47" when views as an ASCII radix, then the COP to DATA[0] produces what you want.

This is what i am after. Do you mean COP #N200:0 #ST9:0DATA[0] because i cant get it to accept that.
I tried MOV N200:0 ST9:0 DATA[0] but it moves the decimal 13367 into the ascii register.
I will try again when I get access to the PLC!!

This is the first time I have ever tried manipulating ascii data, and it is quite awkward!!!
 
:)
I read that post before i tried writing it. I tried suggestion no. 2 but it writes the decimal equivalent instead of the ascii.
I could not get the first suggestion to work. I will try again when I get to the PLC again.
Thanks for the replies, when I try again i will post if i can get it to work.
 
Originally posted by SteveC
I tried suggestion no. 2 but it writes the decimal equivalent instead of the ascii.

I could not get the first suggestion to work. I will try again when I get to the PLC again.
Thanks for the replies, when I try again i will post if i can get it to work.

I just played around a bit with the instructions, and they work as I said, with a few oddnesses.

Method #1 - COP instruction.
The COP instruction assumes that 42 words of data will be copied from the N file to the ST. So to get the instruction to work, N200:41 must exist. If it doesn't, the instruction won't work.


Method #2 - MOV to ST.Data[0]

If the LEN of the ST data register = 0, a MOV to ST20:0.DATA[0] shows that the information is there (based on the display in the MOV block), but when you go to the data table, you don't see it, until the LEN is great enough to show the information.

Furthermore, you can't write to the LEN field online (but you can change it with a MOV instruction.)

Are you sure you have the syntax right? For method #2, it's MOV, not COP. And the address is
STfilenumber colon register period DATA bracket ASCII pair bracket

ST20:0.DATA[0]
 
Last edited:
Yup, I got it sorted this morning, as soon as i wrote MOV 6 to the LEN it worked. I think the reason I thought it had copied the decimal equivalent was due to an earlier error and it not clearing down in the register, therefore copying the LEN caused it to start working.
The MOV moves two characters, and by using the MOV DATA[0] then [1] then [2] assembles the ascii string automatically, which is very handy as I thought I would have to assemble using the ASCII string concatenate function (ACN).

Also that oddness with the COP instruction would explain a few things, I was trying to use some spare bits at the end of an integer register.

Thanks for all the help, ive learnt a lot about ASCII data in the last few days!!
 

Similar Topics

I am using SLC500 how do you move ASCII (A10) into a string (ST9)? I tried cop FLL and no go Thanks
Replies
6
Views
2,180
I am taking a barcode scanner ASCII string into a SLC500 (CH0). Works well, but I am having a problem with about five barcodes out of one...
Replies
2
Views
4,579
Hello. I am trying to read in ascii data (from a welder) to a slc504 com port. I have looked at the ascii instruction set but I am not familiar...
Replies
3
Views
5,858
PLC5/SLC500 ASCII export only shows I/O tags which are configured (have description in them) When I click on the Data File I or O I can see other...
Replies
6
Views
7,546
E
In order to communicate with some 3rd party hardware, I need to build a ASCII-string based on HEX values. The basic problem is to have an...
Replies
16
Views
13,835
Back
Top Bottom