Eric Nelson
Lifetime Supporting Member + Moderator
Instead of taking off for the holiday, I decided to come in to work and frustrate myself with floating point numbers... banghead
For those who care, the components are:
A-D DL-06 PLC
A-D EZ-420 Operator Interface
PacSci PC800 Drive
I'm trying to scale a user entered value and send it to the drive. A value of 1.00 (inches) is equal to 33060 counts. The decimal point is fixed, so the entered value will be "100" (in BCD). So, to make "100" equal 33060, I have to multiply by 330.6. Simple enough, but I figure I have to use floating-point (real) numbers to do the math.
I'm not 'real' good with 'real' numbers, and I've NEVER used them with an A-D, so I'm not having much fun right now. What I've got so far actually WORKS, but I think I'm making it MUCH more complex than needed. I guess I've been out of school a bit too long, or, more likely, just getting old and crotchety like BobB...
To get the 330.6, I'm converting 3306 and 10 (both in BCD), first to binary, then to 'real' numbers. I take the 'real' equivalent of 3306 and divide it by the 'real' eqivalent of 10, which gives me (the 'real' equivalent) of 330.6
Next, I take my user entered value (in BCD) and convert that, first to binary, then to a 'real' number. I multiply this by my 330.6 value, then convert the result, first to binary, then to BCD. Now I (finally) have my scaled value to send to the drive.
Here's the ladder for you A-D guys...
.
This 'should' be simple to do, so please explain to me how stupid I am for approching it this way...
beerchug
-Eric
P.S. I drove myself nuts last night trying to send ASCII commands to the drive, but finally figured THAT one out. Why can't everything just speak MODBUS?...
For those who care, the components are:
A-D DL-06 PLC
A-D EZ-420 Operator Interface
PacSci PC800 Drive
I'm trying to scale a user entered value and send it to the drive. A value of 1.00 (inches) is equal to 33060 counts. The decimal point is fixed, so the entered value will be "100" (in BCD). So, to make "100" equal 33060, I have to multiply by 330.6. Simple enough, but I figure I have to use floating-point (real) numbers to do the math.
I'm not 'real' good with 'real' numbers, and I've NEVER used them with an A-D, so I'm not having much fun right now. What I've got so far actually WORKS, but I think I'm making it MUCH more complex than needed. I guess I've been out of school a bit too long, or, more likely, just getting old and crotchety like BobB...
To get the 330.6, I'm converting 3306 and 10 (both in BCD), first to binary, then to 'real' numbers. I take the 'real' equivalent of 3306 and divide it by the 'real' eqivalent of 10, which gives me (the 'real' equivalent) of 330.6
Next, I take my user entered value (in BCD) and convert that, first to binary, then to a 'real' number. I multiply this by my 330.6 value, then convert the result, first to binary, then to BCD. Now I (finally) have my scaled value to send to the drive.
Here's the ladder for you A-D guys...
| ALW_ON +-------+
|-----] [-------------+-----| LD | Stick "3306" (BCD)
| | | K3306 | in the Accumulator
| | +-------+
| | +-------+
| +-----| BIN | Convert to Binary
| | +-------+
| | +-------+
| +-----| BTOR | Convert to Real
| | +-------+
| | +-------+
| +-----| OUTR | Stick result in V2210/11
| | V2210 |
| +-------+
|
| ALW_ON +-------+
|-----] [-------------+-----| LD | Stick "10" (BCD)
| | | K10 | in the Accumulator
| | +-------+
| | +-------+
| +-----| BIN | Convery to Binary
| | +-------+
| | +-------+
| +-----| BTOR | Convert to Real
| | +-------+
| | +-------+
| +-----| OUTR | Stick result in V2212/13
| | V2212 |
| +-------+
|
| ALW_ON +-------+
|-----] [-------------+-----| LD | Stick my "User Entered Value"
| | | V2100 | in the Accumulator
| | +-------+
| | +-------+
| +-----| BIN | Convert to Binary
| | +-------+
| | +-------+
| +-----| BTOR | Convert to Real
| | +-------+
| | +-------+
| +-----| OUTR | Stick Result in V2214/15
| | V2214 |
| +-------+
|
| ALW_ON +-------+
|-----] [-------------+-----| LDR | Stick my "3306"
| | | V2210 | in the Accumulator
| | +-------+
| | +-------+
| +-----| DIVR | Divide by my "100"
| | | V2212 | (Now I have that damned "330.6")
| | +-------+
| | +-------+
| +-----| MULR | Multiply 330.6 by
| | | V2214 | my "User Entered Value"
| | +-------+
| | +-------+
| +-----| RTOB | Convert Result to Binary
| | +-------+
| | +-------+
| +-----| BCD | Then to BCD
| | +-------+
| | +-------+
| +-----| OUTD | Stick this BCD result
| | V2214 | in V2216/17
| +-------+
.
This 'should' be simple to do, so please explain to me how stupid I am for approching it this way...
beerchug
-Eric
P.S. I drove myself nuts last night trying to send ASCII commands to the drive, but finally figured THAT one out. Why can't everything just speak MODBUS?...