Forum Replies Created
-
AuthorPosts
-
manjey73ParticipantOptions for Standard commands to use formulas for IEEE (float)
Add to base formula
public double fRevers (int rev)
{
float q = Convert.ToSingle(CmdVal);
byte[] f = new byte[4];
byte[] o = new byte[4];
f = BitConverter.GetBytes(q);
Array.Copy(f,0,o,0,4);
if (rev == 1)
{
Array.Copy(f, 0, o, 1, 1);
Array.Copy(f, 1, o, 0, 1);
Array.Copy(f, 2, o, 3, 1);
Array.Copy(f, 3, o, 2, 1);
}
Array.Resize(ref o, 8);
Double ou = BitConverter.ToDouble(o,0);
return ou;
}Use the formula in the control channel – fRevers(1) Command type Standard, suitable for some Modbus devices.
Or try to use this formula
LINK{ buf[1], buf[0], 0, 0, 0, 0, 0, 0 }and change the variable type on input
ushort val = (ushort)Cmd;
manjey73ParticipantTicks
————————————
public static long Ticks()
{
DateTime now = DateTime.Now;
long time = now.Ticks/10000;
return time;
}
———————————–You want to work Ton
-
This reply was modified 8 years, 8 months ago by
manjey73.
manjey73Participanthttps://github.com/Manjey73/OpnenKPs/tree/master/KpRpi3 (readme – online translate)
https://github.com/Manjey73/OpnenKPs/releases/tag/KpRpi3 (use gpio 5-27, in archive use all gpio)
manjey73Participanthttps://s30.postimg.org/9etq90vmp/RStrig_Reset.png
Base formulas
————————————————
ResetCnl
————————————————
double ResetCnl(double val, int InCnl)
{
bool q = val > 0;
if (q)
{
q = !q;
CnlValSet(InCnl, 0);
}
return Convert.ToDouble(q);
}
————————————————-
RStrig
————————————————-
double RStrig (double set, double res)
{
bool s = set > 0;
bool r = res > 0;
bool q = r ? q = false : Val(CnlNum) > 0 || s;
return Convert.ToDouble(q) ;
}
—————————————————
Ton
—————————————————
int[] TonNum = new int[1];
long[] TonST = new long[1];
bool[] TonFlag = new bool[1];
public double Ton(double TonIn, long TonPT)
{
long ET = 0L;
bool q = Val(CnlNum) > 0;
bool ton_in = TonIn > 0;int res = Array.IndexOf(TonNum, CnlNum);
if (res == -1)
{
res = TonNum.Length;
Array.Resize(ref TonNum, res+1);
Array.Resize(ref TonST, res+1);
Array.Resize(ref TonFlag, res+1);
TonNum[res] = CnlNum;
}if (!ton_in)
{
q = false;
TonFlag[res] = false;
TonST[res] = 0L;
}
else
{
if (!TonFlag[res])
{
TonFlag[res] = true;
TonST[res] = Ticks();
}
else
{
if (!q) ET = Ticks() – TonST[res];
}
if (ET >= TonPT) q = true;
}
return Convert.ToDouble(q);
}
———————————————————I use formulas and module of automatic control to re-send the command
May still need to make the formula entry a bit to the desired value, if necessary.Sorry for my English, is machine translation
-
This reply was modified 8 years, 8 months ago by
-
AuthorPosts