Click -Move numeric text to variable

keithkyll

Member
Join Date
Jul 2005
Location
Heath, TX
Posts
2,033
I'm reading a scale. RS232 ASCII. TXT1 to TXT20. TXT8 to TXT11 has the numeric value. Leading zeros are spaces. A Copy fails because it doesn't like spaces. Is there an easy way?
 
I struggled with something similar Monday...I was trying to take an integer and break up each digit. I could copy the integer to a series of TXT locations, but then I wanted to copy those individual characters back into integers and could not get the job done. The copy instruction wanted to put two digits in some of the integers as if it was copying two consecutive TXT values. I tried separating them with NULL characters between each digit and that still did not work.

In my situation I only would have the values 0,1,2, and 3 in my digits so I brute forced it with compare contacts.

Pseudo code:
If TXT1 = "0" Math DS1 = 0
If TXT1 = "1" Math DS1 = 1
If TXT1 = "2" Math DS1 = 2
etc.

You might not have to resort to that if you can compare the TXT to a space and then force it to be NULL... I am at home without tools to experiment with.

I think that the very sparse Click instruction set needs to be cluttered up with a few ASCII or string handling instructions.
 
Maybe something like this.
It is not the optimal way, but Paul is correct about the lack of cluttering in the CLICK instruction list.

Code:
          C1
---------]^[-----------------------------+-------------------
                                         | Copy     Single
                                         | 0
                                         | DS101
                                         +-------------------
          C1
---------]^[-----------------------------+-------------------
                                         | For      20
                                         | 
                                         +-------------------

-----------------------------------------+--------------------
                                         |Math      DS101
                                         |DS101 + 1
                                         +-------------------

-----------------------------------------+--------------------
                                         |Copy       Single
                                         |TXT[DS101]
                                         |TXT100
                                         +-------------------
TXT100      " "
---------]=[-----------------------------+-------------------
                                         |Copy       Single
                                         |"0"
                                         |TXT[DS101]
                                         +-------------------

-----------------------------------------+-------------------
                                         |NEXT
                                         |
                                         +-------------------
                                                 C1
-----------------------------------------------(RST)
 
Last edited:
Math Result toWrong Register - Intermittent

Tried "IF TXT8 = " " then TXT8 = 0. Ditto for the next 3. Ended up with all zeros. Not sure why.

Did individual digits. Copy TXT8 to DS102, TXT9 to DS103, ....
That works.
Math box to assemble digits.
[ DS105 + ( DS104 * 10 ) + ( DS103 * 100 ) + ( DS102 * 1000 ) ]
Result to DS12.
Reading RS232 once per second. Math box triggered with a transitional contact from the "Read Success" bit.

Strange problem. In an earlier part of the program, three different math boxes set DS1 to 0, 1, or 3. Using it for a pump status icon. Icon intermittently flashing "Overload Tripped". Pump is off. DS1 should be a solid 0.
With Monitor on, I see DS1 intermittently changing from 0 to 115. The scale is currently at 115 pounds. The math box should be putting the result in DS12, but it is intermittently putting it in DS1! :confused:

I think I'll try changing the DS1 boxes from Math to Copy. If underlying code is leaving result on the stack too long, Copy should put me in a different routine.
 

Similar Topics

What is the simples way to do a double click of a button in a ladder logic. New here and I hope this has not been asked before.
Replies
22
Views
562
I have a program that I am gradually piecing together (my first program). There are 4 cascading timers that turn Y001 and Y001 + Y002 on and off...
Replies
8
Views
562
Complete noob here, using a Click C0-02DD1-D to run a test stand. Requirement is to turn on motor run for X seconds, turn off and dwell for X...
Replies
6
Views
1,127
merry christmas and happy new year i have a click c0-00dr-d and allen bradley 2711c-t3m. can the panelview talk to the click plc via modbus...
Replies
1
Views
255
In an attempt to address a networking issue on my end, I am asking the Click Plus experts if you could verify that I am configuring the email...
Replies
0
Views
355
Back
Top Bottom