OK, I Give... What Am I Missing Here?...

Eric Nelson

Lifetime Supporting Member + Moderator
Join Date
Apr 2002
Location
Randolph, NJ
Posts
4,346
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... :D

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... :sick:

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?... :rolleyes:
 
Eric:

I might be missing something here... I am not familiar with A-D; can it handle doubles (aka long integers)? I mean those 32-bit long ones.
If you could use double math, all you need to do is 100 * 3306 / 10, using <u>double-length registers</u>.
Of course some basic boundary checking (to prevent overflow) would be a good idea.

If A-D cannot handle double values, then... But it knows real numbers, doesn't it?

Once again, sorry if I did not understand this correctly.
 
You're not missing anything...

It's ME that's 'missing something' (besides most of my hair)... :p

I didn't think about just getting rid of the stupid decimal point in the first place!... šŸ™ƒ

Once again, PLCS.net comes through with the quick answers! On a holiday, no less!... :site:

Thanks ladderdude!

beerchug

-Eric
 
Works just fine...

Now it's nice and simple... And everything stays in BCD!... (y)

| ALW_ON +-------+
|-----] [-------------+-----| LD | Stick my "User Entered Value"
| | | V2100 | in the Accumulator
| | +-------+
| | +-------+
| +-----| MUL | Multiply by my scale value
| | | K3306 |
| | +-------+
| | +-------+
| +-----| DIVD | Divide by "10"
| | | V2000 | (V2000 contains "10")
| | +-------+ (Koyo doesn't allow /K)
| | +-------+
| +-----| OUTD | Stick result in V2214/15
| | V2214 |
| +-------+


.
Actually, I added a third decimal place to my "User Entered Value" (i.e. 1.000"), so I'm dividing by 100 instead of 10.

My apoligies to the Nelson kin here... Hopefully our name has not been too badly tarnished by my temporary brain loss... :D

beerchug

-Eric
 

Similar Topics

Hey all. I have a problem I seem to be unable to figure out by myself. I have been searching for a few days now. The situation is as follows: I...
Replies
22
Views
5,101
I don't know if I am looking into this to hard. I am in the middle of adding some external relays and alarms to all of our machines. I go to...
Replies
4
Views
2,224
Wandering through the forum I found this thread about how to test/tune a simple position control. Tried to get a good low ISE, but the best I...
Replies
3
Views
2,530
Hi, we are using Rx3i CRU320 redundant PLC system and we noticed a discrepancy between Primary and Secondary controller. Couple of variables (DI)...
Replies
8
Views
268
Hi guys, got one problem PLC model fp-xh c60t and HMI model TG765S-MT I've encountered an issue which is the recipe file went missing if i swtich...
Replies
0
Views
80
Back
Top Bottom