Technical FAQs

Ask a Question

How to convert bit to word in scadapack RTU using ISAGRAF ?

Below script sample explains a logical way of converting bit to word and same can used in ST language inside ISAGRAPH to convert.

Value:=0;

    IF bit0 THEN Value := Value + ANA(EXPT(2.0, 0)); END_IF;
    IF bit1 THEN Value := Value + ANA(EXPT(2.0, 1)); END_IF;
    IF bit2 THEN Value := Value + ANA(EXPT(2.0, 2)); END_IF;
    IF bit3 THEN Value := Value + ANA(EXPT(2.0, 3)); END_IF;
    IF bit4 THEN Value := Value + ANA(EXPT(2.0, 4)); END_IF;
    IF bit5 THEN Value := Value + ANA(EXPT(2.0, 5)); END_IF;
    IF bit6 THEN Value := Value + ANA(EXPT(2.0, 6)); END_IF;
    IF bit7 THEN Value := Value + ANA(EXPT(2.0, 7)); END_IF;
    IF bit8 THEN Value := Value + ANA(EXPT(2.0, 8)); END_IF;
    IF bit9 THEN Value := Value + ANA(EXPT(2.0, 9)); END_IF;
    IF bit10 THEN Value := Value + ANA(EXPT(2.0, 10)); END_IF;
    IF bit11 THEN Value := Value + ANA(EXPT(2.0, 11)); END_IF;
    IF bit12 THEN Value := Value + ANA(EXPT(2.0, 12)); END_IF;
    IF bit13 THEN Value := Value + ANA(EXPT(2.0, 13)); END_IF;
    IF bit14 THEN Value := Value + ANA(EXPT(2.0, 14)); END_IF;
    IF bit15 THEN Value := Value + ANA(EXPT(2.0, 15)); END_IF;

Out:=Value;
Was this helpful?
What can we do to improve the information ?