Jump to content

Recommended Posts


Posted

you dont convert string to byte

Byte is a size in length of bits.

The byte can be on type string or int or whatever. Please use a translator and ask a full question. We cannot help on the above post....or lack there of

Posted

I have tag  data type is String consist of 22 characters, i want to extract one  character and convert into Int to do some calculations, i have used( MID_INT) Function Block extracts a sub-string of characters starting from a certain rank. The result is a character string but I want to put in Array of strings or Array of Bytes and then  take every Byte or character  to do some calculations.
Summarization:
 how I can extract one character from string[n] composed of set of characters (n)  is number of characters TO DO SOME CALCULATIONS 

LOOK

Is  There any function Block can i use it?
Thanks

s.png

SS.png

Posted

I used standard blocks in my example and call all variables with their names.

1) ok, first set values to zero

count:=0;
DO_SOME_CALCULATION := 0;

2)  do a loop for number of elements/characters in your STRING. In your case you have every time 22 characters, so you can just use LEN_ORIGINAL_STRING:=22.

3) you separate every character from STRING - I call it ELEMENT_OF_STRING      as INT

4) you split INT in to 2  Bytes: ELEMENT_BYTE1 and ELEMENT_BYTE2

5) you calculate something that you need with both bytes - I call it DO_SOME_CALCULATION

6) finish :)

 

  • Like 1
Posted

Hi there!

I have a question with AB PLC. My problem: 

I have some raw data...distance for example.When the machine starts,the sensor begins to send the information with the distance values. When data is received it is moved into an array. After the first 5 values the program calculates an average and the result is moved into another array.Currently after receiving the fifth value,thus filling the first array,making the calculation and sending the average to the other array,the program empties the entire first array instead of just always discarding the oldest value of the five,and recalculating the average with the newly arrived value every time.

I tried to made this with ladder diagram using an an fifo load and unload but isnt working. Please help me if anybody can. Thank You.

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
×
×
  • Create New...