RegIDX
--------------------------------------
0x0006 Byte1 Voltage RMS BYTE_L
0x0007 Byte2 Voltage RMS BYTE_H
..
..
0x000E Byte9 Current RMS BYTE_L
0x000F Byte10 Current RMS
0x0010 Byte11 Current RMS
0x0011 Byte12 Current RMS BYTE_H
---------------------------------------
Total Bytes 6
simple 'byte'Arr doings:
MyByteArr[0] contains the byte1 from 0x0006 BYTE_L
MyByteArr[1] contains the byte1 from 0x0007 BYTE_H
--------------------------------------------------
MyByteArr[2] contains the byte1 from 0x000E BYTE_L
MyByteArr[3] contains the byte1 from 0x000F
MyByteArr[4] contains the byte1 from 0x0010
MyByteArr[5] contains the byte1 from 0x0011 BYTE_H
The Uart0 Records the RegValis
The Uart1 Sends the Stored RegValis
Like it need, MSB or LSB
means Byte_H or Byte_L at first
// Send Voltage RMS
RS232.SendChar(MyByteArr[1]
RS232.SendChar(MyByteArr[0]
// Send Current RMS
RS232.SendChar(MyByteArr[5]
RS232.SendChar(MyByteArr[4]
RS232.SendChar(MyByteArr[3]
RS232.SendChar(MyByteArr[2]
..
depth thinking
read this
FlowChart sendStructs
If you use your ByteRecord
think you created like this:
Code: Select all
struct RecordFormat {
byte VoltageRMS[2];
byte CurrentRMS[4];
//.more.
//.more.
} myMCPData;
you can give your struct elements your read valis by pointer, example,
like the example with Struct Send,or you can simple record
without pointer and use the Variable in ModBus Component
like it is, because you do simulation too,
because send structs just in time not supported to simulate i think.
// without pointer
we have Uint, we need 2 bytes for VoltageRMS and 4 Bytes for CurrentRMS
so you can store in an uintArr[6] all valis you need
like you need to catch the MODBOS Data in this steps,
you get in one read 2 bytes as Value for Voltage RMS if you querry
by the start address (RegAddress VoltageRMS) and read 2 counts,
then you need a uintarr[2] to point RegValue to
myVoltageRMS[2]
and if you querry by the start address (RegAddress CurrentRMS)
you read 4 counts, so you need here a uintarr[4]
myCurrentRMS[4]
because the Regadress index is not ++
so you can not read in one step all two data
in one uintArr[6] so must help like this:
example
your first data lies on RegAddress
0x0006
and your last data lies on RegAddress
0x0012
you know
LSB from Voltage RMS is the Byte1
MSB from Voltage RMS is the Byte2
LSB from Current RMS is the Byte9
MSB from Current RMS is the Byte12
read with modbus component at adress 0x0006
12 counts in your totaluintArr[12]
then you have for
totaluintArr[0] Byte 1 LSB Voltage RMS
totaluintArr[1] Byte 2 MSB Voltage RMS
totaluintArr[8] Byte 1 LSB Current RMS
totaluintArr[9] Byte 2 Current RMS
totaluintArr[10] Byte 3 Current RMS
totaluintArr[11] Byte 4 MSB Current RMS
then send the valis with Uart from the stored elements
with simple
Code: Select all
// Voltage RMS MSB
RS232.SendChar(totaluintArr[1])
RS232.SendChar(totaluintArr[0])
// Current RMS MSB
RS232.SendChar(totaluintArr[11])
RS232.SendChar(totaluintArr[10])
RS232.SendChar(totaluintArr[9])
RS232.SendChar(totaluintArr[8])
with structs possible too
Code: Select all
// MSB
// Voltage RMS
RS232.SendChar(myMCP.VoltageRMS[1]);
RS232.SendChar(myMCP.VoltageRMS[0]);
// MSB
// Current RMS
RS232.SendChar(myMCP.CurrentRMS[3]);
RS232.SendChar(myMCP.CurrentRMS[2]);
RS232.SendChar(myMCP.CurrentRMS[1]);
RS232.SendChar(myMCP.CurrentRMS[0]);
hope this helps
happy weekend!
best wishes
rudi
