Professional Documents
Culture Documents
RS422
Procedureisasfollowing:
Youhavetoget3valuesback,X1,X2,andX3foreachstack,thencalculateMx
Foreachmeterboxthereare2stacks
TocalculateMC:MC=((Mx2.3*Zcal))*A2+B2
Where:
Mx=rawMC
A2=gain
B2=offset
Zcal=zerocalibrationvalue
zerocalibrationvaluewillbeexplainedattheendofthisdoc
Startwitha2=0.04,B2=3
Togetavaluefrommeterbox
1Send3bytestosetup
meterboxwillsendtwobytesback,discardthese2bytes
2Wait800milliseconds
3Sendthreebytes,then2byteswillbesentback
4CalculateX1from2bytes
Repeatsteps1to4forX2andX3
ThenCalculateMx(rawMC)
Thedetailedprotocol
getX1:
Sendthreebytestosetup
AAi,CCiandBBiarethe3bytes
AAi=1(adresbyte,setadress=1)
CCi=29
BBi=0
pause50milliseconds
Send3bytes
{
send3bytes
Codeexample:
Serial1.WriteChar(chr(AAi))
Serial1.WriteChar(chr(CCi))
Serial1.WriteChar(chr(BBi))
NOTE:sendtheactualbytevalue!
Eg.Char(65)=A,thebytevalueis65andtheASCIIvalueisA
For29donotsend2andthen9characters
}
Wait800ms1000milliseconds
Clearthecommsbuffer(therewillbe2bytesreceivedbutdisregard)
AAi=1
CCi=9
BBi=0
Send3bytes
Nowreceive2bytes:
Convert
Av:=9.7968e3*Rbyte[1]+38.269e6*Rbyte[2]
X1:=1.60616*2.5*Av
where
st
Rbyte[1]:=1
byte
nd
Rbyte[2]:=2byte
GetX2:
Pause50ms
SendthreebytestosetupX2
AAi=1
CCi=93
BBi=0
Send
Wait800ms1000milliseconds
Clearthecommsbuffer(therewillbe2bytesreceivedbutdisregard)
AAi=1
CCi=73
BBi=0
Send
Nowreceive2bytes:
Convert
Av:=9.7968e3*Rbyte[1]+38.269e6*Rbyte[2]
X2:=1.60616*2.5*Av
GetX3:
Pause50ms
SendthreebytestosetupX2
AAi=1
CCi=221
BBi=0
Send
Wait800ms1000milliseconds
Clearthecommsbuffer(therewillbe2bytesreceivedbutdisregard)
AAi=1
CCi=201
BBi=0
Send
Nowreceive2bytes:
Convert
Av:=9.7968e3*Rbyte[1]+38.269e6*Rbyte[2]
X3:=1.60616*2.5*Av
NowcalulateMx
Stack2
GetX1:
Pause50ms
SendthreebytestosetupX1
AAi=1
CCi=61
BBi=0
Send
Wait800ms1000milliseconds
Clearthecommsbuffer(therewillbe2bytesreceivedbutdisregard)
AAi=1
CCi=41
BBi=0
Send
Nowreceive2bytes:
Convert
Av:=9.7968e3*Rbyte[1]+38.269e6*Rbyte[2]
X1:=1.60616*2.5*Av
getX2:
Pause50ms
SendthreebytestosetupX2
AAi=1
CCi=125
BBi=0
Send
Wait800ms1000milliseconds
Clearthecommsbuffer(therewillbe2bytesreceivedbutdisregard)
AAi=1
CCi=105
BBi=0
Send
Nowreceive2bytes:
Convert
Av:=9.7968e3*Rbyte[1]+38.269e6*Rbyte[2]
X2:=1.60616*2.5*Av
getX3:
Pause50ms
SendthreebytestosetupX2
AAi=1
CCi=253
BBi=0
Send
Wait800ms1000milliseconds
Clearthecommsbuffer(therewillbe2bytesreceivedbutdisregard)
AAi=1
CCi=233
BBi=0
Send
Nowreceive2bytes:
Convert
Av:=9.7968e3*Rbyte[1]+38.269e6*Rbyte[2]
X3:=1.60616*2.5*Av
CalculateMx
proceduretoCalculateMx
R2:=4.70e3
X3:=X3*0.49
ifX3<2.917thenth_b:=15.88*X317.844
elseth_b:=22.831*X338.1
w2:=2*pi*37.5e3
th_b:=th_b/180*pi
a:=X2*cos(th_b)//th_bisnotdegrees,itsinradians
b:=X2*sin(th_b)