Lobenstein Posted October 2, 2023 Share Posted October 2, 2023 I can't seem to get the actual torque values to come in as a 16 bit signed value through PDO mapping. If the torque is a negative number it rolls over and I get some large value. The only way I can seem to make it work is to bring in the actual torque through the encoder conversion table and scale it there and just read the DeltaPos value. Is this the best method or is there a way to bring this PDO in as a 16 bit signed number? Quote Link to comment Share on other sites More sharing options...
steve.milici Posted October 2, 2023 Share Posted October 2, 2023 Processing this in the ECT would be the best method. Quote Link to comment Share on other sites More sharing options...
ksevcik Posted October 4, 2023 Share Posted October 4, 2023 (edited) It never occurred to me to run all those values through the ECT just for tuning/charting purposes, so I came up with a hack that works for the plot tool: ECAT[0].IO[1].Data.a - (ECAT[0].IO[1].Data.a & 32768) - (ECAT[0].IO[1].Data.a & 32768) Obviously substitute your values for ECAT[0] and IO[1]. Then use the plot scale factor as necessary to scale to 100% or whatever. It works because to convert from the 16-bit 2s complement, you subtract 2^16 from the unsigned number. The bitwise & picks out bit 15 to indicate sign and subtracts 2^15 twice to convert to the signed form. You have to subtract twice for this to work in Plot Tool. I tried bit shifting or multiplying by two with any number of parentheses and Plot Tool couldn't parse it. Subtracting twice was the only thing that worked. If you wanted to use this in Script or C, this #define should work: #define Torque(value) (value - (value & 32768) << 1) None of these work if you need the torque value available for servo-loop processing or the like, obviously. The ECT would be your only option for that. Edited October 4, 2023 by ksevcik Quote Link to comment Share on other sites More sharing options...
steve.milici Posted October 4, 2023 Share Posted October 4, 2023 If you assign the ECT entry for this to an activated motor (disabling FFE and amp-fault), you can use all PMAC motor features to read this value, including use in the Plot tool. Quote Link to comment Share on other sites More sharing options...
tecnico Posted January 20 Share Posted January 20 you can also copy the value into a ptr that is mapped in the user memory as signed 16bit integer -> i.user:xx.0.16 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.