Re: [foxboro] HLBL "to the power" expression

  • From: "Brown, Stanley" <stan.brown@xxxxxxxxxxxxxxxxx>
  • To: "foxboro@xxxxxxxxxxxxx" <foxboro@xxxxxxxxxxxxx>
  • Date: Wed, 28 Apr 2010 11:41:47 -0400

That's really sweet code!! Thanks for putting this in the archive!


> -----Original Message-----
> From: Stan Brown [mailto:stanb@xxxxxxxxx] On Behalf Of Johnson, David
> Sent: Wednesday, April 28, 2010 11:04 AM
> To: foxboro@xxxxxxxxxxxxx
> Subject: Re: [foxboro] HLBL "to the power" expression
>
> Peter,
> I think Jeremy Milum asked for that a long time ago, and didn't make
> much headway.
> Here's a way to make a subroutine call and use a CALCA block to give
> you results.  I've done something similar with a CHARC block that
> allows you to characterize a vavle position from HLBL without having to
> recompile the block.
>
> Anyway I re-wrote the POW function in HLBL to allow a negative
> exponent, and included a subroutine that calls the CALCA block.  Here
> are all the details, hope it helps.
>
> Regards,
> David
>
>
> NAME   = TEST:FUNCTION
>   TYPE   = CALCA
>   DESCRP = RAISE A NUMBER TO A PWR
>   ...
>   RI01   = :POWER2.RO0010
>   RI02   = :POWER2.RO0011
>   ...
>   BI01   = :POWER2.BO0001
>  ...
>   STEP01 = IN BI01       ;ARE WE ASKED TO CALC?
>   STEP02 = BIF 10        ;IF NOT GOTO 10
>   STEP03 = EXP RI01 RI02 ;RAISE RI01 TO THE RI02 PWR
>   STEP04 = OUT RO01      ;HERE'S THE ANSWER
>   STEP05 = SET BO01      ;TELL SEQ CODE IT'S HERE
>   STEP06 = EXIT
>   STEP07 =
>   STEP08 =
>   STEP09 =
>   STEP10 = CLR BO01      ;NOT ASKED TO RUN
>   STEP11 =               ;SO DON'T TRUST THE RESULT
>  ...
>   STEP50 =
> END
>
>
>
> NAME   = TEST:POWER2
>   TYPE   = IND
>   DESCRP = CALCULATE A POWER
> ...
>   BI0001 = :FUNCTION.BO01
>  ...
>   RI0010 = :FUNCTION.RO01
>  ...
>  END
>
>  INDEPENDENT_SEQUENCE{*******************************
>           **                                      **
>           **       INDEPENDENT SEQUENCE           **
>           **         CONTROL BLOCK                **
>           **                                      **
>           *****************************************}
> CONSTANTS
>
> VARIABLES
>
> USER_LABELS
>
>
> /* This Subroutine makes a "call" to a CALCA block to */
> /* raise a number to a power.                         */
>
> SUBROUTINE Calc_it ( IN Number    : R
>                      IN Exponent  : I
>                      INOUT Answer : R)
>
> STATEMENTS
>  /* We are sending the values via RO0010 & RO0011 */
>  /* This would look better if we used USER_LABELS */
>  /* but adds another layer to work through on the */
>  /* list                                          */
>  RO0010 := Number;
>  RO0011 := Exponent;
>  /* Set the trigger with a secured connection */
>  BO0001 := TRUE;
>  /* Make sure the calc block processes this before we */
>  /* return the answer                                 */
>  WAIT UNTIL (BI0001);
>  Answer := RI0010;
>  BO0001 := FALSE;
> ENDSUBROUTINE
>
>
>
>
> /* This subroutine calculates a number raised to a power */
> SUBROUTINE POW ( IN Number    : R
>                  IN Exponent  : I
>                  INOUT Answer : R)
>
> VARIABLES
>  Original_Exp : I;
>
> STATEMENTS
>   Original_Exp := Exponent;
>   Exponent := ABS(Exponent);
>   Answer := 1;
>   WHILE (Exponent > 0) DO
>     Answer   := Answer * Number;
>     Exponent := Exponent - 1;
>   ENDWHILE;
>
> IF (Original_Exp < 0) THEN
>   Answer := 1/Answer;
> ENDIF;
>
> ENDSUBROUTINE
>
>
> STATEMENTS{*****************************************
>           *      Specify the statements here       *
>           *****************************************}
>
> CALL POW (RI0001, II0001, RO0001);
> CALL Calc_it (RI0001, II0001, RO0002);
> ENDSEQUENCE
>
>
>
>
> Confidentiality Notice:
>
> The information contained in this message is private and confidential.
> This information is intended only for  the individual or entity named
> above.  If the reader of this message is not the intended recipient,
> you are hereby notified that any use, review, dissemination,
> distribution, copying or action taken based on this message or its
> attachments, if any, is strictly prohibited.  If you are not the
> intended recipient, please contact the sender by reply email and delete
> or destroy all copies of this message and any attachments.  Thank you.
>
>
> _______________________________________________________________________
> This mailing list is neither sponsored nor endorsed by Invensys Process
> Systems (formerly The Foxboro Company). Use the info you obtain here at
> your own risks. Read http://www.thecassandraproject.org/disclaimer.html
>
> foxboro mailing list:             //www.freelists.org/list/foxboro
> to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
> to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
>


The information contained in this message and any attached files may be 
privileged and/or confidential and protected from disclosure. If you are not 
the intended recipient, any disclosure, copying, distribution or use of any of 
the information contained in or attached to this transmission is strictly 
prohibited. If you have received this transmission in error, please so notify 
the sender immediately without reading it. Also, please promptly destroy the 
original transmission and its attachments. Any views or opinions presented in 
this message or attachments are those of the author and do not necessarily 
represent those of KapStone Paper and Packaging Corporation or its subsidiaries.
 
 
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
 
foxboro mailing list:             //www.freelists.org/list/foxboro
to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
 

Other related posts: