Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
M-Var set to Real
#1
If is set a M-Var directly to a real value, does Power PMAC convert it to a 32-bit floating point value. I need to send a 32-bit floating point value out to a piece of equipment using a ACC-14E. If I can set a M-Var equal to the real value, I can then parse it out into 4 8-bit values to write to the ACC-14E.

Thanks
Reply
#2
I think you will need a small trick here. First, you will write your value to a holding register in the user shared memory buffer as a 32-bit floating-point value. For example,

Sys.Fdata[100] = MyValue

Then you can access the 4 bytes in this representation individually with Cdata elements:

Sys.Cdata[400]
Sys.Cdata[401]
Sys.Cdata[402]
Sys.Cdata[403]

Note that since there are 4 Cdata elements per Fdata element, the indices are 4 times greater.

So these can simply be copied a byte at a time to the 4 byte registers of your ACC-14E:

Acc14E[i].DataReg[0] = Sys.Cdata[400]
etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)