Direct Soft - Stripping digits right of decimal

R_C

Member
Join Date
Apr 2005
Posts
93
Coming from an Allen Bradley background. I have a value that is 0.0006789 I would like to only display 0.00067. Stripping off any digits after the 5 place past the decimal. How can this be done using DirectSoft with a D0-06DR?
 
You could try this (assuming you are using floating point):

STR SP1
LDD V2000 (Where the float is stored)
MULR R100000 (Move the decimal out to where we won't lose what we want)
RTOB (Convert to Integer to drop off extra decimal places)
BTOR (Back to Float)
DIVR R100000 (Reverse the multiplication earlier)
OUTD V2002

Note: Floating point is inherently inaccurate and there is no guarantee that the above will work with every number. Trying to represent an infinite series of numbers as floating point is impossible and certain combinations will always show up as more or less digits than you really want.

With that said, you might want to just move it to an integer and have the HMI use implied decimal places to get it to display as you want.
 
Last edited:
The value is a Real DWord, and can be positive or negative. I am using this value as a display on C-More panel.
Any more suggestions?
 
In the numeric display object under 'Number of Digits' play with the 'total' and 'fractional' settings. If your number will frequently get very close to zero then under 'Panal Manager' check 'Disable Exponent Notation' to prevent the switchover.

Don't even bother with trying to process in the PLC if this is only for display.
 

Similar Topics

I have written one program with FDB. Thought I could therefor write code for an automation direct DL-06. Huge learning curve. I believe I have...
Replies
3
Views
1,760
Hey All, I got an older piece of equipment here, controls done with an Automation Direct 06 plc (OEM is long gone). I'm trying to piece together...
Replies
11
Views
2,376
Hello everyone, I have a customer that needs some help and I dont really understand the question so im posting it here, I think he is over...
Replies
16
Views
3,893
Hello all, I am trying to synchronize the speed of two motors so that once an operator sets them both where they want they can push a button that...
Replies
4
Views
2,711
I am working with a DL 205, DL250-1 CPU, D2-16ND3-2 Digital input module. I am writing a ladder that will send the value from the digital input...
Replies
0
Views
1,229
Back
Top Bottom