Decimals in RSLOGIX 500

LWCiak

Member
Join Date
Apr 2014
Location
Utah
Posts
21
Let me start by saying: "ARRRRRRRRRRGGHHHHHHH"
I cannot for the life of me figure out how to use decimals in RL.:cry:
For example:
I am writing the code to simulate a Coke machine.
The number of coins and or dollar bills routines are ok.
The problem I have is determining the total amount of money inserted.

For example: I have inserted 5 dimes. (ACC=5) I then need to convert to 50 (.50) cents.
After all coins, quarters, nickles or dollar bills have been inserted, I need these converted numbers to be totaled and compared to the product price for dispensing.

I'm STUCK!:mad:

Short version: How can I get a decimal result.

I have searched hi and low - low and high, and googled it to death.

Any help or answers or pointers will be appreciated.🍺

TIA
Malt aka LWCiak
 
If your counter accumulator is counting $0.10 then simply multiplying it by 0.1 gives you how many $

e.g.

Counter.ACC = 5

5 * 0.1 = $0.50

373 * 0.1 = $3.73

Are you getting stuck because the counter accumulator is an integer value, and you want a floating-point result ? Fear not, you can mix data-types in any math instructions without worrying about it, just be conscious of the data-type of the result...

Use separate counters for each of the coin and bill values, multiply each counter accumulator by it's $ value, and add the results together..... seems simple and straightforward, or am I missing something ?
 
Last edited:
Make sure you're writing the number wanted into a Float number (normally File F8) (except for Micrologix which doesn't support them).

Else use an integer 100 times greater than you want & remember it's counting by pennies, not dollars.
 
I just thought of another option, count by pennies in an integer, but check that integer to see if it's ever GEQ 100, if yes subtract 100 from itself & add 1 to another integer that counts dollars - so one integer gives you dollars & the second gives you cents.

If you are using a HMI to show the value, run the two integers together with a period between them to show the true value.
 
Make sure you're writing the number wanted into a Float number (normally File F8) (except for Micrologix which doesn't support them).

Else use an integer 100 times greater than you want & remember it's counting by pennies, not dollars.

Some MicroLogix processors support Floating-Point data files. If yours doesn't, then treat everything as pennies, as Aabeck suggests. Let's hope your coke machine doesn't sell more than ÂŁ327 of coke in each "accounting period".

Aabeck types fast - and provided a workable solution to the numeric limitations of an Integer.
 
I need to find one that does, I have a ML1000 here at home to play (I mean test) with that I have been using.

You don't need to spend money, just work with what you've got....

And you don't need to use counters either...

just ADD the penny count for a coin to an integer register each time a coin is inserted.

then if that integer register is >= 100, ADD 1 to a $ value, and subtract 100 from the penny value

Now your coke machine can handle sales up to $32767.99 for each accounting period... bet you wish you had a few of them..!!
 
The MicroLogix 1000 was based on the SLC-5/02 operating system, and does not support floating-point data types.

All of the other MicroLogix started out using the "Enhanced" 5/03 operating system as a baseline, so they support floating point.

The MicroLogix 1100/1400 were a clean-sheet operating system designs but they were building on a basic instruction set from the SLC-500 family.
 
Just checked, Ken, 1200 series A or B doesn't support F files, they come up as "Reserved", and you can't create an F file.

Series C provides a default F file, and allows you to create new F files.
 

Similar Topics

Hey there. I have a quick question about displaying data WITH a dcimal place. I am reading a tag from my Compact Logix. Lets say it looks like...
Replies
2
Views
1,522
I'm working with Logix 500 and trying to do a percentage. I have my 2 values, coming from n7:89 and n7:100, and used the divide command. This...
Replies
3
Views
1,400
I really need your help here! I have a Decimal Number that is being transferred in 1-byte words. The original number is larger than 1 byte...
Replies
2
Views
2,370
Hi what will be the value shown in the analog address memory read by PLC if I have 4-20 mA or 0-10v sensor signal,will this be 0 to 32000...
Replies
6
Views
2,840
Other than using a floating point, is there anyway to enter a decimal into a allen bradley 5 processor-like into a n7 file... using rslogix5 ...
Replies
7
Views
1,811
Back
Top Bottom