Search code examples
precisionplcstructured-text

How to log LREAL values to file?


I'm new to PLC programming and I'm trying to keep track of an LREAL variable in some existing structured-text code. I'm using Omron's CX-Programmer with a simulated CJ2M.

My first instinct was to log all changes in value to SD card, using WRITE_TEXT() . Since I need a string value to write, I had hoped that LREAL_TO_STRING() would do the trick, but it appears that function does not exist.

How could I best log that value without losing precision?


Edit: I managed to work around this problem. Having been told CX-Programmer's SD card emulation could be unreliable, I simply wrote the values to an array and examined the contents of those memory locations with the built in tools. I could also export these values into a file if needed. This approach limits the amount of recorded data to available space in the simulated PLC memory.


Solution

  • In CXP you can't convert real into a string. You have to do the conversion yourself.

    If you want to know if you can do any other conversion you can follow the table here.