simple math with DL06

qlingtime

Member
Join Date
May 2005
Posts
13
Hi everyone,

I am having a little problem verifying some math results being done in DL06. Doing simple math in DL06 suppose to be relatively easy and straight forward but I must be doing something wrong that my results are not coming out correctly.

here's part of my program:

LD V2020 -- V2020 contains integer 50
DIVR R4 -- dividing accumulator by real # 4.0
OUTD V2022 -- save result (should be 12.5) to V2022
LDR R320000 -- load real # 320,000 into accumulator
DIVR V2022 -- divide accumulator by what's in V2022
OUTD V2024 -- store result into V2024

but my "DATA VIEW" shows V2022 = 12 and V2024 is some garbage #. I tried looking at it w/ BCD, decimal, real... none of the options would give me the correct number.

Can anyone see what I am doing wrong? Any help would be greatly appreciated.

Thnx,
--tong
 
The problem is your first instruction. Actually it's ok but after it executes the accumulator holds the BCD number 50. Then you attempt to divide by a REAL number. This is apples and oranges. It doesn't work.

Unfortunately there's not a BCD to REAL command. It must be done in 2 steps. So, after your first instruction place these:

BIN - converts the BCD number in the accumulator to a binary number
BTOR - converts a binary number to its REAL representation

Your other instructions should then work fine. View the final result as a REAL number
 
bernie_carlton said:
The problem is your first instruction. Actually it's ok but after it executes the accumulator holds the BCD number 50. Then you attempt to divide by a REAL number. This is apples and oranges. It doesn't work.

Well...

We really don't know that it contains a BCD number. All Qlingtime said was "V2020 contains integer 50". It could be a Decimal integer. In which case all he needs is a BTOR.

If it is indeed a BCD number (Ie. it reads correctly as an integer when viewed with BCD/Hex) then Bernie is absolutely correct.

In any case it is apples and oranges as Bernie has suggested. The number formats must match. Otherwise you get garbage out.
 
I made a bad assumption when I thought if i divide by a real #, the result would automatically become real.

Thanks very much, I'll try that out this weekend.
 
thanks very much guys, I only had to do a BTOR and all my munbers came out correctly.

You guys are the greatest :)
 

Similar Topics

hey Guys, I want to take my five counters, add them and multiple by 10, I got it to work, but WAY to many lines. Any suggestions...
Replies
2
Views
1,781
Guys I'm sure this is simple, its just not for me. if an i/p is calibrated for 10-50ma input equals 6-50psi out. what is the out at 25ma? What...
Replies
5
Views
2,143
Hi all, Writng a FB in ST on Beckhoff TC for a pulser which turns on and off on a cycle, is paused by turning bControlInput to FALSE, but resumes...
Replies
4
Views
65
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
248
I have a program that does a 7 second "scan" sensor calibration routine whenever a setting (setting is called assistance level or "AL" and ranges...
Replies
3
Views
172
Back
Top Bottom