Chinese YGC-FX and YGC-FS modbus Node ID question

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
viktor_au
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

Post by viktor_au »

Have problems communicating with wind vane and wind speed Modbus devices.
Has anyone used those devices?
Thanks.
Last edited by viktor_au on Wed Jan 15, 2020 4:19 am, edited 1 time in total.

User avatar
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

Post by Benj »

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.

viktor_au
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

Post by viktor_au »

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?
Last edited by viktor_au on Wed Jan 15, 2020 4:20 am, edited 3 times in total.

User avatar
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

Post by Benj »

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.

viktor_au
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

Post by viktor_au »

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)
Last edited by viktor_au on Tue Jan 14, 2020 8:46 pm, edited 1 time in total.

viktor_au
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

Post by viktor_au »

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
Attachments
sensors_view_1.jpg
sensors_view_1.jpg (32.83 KiB) Viewed 4563 times
Last edited by viktor_au on Wed Jan 15, 2020 4:21 am, edited 1 time in total.

viktor_au
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

Post by viktor_au »

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.

User avatar
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

Post by Benj »

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.
ModbusWindspeedDemo.fcfx
(10.82 KiB) Downloaded 197 times

viktor_au
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

Post by viktor_au »

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
Attachments
ygc-fx_info.jpg
ygc-fx_info.jpg (80.96 KiB) Viewed 4526 times
Manual.pdf
(307.9 KiB) Downloaded 190 times

Post Reply