[Beremiz-devel] Fwd: Regarding ST compile with iec2c

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Beremiz-devel] Fwd: Regarding ST compile with iec2c

RajJ Jan


---------- Forwarded message ---------
From: Ramakrishnananda karidas <[hidden email]>
Date: Mon, Sep 16, 2019, 2:09 PM
Subject: Fwd: Regarding ST compile with iec2c
To: raj raj <[hidden email]>




---------- Forwarded message ---------


Hello Everyone 

First of all Thank you very much for your efforts with Matiec project. 
Andrej helped me with some information couple of weeks ago. Thank you. I have another thing to know. 
I could cross compiled maitec project to windows on linux. it converts IEC to c fine.

It tested iec2c.exe with ST code in weigh_st.txt in AnnexF folder in Matiec project. it gives compile errors. Could you please give more inputs.  
To me the ST code seems fine. 

ST code form weigh_st.txt and errors below. Not sure if its Not supported issue or something else.

FUNCTION WEIGH : WORD     (* BCD encoded *)
  VAR_INPUT  (* "EN" input is used to indicate "scale ready" *)
    weigh_command : BOOL;
    gross_weight : WORD ; (* BCD encoded *)
    tare_weight : INT ;
  END_VAR
(* Function Body *)
IF weigh_command THEN
  WEIGH := INT_TO_BCD (BCD_TO_INT(gross_weight) - tare_weight);
END_IF ;

END_FUNCTION                     (* Implicit "ENO" *)


Errors in the picture attached.

Thank you and
Best regards
Ram


_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

image.png (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Fwd: Regarding ST compile with iec2c

Beremiz-Devel mailing list


 Hi Ram,

 
 You cannot trust the example code in the standard. It contains many errors.
 In the example you mention it calls the function INT_TO_BCD(), which
according to the standard does not exist.

 In  table 22 of IEC 6113-3 (v2), you get the note:
"The conversion functions *_BCD_TO_** and **_TO_BCD_* shall perform
conversions between
variables of type BYTE, WORD, DWORD, and LWORD and variables of type USINT,
UINT, UDINT
and ULINT (represented by "*" and "**" respectively), when the corresponding
bit-string variables
contain data encoded in BCD format. For example, the value of
USINT_TO_BCD_BYTE(25) would
be 2#0010_0101, and the value of WORD_BCD_TO_UINT (2#0011_0110_1001) would be
369.
"

 All the sample code that calls INT_TO_BDC() (and there are many in that same
standard) are all wrong!




  Cheers,

      Mario.

P.S.: Sorry for the delay in my reply. I was traveling last week and did not
get a chance to reply.





On Tuesday, September 17, 2019 16:33:34 RajJ Jan wrote:

> FUNCTION WEIGH : WORD     (* BCD encoded *)
>   VAR_INPUT  (* "EN" input is used to indicate "scale ready" *)
>     weigh_command : BOOL;
>     gross_weight : WORD ; (* BCD encoded *)
>     tare_weight : INT ;
>   END_VAR
> (* Function Body *)
> IF weigh_command THEN
>   WEIGH := INT_TO_BCD (BCD_TO_INT(gross_weight) - tare_weight);
> END_IF ;
>
> END_FUNCTION                     (* Implicit "ENO" *)



_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel