[Beremiz-devel] Fwd: Regarding ST compile with iec2c
---------- 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 ---------
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 ;
Re: [Beremiz-devel] Fwd: Regarding ST compile with iec2c
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
variables of type BYTE, WORD, DWORD, and LWORD and variables of type USINT,
and ULINT (represented by "*" and "**" respectively), when the corresponding
contain data encoded in BCD format. For example, the value of
be 2#0010_0101, and the value of WORD_BCD_TO_UINT (2#0011_0110_1001) would be
All the sample code that calls INT_TO_BDC() (and there are many in that same
standard) are all wrong!
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 ;
> (* Function Body *)
> IF weigh_command THEN
> WEIGH := INT_TO_BCD (BCD_TO_INT(gross_weight) - tare_weight);
> END_IF ;
> END_FUNCTION (* Implicit "ENO" *)