Have problems communicating with wind vane and wind speed Modbus devices.
Has anyone used those devices?
Thanks.
Chinese YGC-FX and YGC-FS modbus Node ID question
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Chinese wind YGC-FX and YGC-FS modbus id question
Hello,
No problems I'm aware of but would be interested to know how you get on with them if you have a go.
Wind speed is something I'm interested in as I'm considering building a micro wind turbine, send us a link if you find a good product.
No problems I'm aware of but would be interested to know how you get on with them if you have a go.
Wind speed is something I'm interested in as I'm considering building a micro wind turbine, send us a link if you find a good product.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 44 times
- Been thanked: 60 times
- Contact:
Re: YGC-FX =Slave 02, YGC-FS = Slave 01
I could move forward a bit by using the English manual.
The manual was sent to me by the Chinese seller (after a few emails to him).
The manual says about CRC:
01 Success, 00 Fail.
It didn't work.
Looks like 0=OK, 1=Fail.
-------------------
I've got some results with:
Read Holding register 0x00, slave id=0x01, regi_n = 0x01.
And I have a question.
The bytes N4 and N5 have the data.
The manual say:
The sensor returns data 0x0026 converted to decimal 38, indicating a wind speed of 3.8m / s, with a decimal place.
How can I join two bytes and convert them to decimal?
The manual was sent to me by the Chinese seller (after a few emails to him).
The manual says about CRC:
01 Success, 00 Fail.
It didn't work.
Looks like 0=OK, 1=Fail.
-------------------
I've got some results with:
Read Holding register 0x00, slave id=0x01, regi_n = 0x01.
And I have a question.
The bytes N4 and N5 have the data.
The manual say:
The sensor returns data 0x0026 converted to decimal 38, indicating a wind speed of 3.8m / s, with a decimal place.
How can I join two bytes and convert them to decimal?
Last edited by viktor_au on Wed Jan 15, 2020 4:20 am, edited 3 times in total.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Chinese wind YGC-FX and YGC-FS modbus id question
Hello,
To join two bytes together you would do this.
IntVar = ( MSB << 8 ) + LSB
Which is a more efficient way of writing.
IntVar = ( MSB * 256 ) + LSB
If you're reading a Modbus register via the component then it's a 16-bit value already. The above is already done for you.
No conversion required between hex and decimal, to the micro they are the same binary value.
To join two bytes together you would do this.
IntVar = ( MSB << 8 ) + LSB
Which is a more efficient way of writing.
IntVar = ( MSB * 256 ) + LSB
If you're reading a Modbus register via the component then it's a 16-bit value already. The above is already done for you.
No conversion required between hex and decimal, to the micro they are the same binary value.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 44 times
- Been thanked: 60 times
- Contact:
Re: Chinese wind YGC-FX and YGC-FS modbus id question
Create an int from lsb and msb
I am not sure which one is received first.
MSB should be 1st, isn't it?
And only after I add the LSB byte.
It is not easy to translate Chinglish manual to English.
Example of manual page:
ModBus CRC check steps
1. Preset 16-bit register hexadecimal FFFF, said the register for
the CRC register;
2. The first 8-bit data and CRC register low or XOR, the result
placed in the CRC register;
3. The contents of the register to the right one (toward the low),
with 0 to fill the most significant bit, check the lowest bit;
4. If the least significant bit is 0: Repeat step 3 (shift again) If
the least significant bit is 1: The CRC register is XOR'ed
with the polynomial A001 (1010 0000 0000 0001)
5. Repeat steps 3 and 4 until 8 shifts to the right so that the
entire 8-bit data is completely processed;
6. Repeat step 2 to step 5 for the next 8-bit data processing;
7. The resulting CRC register is the CRC code (the resulting
CRC code is low after high)
I am not sure which one is received first.
MSB should be 1st, isn't it?
And only after I add the LSB byte.
It is not easy to translate Chinglish manual to English.
Example of manual page:
ModBus CRC check steps
1. Preset 16-bit register hexadecimal FFFF, said the register for
the CRC register;
2. The first 8-bit data and CRC register low or XOR, the result
placed in the CRC register;
3. The contents of the register to the right one (toward the low),
with 0 to fill the most significant bit, check the lowest bit;
4. If the least significant bit is 0: Repeat step 3 (shift again) If
the least significant bit is 1: The CRC register is XOR'ed
with the polynomial A001 (1010 0000 0000 0001)
5. Repeat steps 3 and 4 until 8 shifts to the right so that the
entire 8-bit data is completely processed;
6. Repeat step 2 to step 5 for the next 8-bit data processing;
7. The resulting CRC register is the CRC code (the resulting
CRC code is low after high)
Last edited by viktor_au on Tue Jan 14, 2020 8:46 pm, edited 1 time in total.
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 44 times
- Been thanked: 60 times
- Contact:
Re: Link to YGC-FX and YGC-FS
Re: send us a link if you find a good product.
The products I have are for weather station.
This is the link
https://www.aliexpress.com/item/3294319 ... 4c4dKO7DOu
The products I have are for weather station.
This is the link
https://www.aliexpress.com/item/3294319 ... 4c4dKO7DOu
- Attachments
-
- sensors_view_1.jpg (32.83 KiB) Viewed 4572 times
Last edited by viktor_au on Wed Jan 15, 2020 4:21 am, edited 1 time in total.
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 44 times
- Been thanked: 60 times
- Contact:
Chinese YGC-FX and YGC-FS modbus Node ID question
How can I change the node/slave number in this Chinese wind sensor?
FC8 has two macros with preset functions, but they ask for the Slave ID.
I have to change two wind devices id from 01 to 16 and 17.
Would be great is somebody can help me.
FC8 has two macros with preset functions, but they ask for the Slave ID.
I have to change two wind devices id from 01 to 16 and 17.
Would be great is somebody can help me.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Chinese YGC-FX and YGC-FS modbus Node ID question
Hello,
Changing the device address is something only the manufacturer will be able to describe how to do. It may be set via jumpers or set via modbus commands or may not even be possible.
For modbus MSB is first and the CRC is automatically calculated for you.
Looks like you would perform a ReadInputRegister or ReadHoldingRegister command with the correct slave and register address and then use the GetResponseInt function to read back the 16-bit data with an Index parameter of 3 I beleive.
Here's a very basic example.
Changing the device address is something only the manufacturer will be able to describe how to do. It may be set via jumpers or set via modbus commands or may not even be possible.
For modbus MSB is first and the CRC is automatically calculated for you.
Looks like you would perform a ReadInputRegister or ReadHoldingRegister command with the correct slave and register address and then use the GetResponseInt function to read back the 16-bit data with an Index parameter of 3 I beleive.
Here's a very basic example.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 342
- Joined: Fri Jan 26, 2018 12:30 pm
- Location: South Australia
- Has thanked: 44 times
- Been thanked: 60 times
- Contact:
Re: Chinese YGC-FX and YGC-FS modbus Node ID question
Thank you Ben
I have contacted Chinese manufacturer with node id write function question. I hope I will solve this problem.
------------------
Wind vane YGC-FX update
I have contacted Chinese manufacturer with node id write function question. I hope I will solve this problem.
------------------
Wind vane YGC-FX update
- Attachments
-
- ygc-fx_info.jpg (80.96 KiB) Viewed 4535 times
-
- Manual.pdf
- (307.9 KiB) Downloaded 190 times