Files

27 lines
764 B
Smalltalk
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(*
===============================================================================
Project : PLC_Library
Device : -
Path : Fastwel
Name : AIM731_AO
Type : FUNCTION
===============================================================================
*)
FUNCTION AIM731_AO : WORD
(*
Перевод значений -10..+10 В или 0..+10 В в единицы АЦП выходов модуля AIM731
*)
VAR_INPUT
DAC : REAL; (*Вольты*)
RANGE : BYTE; (*Диапазон: 0 - -10..+10 В; 1 - 0..+10 В *)
END_VAR
(*----- IMPLEMENTATION -----*)
CASE RANGE OF
0 : AIM731_AO := REAL_TO_WORD((DAC + REAL#10.0)/REAL#0.00030518);
1 : AIM731_AO := REAL_TO_WORD(DAC/REAL#0.00015259);
ELSE
AIM731_AO := 0;
END_CASE;
END_FUNCTION