Siemens Sorting Routine

jburda

Member
Join Date
Aug 2005
Location
Pennsylvania
Posts
1
I have an application where I read 10 pressure readings from 10 diff pressure transmitters. When commanded to do so, I need to get my values, sort the list based on highest to lowest, and set bits based on which transmitter had the highest reading.

I have developed a function block to do the sorting that is cumbersome and was looking for a better way to do this.
 
If it is just necessary to take action on the highest value just work youre way through the list and remember the location of the highest value. (It is not a lot of data so complex datastructures to speed up the search are unneccacery) I'll give an example in basic.

item_nr=0
largets_found_so_far=0




For nr=1 to Nr_of items
if list[nr]>largest_found_so_far then
largest_found_so_far = list[nr]


Item_nr = nr


end if




next nr



''Action based on highest reading
..
..

What to do with two exactly the same values?

For Siemens you will need to use pointers to make this happen. Or a just make a number of compare's.
 
Last edited:
i did not try it but i would think in this way


  • create a table in a data block
  • put the first reading in the table using att function from the ti lib
  • for the rest of the readings use the cdt function to locate the first value equal than or grater than the reading (2-10)
  • if the returned index value is within the table then this value is grater than the values in the table , in this case use the function iblokmov to move the table down , then add the value in the empty space (u need to use indirect addressing to locate it)
  • if the return value is not within the table then add the value to the table using att
it is pretty complicated , please send me the result if u success in this way or another
 

Similar Topics

Hello, I have a CPU 317-2DP Firmware Version V2.1.8. In TIA Portal only V2.6 is available, and there is no option to upgrade FW. Then I open it...
Replies
2
Views
98
HI everyone, i am new to Siemens plc programming and i am in need of some help. yesterday we had an S7-1200 CPU 1214C fail to turn on an output to...
Replies
9
Views
300
Hi PLC people, think about this scenario: The PLC is somehow connected to the same network with the facilities` network. Then someone connects to...
Replies
2
Views
106
Hello everyone, I've had this issue for the last 2 days where I try to assign the profisafe address to an IO block (6ES7 146-6FF00-0AB0) but when...
Replies
5
Views
160
Hello, good morning, I have been having two problems with the Tia Portal software. The first is that I have installed it on my computer and...
Replies
5
Views
197
Back
Top Bottom