Accesing EKM with RS485 Protocol

For more advanced meter data users. Learn from others and ask questions about how to read meters, how to use the EKM Push Data, and how to display the meter data in useful ways.
GabrielDuarteCh
Posts: 7
Joined: Sun Dec 07, 2014 12:35 pm

Accesing EKM with RS485 Protocol

Post by GabrielDuarteCh »

Hi,

I´m working on a project using your EKM Omnimeter I v.3 to monitor a photovoltaic Solar power system and i want to access the EKM through my own embedded solution. I am using a pic 16F877A with a max485 but i have some doubts about the parsing and the communication protocol.

1) The request string 2F 3F 30 30 30.... that would be in hex format ( 0x2F, 0x3F, 0x30, 0x30....) do i get that right ?
2) In the communication sequence for reading. Do i need to send a read before closing or can i just send REQUEST, wait for the return, and then close.
3) In the read string, the CRC16, do i need to calculate it or can i just send two random bytes ?
4) The CRC16 the EKM generates is always the same or does it change?

I hope you can help me.

Thank you.

Gabriel Duarte
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Accesing EKM with RS485 Protocol

Post by Jameson »

Hello Gabriel, welcome to the forum!

First make sure you have seen the bottom of this page for information about how to read your meter over RS485 with your own solution: http://www.ekmmetering.com/developer-portal/
1) The request string 2F 3F 30 30 30.... that would be in hex format ( 0x2F, 0x3F, 0x30, 0x30....) do i get that right ?
Yes this is correct. Make sure you have your serial settings as 9600 baud, 7 data bits, Even Parity, 1 stop bit, no flow control.
2) In the communication sequence for reading. Do i need to send a read before closing or can i just send REQUEST, wait for the return, and then close.
Also after you get the full 255 bytes from the meter you should send the "Close String": 01 42 30 03 75
3) In the read string, the CRC16, do i need to calculate it or can i just send two random bytes ?
You do not need to verify the data with the CRC16 (you do not need to calculate it for the meter request). But what CRC does is verify that the data you received is the data that the meter intended to send to you. So it is best practice to use CRC to check your data. Depending on your abilities, calculating the CRC can be a steep learning curve.
4) The CRC16 the EKM generates is always the same or does it change?
Every meter response will have a unique CRC 16 that verifies the data, even if the metered values dont change, the meter clock will so this will change the CRC.

Let us know if you need a hand, there are a lot of resources on this forum about how to calculate CRC16. Just use the search bar to find "CRC"

Good luck!
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
GabrielDuarteCh
Posts: 7
Joined: Sun Dec 07, 2014 12:35 pm

Re: Accesing EKM with RS485 Protocol

Post by GabrielDuarteCh »

Hi Jameson thank you for your reply,

Yes, i understand about the "Close String", that is what i actually ment by "closing". But i´m really doubting about the sequence, i mean, do i need to send "Request", wait for the "Return" , send the "Read String", wait for the "Return", and then send the "Close String", or can i just do "Request", wait for "Return" , and then "Close String", do i make my point ?
Jameson wrote: You do not need to verify the data with the CRC16 (you do not need to calculate it for the meter request). But what CRC does is verify that the data you received is the data that the meter intended to send to you. So it is best practice to use CRC to check your data. Depending on your abilities, calculating the CRC can be a steep learning curve.
Oh ok i will check about the CRC calculation. But my real concern comes from this part on your Meter Communication Protocol

"Read Last kWh: 01 52 31 02 30 30 31 31 03 CRC16"

Since it says inside the string must be a CRC16 i understand there must be two bytes to end the string. You are telling me i don´t need to calculate it right ?, so i can just send two random bytes, no matter what they are.

The point is there MUST be two bytes representing the CRC. because i am concern the meter won´t recognize these bytes and will send me a response telling me the message is corrupt, so i must resend another package.

I´m sorry if i didn´t understand you, but i´m really concern about this and i need to get this straight.

Thank you.
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Accesing EKM with RS485 Protocol

Post by Jameson »

Yes, just: "Request", wait for "Return" , and then "Close String"

You do not need to know the CRC to make a normal request string. "Read Last kWh: 01 52 31 02 30 30 31 31 03 CRC16" is more of an advanced string that you should not need.

What is your meter number? I can help you to generate the request string.

The best from my perspective is to use the EKM Dash to read your meter first. Then you know it works. After this use the EKM Dash Hex Inspector to "see" how the communication with the meter works. You will then copy this to get your PIC processor to work in the same way.

Regards,
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
GabrielDuarteCh
Posts: 7
Joined: Sun Dec 07, 2014 12:35 pm

Re: Accesing EKM with RS485 Protocol

Post by GabrielDuarteCh »

Hi Jameson,

My meter number is 15423 and this is the string i have generated for the request

const BYTE Request[] = {0x2F,0x3F,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x35,0x34,0x32,0x33,0x21,0x0D,0x0A};

is that ok?

Thank you.
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Accesing EKM with RS485 Protocol

Post by Jameson »

Yes, your meter request string looks good for meter 15423. Are you able to "sniff" the output to see what you are actually getting? We use PC software called "Advanced Serial Port Monitor" to do this.
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
GabrielDuarteCh
Posts: 7
Joined: Sun Dec 07, 2014 12:35 pm

Re: Accesing EKM with RS485 Protocol

Post by GabrielDuarteCh »

Hi, i could communicate to the meter. I want to check the Voltage every 5 seconds, so i send the Request every 5 seconds. The first "Return" is correct but from this point on i´m not getting the right data or i'm not getting it in the right order (i.e. where i should see the voltage i see the power or the current or just 30). How often can i "talk" to the meter?

I'm just sending request and close. I'm using a max485 and a pic 16f877a with no 120 resistors.

Thank you.
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Accesing EKM with RS485 Protocol

Post by Jameson »

It sounds like you need to clear your Serial Buffer between reads. If your first call is working, then you are on the right track.

If you have it optimized you should be able to make a call roughly every 0.75 seconds.

Thanks,
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
GabrielDuarteCh
Posts: 7
Joined: Sun Dec 07, 2014 12:35 pm

Re: Accesing EKM with RS485 Protocol

Post by GabrielDuarteCh »

OK Jameson thanks for your quick reply!

I will check that out, also i was checking the data on the Return string and i noticed the voltage data came { 0xb1,0xb2,0x35,0x32} instead of {0x31,0x32,0x35,0x32} like it would normally be according to your meter communication parsing. Any idea of why this 'b' instead of '3' ?

The good news is the 125.2 it is fine but it concerns me these 'b'.

Thank you
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Accesing EKM with RS485 Protocol

Post by Jameson »

That looks like garbled data to me. I would suspect a bad terminating resistor value or a bad biasing resistor value in your device (you are not using an EKM Communication converter that is already tuned for this). Only trial and error (playing with different resistor values on your device) can help you to resolve that one (and some good serial sniffing software). You are correct that the meter is actually putting out 0x31,0x32,0x35,0x32, it is just that your device is not seeing it properly.

Just to give you a sense of what we do, we use 470 ohm biasing resistors and 90 to 120 ohm terminating resistors on some of our RS458 communication converters.
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
Post Reply