Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII extract + or -

Status
Not open for further replies.

Wattman

Electrical
May 2, 2001
24
I have a project, which utilizes an MVI46-GSC that is basically a RS232 serial communications card. (RSLogic, SLC505 Processor) I'm receiving data from a multiplexer, which communicates to up to 4 other field devices. The multiplexer in only capable of sending the information in an ASCI format. I have established communications and worked out the logic to extract from the ASCII string a value which is metric, and the logic converts this seven character text value (floating decimal example 000.001 or 0.00001 or 00000.0) to an integer then into a floating decimal point value all of which works.

The problem is within the string the value will also contain the polarity of the value "+ or -" it is always the character just before the value. I cannot determine how to identify or detect when this value changes.

If I extract the value with an AEX command then move it to an integer with a AIC command it shows up within the integer as "3356" for both a + and - value. Does anyone know how to I can determine the state of the value + or - from a ASCII string (also a : equals a value of 3320)

Any help greatly appreciated
Thanks in advance
 
Replies continue below

Recommended for you

I made a mistake it appears that converting a + or - to an integer does not return a value of 3356 and I had thought a : equaled 3320. I'm unsure of where or how I came up with these values. After testing more placing a text value of + in a text string and sending it to a integer returns no value it remains at it's former value

HELP still needed
Please advise
 
Does the ASCII string come into the SLC in Hex or ASCII?

For example, a value that is +1000
in ASCII = +1000
in Hex = 2B 31 30 30 30
in SLC = +1000 or \2B \31 \30 \30 \30

a value that is -1000
in ASCII = -1000
in Hex = 5F 31 30 30 30
in SLC = -1000 or \5F \31 \30 \30 \30

If you do a move from String (ST:) register to an Integer (N:) register the processor should automatically show the sign of the number based on the string read from the buffer.



 
The string is in ASCII

I have another computer setup and monitoring the data as it comes into the MVI46-GSC card serial port via Hyper-Terminal. It is raw and before it is placed in the M0 area of memory then moved to the processor into a ST:
An exact example of what I see is
[1][:][+][0][0][0][.][0][0][7][CR]

[1]= Input channel
[:]= Sepatator
[+]= Polarity
[0]= Value six digits with floating decimal
[0]= Value
[0]= Value
[.]= Value
[0]= Value
[0]= Value
[7]= Value
[CR] Line Terminator

There may be a way that I could move the data directly from the M0 area into something other than a String text??

 
The destination of an ARD (ascii read) must be a string register. No way around this. What does the string look like when it goes into the ST register in the SLC (exaclty)?
 
Field device reads -0.393

Hyper Terminal sees
[1][:][-][0][0][0][.][3][9][3][CR]

ST9:0 contains
1:-000.393^M\00


Exactly

 
Try using an AEX (extract) from the ST file to a Float file (F:). In the AEX function the Index=3 and the Number=8. When the number goes to the float register the sign of the number should be included.
 
As far as I know you cannot extract from an ST and move the value directly to a floating-point number.

I'm using an AEX and moving what I need to another ST word then converting the characters into an Integer with an ACI

Hey !!!! :-0 :) I just figure it out thanks to your help

1 : - 0 0 0 . 3 9 3 ^ M \ 0 0

I extracted the sign and all of the values before the decimal result=(-000)
Then extracted the values after the decimal (393)
Then
Used an ACN to put them back together in another ST
Result=(-000393)
Then simply converted it to an integer the sign follows along
Result=(-393)
I lose any zeros that are in front, but it does not matter I simply used the sign bit S:0/3 to set the actual floating point to a negative value when it occurs.

Thanks for you help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor