BCD conversion

Lallers66

Member
Join Date
Jul 2017
Location
California
Posts
7
Hi there.

I have a Micrologix 1100, I have 6 switches to I:0/0 through I:0/5.

My plan is to use I:0/0 to I:0/3 as set for a value of 0-15.
I:0/4 and I:0/5 for the values 0, 1/4, 1/2 and 3/4

This will be combined later for a total range of 0-15.75 gallons.

I have tried COP function to move the first 4 values into a N7 and then use the FRD function.

But I can't get it on how to use only the first 4 and the other 2 separate from each other.

I:0/6 through I:0/9 will be used for other.

I will use this value of volume, use a flowmeter to fill this predetermined volume in a vessel.

Any help is appreciated.
 
Four bits to represent the values 0-15 is ordinary binary, not Binary Coded Decimal (BCD). You don't need an FRD instruction.

Instead, just use a Masked Move:

Source: I:0
Mask: 000Fh
Destination: N7:0

At that point N7:0 will be your integer from 0 to 15.

I would manually use two rungs with XIC - OTE to move Inputs 4 and 5 into Bits 00 and 01 of N7:1.

If you want to be explicit in what you're doing, you could do the same instead of using a masked move for the whole gallons portion too.

Multiple N7:1 times 0.25 gallons. Make the destination a Floating Point register, since A-B automatically converts from Integer to Real in the MUL instruction.

Add the Whole Gallons to the Quarter Gallons and you've got your Tank volume preset.
 
Last edited:
I get some grief for it from our younger programmers, but I often do stuff like this with brute-force ladder logic because I consider it easier to understand. Four bits don't make up that huge a rung, and the benefit of using a masked move is trivial compared to four bit instructions.

Like so:

Volume_Calc1.png
 

Similar Topics

Hi. I’m doing a PV 1400e to PVP 7 migration and I don’t know how to convert the old 8digit BCD type from PB1400e into something that will work on...
Replies
2
Views
569
Hi all, I am quite new to PLC programming, so pardon my noob-ness. First, I have counters & timers in my program that I use to calculate total...
Replies
2
Views
3,506
Hello! I am working on a project and have a question. I need to take a 16 bit word and convert it into bianary 1's and 0's. I will be pulling...
Replies
15
Views
5,416
Hi, I recently added a BCD to int conversion block to compare 2 MW. The CPU has a SF error.In the diagnostic area it shows BCD conversion error. I...
Replies
1
Views
4,982
Hello to all, Yesterday the production line stoped and since then we have SF light on the PLC (S7 315-2DP). Here is the screen shoot of the...
Replies
10
Views
6,491
Back
Top Bottom