Hi Guys and gals.
Google lead me to this site a few days ago, and I must say its pretty cool.
I've got a project on the go right now. I'm using a AB SLC 5/03 with an SST profibus scanner card. All is good, i've gotten far in getting my Siemens Posmo A servo drives working with the AB system.
I've ran into a small brainteaser that might give some of you a nice challenge.
I need to take a FLOAT number value (positive of negative) and convert it into a double integer word which is copied into the High and low int registers of the servos, whereby I load these values into traversing blocks, setpoints etc.
The servos use a fixed decimal point, so to store 29.232 in the servos, you multiply it by 10,000 and then 'split it' into two int registers.
29.232 x 10,000 = 293 320
292 320 in hex = 479C8
Split hex word and you got
high int = 0004 (hex)
low int = 79C8 (hex)
If I load these two int values into the respective registers i'm good. Its getting these values from the FLOAT thats got me stumped. Becase the SLC is 16 bit, i'm hitting walls with every strategy i've come up with. I discovered that diving a real number will not leave the MOD and quotient in S:13 and S:14. Arghh.
The real kicker is this. How do I take a number, with a decimeal point that is going to vary (since I am writing a function in the plc for use for all FLOAT->DINT conversions to handle a decimal point all over the place and yet
SPLIT the FLOAT value. Ie take 29.232 and spit out 29 and the 0.232 sperately. That if solved lets my math work.
Ideas?
Rockwells support hasn't addressed this scenairo with their examples, and I dug through the archives here first before asking.
Google lead me to this site a few days ago, and I must say its pretty cool.
I've got a project on the go right now. I'm using a AB SLC 5/03 with an SST profibus scanner card. All is good, i've gotten far in getting my Siemens Posmo A servo drives working with the AB system.
I've ran into a small brainteaser that might give some of you a nice challenge.
I need to take a FLOAT number value (positive of negative) and convert it into a double integer word which is copied into the High and low int registers of the servos, whereby I load these values into traversing blocks, setpoints etc.
The servos use a fixed decimal point, so to store 29.232 in the servos, you multiply it by 10,000 and then 'split it' into two int registers.
29.232 x 10,000 = 293 320
292 320 in hex = 479C8
Split hex word and you got
high int = 0004 (hex)
low int = 79C8 (hex)
If I load these two int values into the respective registers i'm good. Its getting these values from the FLOAT thats got me stumped. Becase the SLC is 16 bit, i'm hitting walls with every strategy i've come up with. I discovered that diving a real number will not leave the MOD and quotient in S:13 and S:14. Arghh.
The real kicker is this. How do I take a number, with a decimeal point that is going to vary (since I am writing a function in the plc for use for all FLOAT->DINT conversions to handle a decimal point all over the place and yet
SPLIT the FLOAT value. Ie take 29.232 and spit out 29 and the 0.232 sperately. That if solved lets my math work.
Ideas?
Rockwells support hasn't addressed this scenairo with their examples, and I dug through the archives here first before asking.