cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to figure out at which memory address each data from the sensors is being stored in?

bblajevici
5-Regular Member

How to figure out at which memory address each data from the sensors is being stored in?

Hey all, I'm playing around with the SigmaTile and KepServerEX.

I imported the KepServerEX project and it is working fine but I'm trying to understand how it works under the surface.

I wanted to replicate the Channel, Device and Tags to set them up myself from scratch, however I don't know which addreses to set for the tags.

How to figure out at which memory address each data from the sensors is being stored in on the modbus emulation on the Raspberry Pi?

In the original project settings I see for example for the Humidity tag there is the Address 40003. Where is this set/defined, where can I look it up?

I searched through the Sigma Tile python code but could not find the answer.

Anyone can help with that?

 

Thanks

Boris

1 ACCEPTED SOLUTION

Accepted Solutions
bblajevici
5-Regular Member
(To:mthakker)

Thanks for your reply Milan.

I think I got the idea but I'm not sure 100%.

I did some research on modbus to understand better how memory addresses are managed.

Is following logic correct?

- Sensors data is stored in holding registers (hr) starting at 40001 to 49999 (modbus architecture) (?)

- When you update the datastore consecutiveley the memory addresses are being written in the order given by the Python script (2 adresses for each float value)

     1 - temperature (400001, 400002) - 400001 being the one to trigger from Kepware in order to get the tag value

     2 - humidity (400003, 400004) - 400003

     3 - pressure (400005, 400006) - 400005   

     4 - acceleration_x(400007, 400008) - 400008

     ...

      this goes on for acceleration, vibration, gyrosocope

- Then there are some more values written for screen control, bad count, good count... where you explicitly specify the address in the setvalue function

for example for screencontrol you provide the address 0x18 which is 24, then added to 400001 results in 400025 which is the address triggered by KEPServerEX

Thanks

Boris

View solution in original post

8 REPLIES 8

You should able to find it from Quick Client. Open the device (usually Channel_Name.Device_Name). On the Right side window, you will see the properties associated with that device. Right Click and Select Properties. Last line will give you the address. Its value is what you are looking for.

I hope this helps.

Thanks,

Varathan

bblajevici
5-Regular Member
(To:vranganathan)

Hi Varathan,

thanks for your reply.

Yes, I had already found that in the demo project. The question was if I haven''t had the demo project and I would just want to set up everything from scratch in KEPServerEX, where should I look up the exact memory address information for each sensor data (on the tile)?

I see Milan has replied also, I will read through the python code and see if I can figure it out.

Thanks

Boris

mthakker
6-Contributor
(To:bblajevici)

Hey Boris,

Varathan tackled the Kepware (client) side of things, but on the server side (the tile) you should look into the Python script called SigmaTile_SenseHat.  There's a thread called update_sensor_datastore which queries the sensors and updates the datastore.

There's a little bit of hacking in this function - I couldn't initialize the modbus datastore to hold 32 bit floats, so I took that float and split it into two uint16s which are then stored in the datastore consecutively.  Kepware can then pack those two uint16s back to a 32 bit float, so that it interprets the number correctly.

Let me know if you have any questions!

Milan

bblajevici
5-Regular Member
(To:mthakker)

Thanks for your reply Milan.

I think I got the idea but I'm not sure 100%.

I did some research on modbus to understand better how memory addresses are managed.

Is following logic correct?

- Sensors data is stored in holding registers (hr) starting at 40001 to 49999 (modbus architecture) (?)

- When you update the datastore consecutiveley the memory addresses are being written in the order given by the Python script (2 adresses for each float value)

     1 - temperature (400001, 400002) - 400001 being the one to trigger from Kepware in order to get the tag value

     2 - humidity (400003, 400004) - 400003

     3 - pressure (400005, 400006) - 400005   

     4 - acceleration_x(400007, 400008) - 400008

     ...

      this goes on for acceleration, vibration, gyrosocope

- Then there are some more values written for screen control, bad count, good count... where you explicitly specify the address in the setvalue function

for example for screencontrol you provide the address 0x18 which is 24, then added to 400001 results in 400025 which is the address triggered by KEPServerEX

Thanks

Boris

Hi,

Is there a way to get the joystick position in Kepware ?

Is it exposed ?

Yes. We should able to.

We use Sense Hat as Device and Python code as OPC server which ships values from Device. You should capture the event from Sense Hat and set the registry value in OPC Server Python Code which is shipped with it.

The sample code to read the joystick values are available in below link.

A Guide to Astro Pi | Raspberry Pi Learning Resources

Once you make it available in OPC Server, You can configure Kepware to read it with new tags.

I hope this helps.

Thanks,

Varathan

ccertain
6-Contributor
(To:bblajevici)

SigmaTile

 

Hi Boris,

the adresses are defined in hexadecimal format in the phyton script. Search please for the corresponding variables

You will find 0x1c for the VibrationAlert

0x1C = 28 (from hexa to dec)

add one because of modbus so you get 29

In Modbus the registers 40001-49999 are typically used for analog output holding

So it looks like 40029 for the VibrationAlert.

You can apply the same mechanism for all the other variables / sensor values

Hope it helps you

Christoph C.

 

 

anishi
13-Aquamarine
(To:ccertain)

Hi ccertain,

 

I'm trying to read VibrationAlert by reading 40029.

But it reads only once and never update.

The value is 1 and update count is also 1.

If you have working opf file, please share it with me.

Or could you tell me which point I should check, please?

 

Best regards

Akira

 

Top Tags