kamenges
Member
Originally posted by Peter Nachtwey:
On a SLC5xx the 32 bit number can be loaded into the special 32 bit register and do a divide using the DDV (I believe) instruction.
That is correct. But it is the ONLY instruction that will operate on a value already in S:13 and S:14. MUL will correctly extend into S:13 and S:14 but ADD and SUB will not. So you can't increment a 32-bit quantity directly.
Originally posted by Peter Nachtwey:
2^32=4294967296 which has a range much greater than 999,999,999.
Also true. But if I am counting 4 events a minute, every minute of every day, 999,999,999 gives me just under 500 years of continuous operation. So while 4294967296 is certainly greater than 999,999,999 that MAY not be germane to the conversation.
Originally posted by Peter Nachtwey:
PLCs should support both signed and unsigned math.
Again, I couldn't agree more. But my '96 Saturn SL should get 50 MPG and do 0-60 in 9.5 seconds, too. Just because I want it to be true doesn't mean I don't have to work with what I have.
Originally posted by Peter Nachtwey:
Today you should simply buy a more powerful PLC and avoid the hassle.
Absolutely. And not even necessarily more powerful, as you pointed out. Just one that doesn't artificially limit the processor it already has. And I agree for new applications. But for an existing application I can do alot of messing around with software methods for what it would cost me to replace the plc and I/O, redraw the schematics and transport the program.
You can do 32-bit extended integers in the SLC but you have to babysit the sign bit of the LSW at rollover by yourself. If you are just looking to do an increment it isn't bad. But the easiest implementation for most people seems to be the multiple register idea from robo77. As long as the range isn't huge and you know how to display it on an HMI it usually works OK.
Keith