Forum Home › Forums › Understanding the Software › Convert decimal to hexadecimal from web browser
- This topic has 41 replies, 4 voices, and was last updated 2 years ago by
kcks66.
-
AuthorPosts
-
July 31, 2023 at 6:48 am #13108
Mikhail
ModeratorHi,
Standard commands expect numeric command result.
To use byte array, change command type to Binary.July 31, 2023 at 6:54 am #13110manjey73
ParticipantMikhail, 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.
July 31, 2023 at 6:58 am #13112manjey73
ParticipantOops, 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.
July 31, 2023 at 7:47 am #13115kcks66
ParticipantHi manjey73,
I am using V5.8.4. Look’s like the result is not the same in both V5 and V6.
Hi Mikhail,
I changed my output channel command type to Binary. That’s great there is no more error message.
However I entered 30 in web browser but the communicator device page show data is unable to be converted (0001 0000)
Pls advice and thank you.
-
This reply was modified 2 years ago by
kcks66.
July 31, 2023 at 7:56 am #13117manjey73
ParticipantFor 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
July 31, 2023 at 7:57 am #13118manjey73
ParticipantWhen entering the value 30 in binary form, it is entered as a string and BitConverter cannot be applied here.
August 1, 2023 at 1:24 am #13122kcks66
ParticipantHi Mikhail,
Pls advice for the decimal to hexadecimal conversion issues.
By the way, I have automatic control module installed, could it be used to do the job?
Thank you.
August 1, 2023 at 5:28 am #13123manjey73
ParticipantYou 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.
August 1, 2023 at 8:57 am #13130Mikhail
ModeratorHi,
What is written in the device manual about sending that command?
What Modbus function is used to send that command?August 1, 2023 at 1:24 pm #13134kcks66
ParticipantHi Mikhail,
It is multiple holding register. Example taken from the manual:
The register address to use is 0002 reference frequency:
August 1, 2023 at 7:08 pm #13137manjey73
Participantpublic 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 workAugust 1, 2023 at 7:50 pm #13138manjey73
ParticipantThe formula does not cause an error on the 5th version, but always sends 0 for some reason
August 2, 2023 at 6:19 am #13139kcks66
ParticipantHi manjey73,
Yes, me too. Always get 0.
By the way, thanks for your effort.
August 2, 2023 at 6:30 am #13140manjey73
ParticipantSo 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.August 2, 2023 at 6:37 am #13141manjey73
Participanttest 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.
-
This reply was modified 2 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.