Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Does anyone know how I can read a binary comtrade data file. In this case "File.dat"
What is comtrade? See https://en.wikipedia.org/wiki/Comtrade.
I am interested in displaying the File.dat The others are easy to open in mathcad.
Once I can view it then I can do further processing to it in mathcad
Thanks.
Solved! Go to Solution.
Caution, using the built-in READCSV of Prime instaed of the one I supplied, requires changes in ReadComtradeCfg, because the READCSV built into Prime already interprets evry field that looks like a number as a number.
In many cases that's OK, but e.g. the Recording device ID (a 1 in your .cfg file) could also be an alpha string.
Luc
HI Files from another protection relay - cannot be opened with mathcad 15 though.
I will have a look later today (your night I guess)
Luc
There was an(other) error in the ReadComtradeCfg function.
It's corrected now, and I've changed the Prime (4) version to use the built-in READCSV function.
Now both implementations (Mathcad 11 and up, as well as Prime 4 and up) should be able to read both data sets.
Success! and Happy Easter,
Luc
Hi Thanks so much. Happy Easter to you too. I like your sign off. You make it look too easy.
You're welcome.
I know that I didn't implement every feature of the Comtrade specification (yet).
If there's anything wrong or missing, don't hesitate reply back.
Luc
Found, and corrected a few more errors in the READCSV function. (applies to Mathcad 11...15 only)
Luc
Oh, it slipped my attention - READCSV is also available in Mathcad 15/14
Here's the help entry:
Is it really WRITECSV(M,"file") and not WRITECSV("file",M), like Prime (4) has it?
And does WRITECSV support the same (row, col, etc.) arguments as READCSV?
LucMeekes wrote:
Is it really WRITECSV(M,"file") and not WRITECSV("file",M), like Prime (4) has it?
Yes, the MC15 help is correct. i just gave it a try.
And does WRITECSV support the same (row, col, etc.) arguments as READCSV?
No. WRITECSV only accepts 2 arguments, matrix and file name. It always writes from the beginning (1;1) and you cannot change the decimal character from "." to "," (in prime the field separator is then automatically changed to ";").
The help in Prime 3.0 is missing the information that READCSV can have more arguments (the same as in MC 15).
BTW, Prime (3.0) can write files where the decimal symbol is a comma, but it can't read those files. Numbers are interpreted as text.
"The help in Prime 3.0 is missing the information"
That is the same for Prime 4. Why am I not surprised...
I am trying this with the following files (attached). (Page 5) Based on the file you created.
I can get the Ia value as I expect,
I think the Ib should be 39.286, 95.7063,127.58 etc
Similarly Ic= -126.778,-133.204,-125609
The voltages
Va=270618,23169,168359 etc
Vb=-70.841,18666.5,108174,etc
Vc=-199898,-25.1208,-276949 etc
What am I doing wrong?
Your picture did not come through. While it is possible to insert a picture by pasting it during editing a post, once posted it is lost. To insert a picture you have to use the camera button, above the edit window. It also means that you have to have your picture saved to a file (.png, .jpg, etc.) beforehand.
Success!
Luc
Any way. I got these results from your file set:
So there are 8 analog channels, 4 with current and 4 with voltage.
And the data is:
ILA is in column 2, ILB is in colum 3...ULA is in column 6 etc.
From your info I gather that you get ILA as 5506, 2816 etc. What makes you think that ILB should be other than 59.05, 143.829 etc. ?
Luc
Hmm, found one error. In the last statement of the ReadComtradeBinary function. You should correct as follows:
The 'multiplier' is added, instead of the 'adder', but that should not make (such) a big difference in ILB.
Now the analog data reads:
Success!
Luc
Hi
The reason I think it should be what I stated is that I have another software that is supposed to read the samples like we are doing here.
The software is SEL SYNCROWAVE and a trial version can be downloaded here.
Essentially it takes the data from a protection relay and then displays graphically. As you move the cursor you can see the reconstructed data samples. The A phase seems to reconstructs ok. The other phases seem off.
https://selinc.com/products/5601-2/#tab-downloads
Appreciate if you could have a look if you have the time .
Kind regards
A former colleage of mine gave some good advice several years ago: There's always one more bug.
Found it. The for loop should read:
I had double ORIGIN. But worse: I had a too high offset, 2 instead of 1.
Anyway that's now corrected. The data now reads:
(There's your 39.286 for ILB ).
Attached is a corrected Prime 4 file.
Success!
Luc
You have saved me hours of work! -
We had a fault on our 330kV interconnector and the relays have a bug and not giving a fault location. I can now use this data to do a fault location and send the helicopter out
Thank you so much.
It is good and satisfying to know that a little bit of programming here can make a tremendous difference on the other side of the world.
Success with pinpointing!
Luc
We found it ! Thank you.
Great!
Have a nice day.
Luc
Hi! I'm using the last file you sent (LM_20181125_Comtrade) and I'm having problems with the ReadComtradeBinary function. I'm using MAthcad Prime 5.
It says that it only works in an array.
Do you know what could be the problem?
Thanks for all your help!
Ana, from Argentina
If you can post your config and data files, I may be able to find the cause.
It'll take me some time though, because it's long ago that I looked into this.
Success!
Luc
Thank you for your quick reply! I wasn't very hopeful since the last message was from 2018 😄
I attached 3 .DAT and .CFG files.
Hope it works!
Regards,
Ana
Hola Ana,
I found the cause of the error message.
Your config file specifies no sampling rate(s), so it uses variable (event driven) sampling. The read routine for the binary data file isn't equipped for that. I didn't include support for that, probably because I didn't have an example file set that actually uses it. So far all work was done with files provided earlier in this thread.
I'll see what I can do to have it handle that situation as well, now that I have your examples to work with.
Luc
Hola Ana,
I guess this is what you are looking for:
From the data file, I deduce that you probably used a 1600 Hz external clock signal to trigger the sampling (the samples are 625 microseconds apart), so it's not actually variable.
If I made no mistake, the attached update should allow you to make similar pictures for the OSC001 file set using Prime. (I can only change the program, I cannot run it because I'm using the free Express edition of Prime, which doesn't allow programming and a few other things).
So go ahead and use it, and thoroughly check that the output is correct, as far as you can. Don't hesitate to get back here with any problems you may encounter using this utility.
Buena suerte!
Luc
Hi Luc, it's Ana from Argentina (I had a problem with my previous account).
I have great news: IT WORKS!
Your code has helped me so much!
Thank you so much for your time, I'm really greatful!
Best regards,
Ana 🙂
Hi Ana,
That's great.
Success with your files!
Luc
Hi Luc
I tried to use the file that you did for Ana bit I got an error in the plot. My Mathcad skills are not too flash. Would you be able to comment if you have the time? I am attaching the Comtrade files that I have been using