RikRealization
Hi Legends! So within PSM I am trying to read out a 17 bit ADC (Pi ADC). Within PSM I could get the voltage readings to be printed out with ease. However when I try to set them to a REAL location address which in my case I made %MD81 it just returns 0.
I have tried to test it without ADC pi putting this in my PSM within the update_inputs() which I know is called within the main loop:
psm.set_var("%MD81", 3.14159)
read_value = psm.get_var("%MD81")
print(f"Set %MD81 to 3.14159, read back: {read_value}")

My runtime logs unfortunately returns:
Set %MD81 to 3.14159, read back: 0
 
0.0 is shown in the monitoring webpage too.
 
How could I fix this?

I already see myself making another mistake. In my FUXA HMI, there I have set the corresponding holding register to a float32 type, would this be correct? (with address 400082 btw). I am using a Raspberry Pi
Reply 0 0
RikRealization
I have also tried %QD81 to no affect
Reply 0 0
thiagoralves
PSM can only access IX, IW, QX and QW locations. You can either separate your real in two QW locations or reduce precision by 1 bit and make it fit in one QW location.
Reply 0 0
RikRealization
Hey Thiago! Thanks again for the fast response. In order to better understand PSM in general I have created a practice program and script (maybe you can use elsewhere as an example, its a WIP) I just can't seem to figure out how to get the WORDS (or UINTS) to REAL to work, in this case for the variable: 'FromWORDPSM_InOpenPLC_Reconstructed_Real'
 
Could you point me in the right direction? The PSM belonging to the program is inserted as a comment.
Reply 0 0
thiagoralves
Perhaps it would be better to just have one word be the integer part and the other word be the decimal part, instead of managing the merge of two 16-bit chunks into one 32-bit REAL. This is easier to accomplish on both sides (Python and ST/LD) as it only requires basic multiplication and division
Reply 0 0
RikRealization
Hey Thiago! Thanks a lot for the advice that indeed was a lot simpler! I am now trying to pass the memory address (in this the focus is on %MD91) into my FUXA HMI
 
[203128%2F9237614%2Fmceclip0]
 
However as you can see below I somehow cannot find it there and I now I am properly connected.
[203128%2F9237616%2Fmceclip0]
[203128%2F9237618%2Fmceclip0]
 
I have tried the Float32LE and Float32MLE too but to no affect. I also ran a Modbus poll adress scan but found nothing:
[203128%2F9237622%2Fmceclip0]
 
What could I be doing wrong?
Reply 0 0
RikRealization
Off course I did also use the integer and decimal separate approach which works but is non ideal[203128%2F9237659%2Fmceclip0]
Reply 0 0
thiagoralves
You’re using the wrong address. See https://autonomylogic.com/docs/2-5-modbus-addressing/
Reply 0 0
blewis9991
Off course I did also use the integer and decimal separate approach which works but is non ideal[203128%2F9237659%2Fmceclip0]
 
Hey Thiago! Thanks a lot for the advice that indeed was a lot simpler! I am now trying to pass the memory address (in this the focus is on %MD91) into my FUXA HMI
 
[203128%2F9237614%2Fmceclip0]
 
However as you can see below I somehow cannot find it there and I now I am properly connected.
[203128%2F9237616%2Fmceclip0]
[203128%2F9237618%2Fmceclip0]
 
I have tried the Float32LE and Float32MLE too but to no affect. I also ran a Modbus poll adress scan but found nothing:
[203128%2F9237622%2Fmceclip0]
 
What could I be doing wrong?
Hi, I have exactly the same problem. I am reading a temperature from a modbus device that returns  2 integers in real4 format. I tried ST and FBD but these are too cumbersome and the type conversions too limiting. So I want to use Python as you are doing, but have Limited experience here. Would you be able to share your project or even just a buildable portion of it? Thank you.
Reply 0 0
Reply