Forum Replies Created
-
AuthorPosts
-
manjey73Participanttest script
public byte[] NewFreq1() { return new byte[] { 0x00, 0x01, CmdData[0], CmdData[1]}; }Using string input, with the Binary command type, you can accurately convert the entered digits to uint and add them to the block of data being sent.
manjey73ParticipantSo it’s strange to me that when sending a Cmd command, it is a double, and in theory, returning a double formed from the required bytes, we should send something other than say 30, which we enter. But for some reason nothing happens.
However, if we use Binary, we can send anything in a byte array, but then we need to somehow convert the received value first into a string, then again into the required bytes, etc.
I don’t know if it is available for formulas in the 5th version of the ScadaUtils function to do this.
Via string here (not Hex) I haven’t tried it yet, there you can use the language to form an array according to the idea.
manjey73ParticipantThe formula does not cause an error on the 5th version, but always sends 0 for some reason
manjey73Participantpublic double NewFreq() { byte[] freq = BitConverter.GetBytes((uint)Cmd*100); byte[] res = new byte[] { 0x00, 0x01, freq[1], freq[0], 0x00, 0x00, 0x00, 0x00 }; return BitConverter.ToDouble(res, 0); }Return the command type to Standard and try the following formula
It may be necessary to play with the location of bytes in the array
byte[] res = new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, freq[1], freq[0] };
But in theory, the first option in the formula should work
manjey73ParticipantYou would change version 5 to version 6, some things are much simpler there
If I’m not mistaken, on the 5th version in Binary mode, when entering HEX, a byte array is returned, and this should be taken into account in the formula.
manjey73ParticipantWhen entering the value 30 in binary form, it is entered as a string and BitConverter cannot be applied here.
manjey73ParticipantFor the 5th version, the formula is likely to be different, since you are forced to enter a HEX value.
The 6th version is somewhat more flexible in terms of formula implementations
manjey73ParticipantOops, do you have Scada version 5? I don’t know if it’s possible to do this on the 5th version, I haven’t tried it before.
manjey73ParticipantMikhail, a person wants to drive just a frequency number, but at the same time he needs a command to be added to the byte array that allows changing this frequency. The formula that I have given is working, it is simply necessary to provide a command in the device template to get it. We did this with recording time in several registers.
manjey73ParticipantIs this your Modbus device ?
manjey73Participant| 31.07.2023 08:59:05 | Code=freq, Data=00010BB8 |
Enter 30 in Web.
Although no, it seems to be enough, I entered 30 into the Web and received the following data in the sent command.
manjey73ParticipantYes, there is another nuance, in the formula it is necessary to additionally convert the number to HEX. We need to think about how to do this… Just using BitConverter is not enough for this
manjey73ParticipantFor me, the formula does not cause errors during compilation. And the result of sending from the Web is shown below. It may be necessary to rearrange the bytes in the formula. Well, configure the command in the Modbus template as multiple for several registers in addition to the other channels.
manjey73Participantpublic byte[] NewFreq()
{
byte[] freq = BitConverter.GetBytes)(uint)Cmd*100);
return new byte[] { 0x00, 0x01, freq[1], freq[0])
}I haven’t checked, but something like this
manjey73ParticipantYou need to use the formula in the control channel that will send the generated CmdData
-
AuthorPosts