Hi, The problem is that the protocol used by the Huanyang HY02D223B is not Modbus compliant. As I believe it, the implementers of the Modbus software in the VFD have not understood the Modbus spec, and incorrectly implemented. it.
From a post on the Machsupport forum I wrote; http://www.machsupport.com/forum/index.php/topic,10300.0.html ------------------------------------------------------ Yes the spec (Huanyang) says the modbus serial pdu contains Address Function Code Data CRC BUT, you need to see what the definition of the Data field contains for each function code. For that you need to look at the document http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf For instance Function code 03 (Read holding registers) on page 15 shows the Data field contains 2 sub-fields as shown below. Data.starting address 2 bytes = 0x0000 - 0xFFFF Data.quantity of Registers 2 bytes = 0x0000 - 0x7D And, the Data field in the response to this contains; Data.bute count 1 byte = 2 x N Data.register valuess N x 2 bytes = 0x0000 - 0xFFFF where N is the quantity of registers. --------------------------------------------------------------------- Basically, they have stuffed up the implementation. That said you could write something to talk to the Huanyang. Cheers, Peter. Kirk Wallace wrote: > On Sat, 2009-05-02 at 09:57 +0000, Jayson Wallis wrote: >> Hi All, >> >> I am currently at wits end and need some help from some people more >> knowledgeable than I. >> >> For the past 2 weeks I have been trying to customize GS2_vfd.c (as >> well as modbus.c/.h) to work with my VFD which is a Huanyang >> HY02D223B. (The manual is on CNCzone >> http://www.cnczone.com/forums/attachment.php?attachmentid=79285&d=1239132143) >> >> Since I have only ever programmed in basic and that is only PicMicros, >> I am finding this exceptionally difficult. I have managed to fool >> (butcher) with it plenty and get an output that would probably work if >> I could only decipher how to read the input. I am sure that I have >> gone about it all wrong and was wondering if anyone had a modified >> driver that was more suited to my requirements. >> >> My VFD takes single requests and replies with single answers that is I >> can only read one thing at a time. >> >> To Read the programmed Frequency I need to send >> [01][04][03][00][00][00][F0][4E] >> >> [01] Slave address [04] read control status [03] request length [00] >> read set Frequency [00 and 00] extra request padding [F0 4E] CRC >> >> Generating the reply of >> [01][04][03][00][03][E8][F0][F0] corresponding to 10.00Hz >> >> If I want to know the frequency out of the vfd I send >> [01][04][03][01][00][00][A1][8E] >> out amps is [01][04][03][02][00][00][51][8E] etc etc, until I have all >> the values required >> >> 2 of the control requests are as follows >> sent [01][03][01][08][F1][8E] Drive Stop >> received [01][03][01][09][30][4E] >> >> send [01][03][01][01][31][88] Drive run >> receive [01][03][01][00][F0][48] >> >> and to set the run frequency of the drive I send >> [01][05][03][03][E8][00][73][8E] Set drive frequency 10.00 Hz >> receive [01][05][02][03][E8][B8][72] >> [01][05][03][13][88][00][5A][4B] set drive frequency 50.00 Hz >> receive [01][05][02][13][88][B5][9A] >> >> I though that I could nut this out so that I didn't have to bother >> anyone but this is driving me crazy. I tried to modify the classic >> ladder modbus routine also but had no luck with that either. If >> someone has a stripped down version of the GS2 files that I may have >> better luck with I would greatly appreciate it. >> >> Thanks, >> >> Jayson. >> >> (Horsham, Australia) >> > I probably don't have a good answer, but I am a little unclear as to how > your program is not working. Are you able to send and receive Modbus > packets? Are the transactions above what you actually got in a buffer > somewhere? If not, I seem to recall that I chose a command that only > needed a valid send packet to get an indication on the remote end, which > was to turn on an LED on a ModIO: > http://www.homanndesigns.com/ModIO.html > > The problems I had where in understanding the peculiarities of the > serial port and getting a handle on how CRC is implemented. I used a lot > of printf's in my program: > http://www.wallacecompany.com/machine_shop/EMC2/modbus/read_Din-1b.c > > to make sure that the program progressed as planned. > > I found the Modbus specifications helpful: > http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf > http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf > > ( http://www.wallacecompany.com/machine_shop/EMC2/modbus/ ) > > I don't recall how far I got with this, but I seem to recall that I was > successful with turning on an LED and reading the status of a digital > input. I haven't gotten any further because I just don't have the time > and the programming skill. > > If you can describe any results that turned out differently than > expected, it may shed light on the problem. Also, since you are familiar > with Basic you may be able to develop your program in Basic. -- ----------------------------------------------------------------------------- eStore: http://www.homanndesigns.com/store Web : http://www.homanndesigns.com ModIO - Modbus Interface Unit email : pe...@homanndesigns.com DigiSpeed - Isolated 10Vdc I/F Phone : +61 421 601 665 TurboTaig - Taig Mill Upgrade board ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users