Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on July 12, 2020, 09:52:15 AM

Title: UDT Logic
Post by: RBPLC on July 12, 2020, 09:52:15 AM
Let's say I had 10 pumps as part of  Pump UDT. One of the fields of Pump was .DischargePressure. Is there an "easy" way to compare the discharge pressure of all the pumps to a certain value and set a bit in the event that any one of the pump's discharge pressure went over a certain value? Is there a way to do this with a math function or do I have to have a logic rung to evaluate each discharge pressure or a loop to index through each of the pumps [0-9].DischargePressure. Let me know if this question isn't clear.   
Title: Re: UDT Logic
Post by: franji1 on July 12, 2020, 12:54:28 PM
Call the UDT PumpStruct.  Then create a block size 10 called Pump of type PumpStruct (Pump0 thru Pump9).

FOR V42 0 to 9
MOVE D5 Pump[V42].DischargePressure
SET Pump[V42].Done
NEXT
Title: Re: UDT Logic
Post by: b_carlton on July 12, 2020, 12:59:26 PM
Is the compare value the same for all pumps or does each pump have its own critical value - possibly also stored within the UDT?
Title: Re: UDT Logic
Post by: RBPLC on July 12, 2020, 01:14:12 PM
In this case the compare value would be the same for all pumps which could be stored in the UDT.
Title: Re: UDT Logic
Post by: franji1 on July 12, 2020, 03:18:36 PM
Call the UDT PumpStruct.  Then create a block size 10 called Pump of type PumpStruct (Pump0 thru Pump9).

FOR V42 0 to 9
MOVE D5 Pump[V42].DischargePressure
SET Pump[V42].Done
NEXT

Sorry - misread your post.  Just use a >= instead of the MOVE in the FOR/NEXT loop

RST C99
FOR V42 0 to 9
STRGE Pump[V2].DischargePressure D5
SET C99
BREAK  // once we found one, go ahead and BREAK out of the FOR/NEXT loop
NEXT