A Forum run by Enthusiasts of MidNite Solar

The Open Source software/hardware corner => General info => Topic started by: David on November 19, 2013, 02:29:56 AM

Title: Modbus log files
Post by: David on November 19, 2013, 02:29:56 AM
When attempting to get log file over Modbus I believe I am getting a response from Classic (at least I am not getting a Modbus error, and I can read registers fine) but the response is always the same 9 bytes:
00 00 00 00 00 4A 40 68 05

any clue what this means? 

I am constructing the "raw" request for yesterdays daily kWh with the following:
    uint8_t raw_req[] = {  0xFF, 0x68, 0x05, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Title: Re: Modbus log files
Post by: TomW on November 19, 2013, 11:28:10 AM
David;

The serial data output is selectable as to what it dumps to the port.

On the MNGP go to MISC>>COMM>>USB MODE and try a few to see which one does the full register dump or whatever data you want.

There is a thread here on it with some info on which does what. I forget the details so will not attempt to confuse you by guessing.

Just set your application to read it and run through a few to see which is the one you want.

Tom
Title: Re: Modbus log files
Post by: David on November 19, 2013, 05:38:22 PM
Hi Tom,
I am attempting this over ethernet.  Can't use USB without going down into the basement with the Troll.  I am able to get correct data from register addresses.  It is the log files that I am trying to get.  I have the classic register map PDF that explains how to get the log files but something must be slightly off and not quite sure how to debug it yet. 
Title: Re: Modbus log files
Post by: Westbranch on November 19, 2013, 07:10:24 PM
David, take a beef Joint and a whip. ::) 
Throw the troll the bone if that doesn't work use the whip... or a crowbar... :P :o
Title: Re: Modbus log files
Post by: TomW on November 19, 2013, 07:51:58 PM
Quote from: David on November 19, 2013, 05:38:22 PM
Hi Tom,
I am attempting this over ethernet.  Can't use USB without going down into the basement with the Troll.  I am able to get correct data from register addresses.  It is the log files that I am trying to get.  I have the classic register map PDF that explains how to get the log files but something must be slightly off and not quite sure how to debug it yet.

David;

Sorry I misunderstood. I am just requesting specific registers with Ross' newmodbus application over TCP/IP (ethernet).  Simply request a list of registers and it returns the values.


By "log files" do you mean "registers"? As far as I am aware there is no way to download a "log file" or if one even exists.

There is documentation but the last I looked at it it was rather dated and confusing, especially the address and register numeric labels being offset by one for some (historic?) reason. Perhaps that is what is vexing you?

Good luck with it.

Tom
Title: Re: Modbus log files
Post by: zoneblue on November 19, 2013, 10:37:15 PM
I  think he means using small file transfer to download the accumalated log data. Ross obviously figured it out, because thats how you set the time.
Title: Re: Modbus log files
Post by: David on November 20, 2013, 12:12:35 AM
Quote from: zoneblue on November 19, 2013, 10:37:15 PM
I  think he means using small file transfer to download the accumalated log data. Ross obviously figured it out, because thats how you set the time.

Yes, that is correct.  The Modbus document is available on each charge controllers page, i.e. http://www.midnitesolar.com/documents.php?productCat_ID=21&productCatName=Charge%20Controllers%20for%20Solar,%20Wind,%20Hydro&model=CLASSIC%20200&product_ID=257

Or the direct link: http://www.midnitesolar.com/pdfs/classic_register_map_Rev-B3-May-28-2013.pdf

Near the bottom it explains how to get the log files that I can't get right.
Title: Re: Modbus log files
Post by: TomW on November 20, 2013, 09:09:45 AM
Way beyond me, guys.

I just don't pick up on this stuff like I used to and I don't remember ever seeing that document before. I should just leave it to those who are more informed to sort things out.

Tom

Title: Re: Modbus log files
Post by: David on April 27, 2014, 10:34:20 PM
Anybody from Midnite care to help explain how to get the log files correctly over Modbus or explain why I am getting the results above?
Title: Re: Modbus log files
Post by: zoneblue on April 28, 2014, 04:00:55 AM
Ask the guy who developed one of the android app,  he figured it out recently, Graham i think his name is.
Title: Re: Modbus log files
Post by: atop8918 on April 28, 2014, 04:08:42 AM
Hi, David,
It's a little difficult to see what's going on without a little more detail. Your PDU with the device address of 0xFF looks okay but there's no CRC and the TCP/IP MBAP header is missing. Presumably this is added by whatever modbus or library you are using? If this is the case then the UNIT IDENTIFIER field should be set to 0xFF and not the first byte of the request packet.

The return packet is hard to decode since it's unclear whether this is just the PDU or the full ADU-with-MBAP header. Whatever it is I'm not really sure what it represents. Like you said, it's certainly not an error response.

If you can fill in some of the blanks then we might get a better idea of what's happening in there.

Thanks!
-A

Title: Re: Modbus log files
Post by: Graham on April 28, 2014, 07:22:13 AM
Quote from: zoneblue on April 28, 2014, 04:00:55 AM
Ask the guy who developed one of the android app,  he figured it out recently, Graham i think his name is.

The code for my open source implementation of the android app is available in sourceforge at http://sourceforge.net/p/classicmonitor/code/HEAD/tree/ (http://sourceforge.net/p/classicmonitor/code/HEAD/tree/)
the code related to the file transfer is mainly in the following files
Classic/src/main/java/ca/farrelltonsolar/j2modlite/msg/ReadFileTransferRequest.java and ReadFileTransferResponse.java

hope this helps

Graham.
Title: Re: Modbus log files
Post by: David on April 29, 2014, 10:29:50 PM
Thanks for the input.  I'm attempting to write to register 4254 and then reading 4255 to get the daily log value the Classic should have written to it.  My other modbus calls are working correctly (watts, current, battery temp,  etc).   I will provide more details in the next day or so.

David