You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old September 19th, 2018, 03:31 PM   #1
Lallers66
Member
United States

Lallers66 is offline
 
Lallers66's Avatar
 
Join Date: Jul 2017
Location: California
Posts: 7
BCD conversion

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.
  Reply With Quote
Old September 19th, 2018, 03:40 PM   #2
Ken Roach
Lifetime Supporting Member + Moderator
United States

Ken Roach is offline
 
Ken Roach's Avatar
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 14,169
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 by Ken Roach; September 19th, 2018 at 03:49 PM.
  Reply With Quote
Old September 19th, 2018, 04:01 PM   #3
Ken Roach
Lifetime Supporting Member + Moderator
United States

Ken Roach is offline
 
Ken Roach's Avatar
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 14,169
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:
Attached Images
File Type: png Volume_Calc1.png (29.9 KB, 38 views)
  Reply With Quote
Old September 19th, 2018, 04:36 PM   #4
Lallers66
Member
United States

Lallers66 is offline
 
Lallers66's Avatar
 
Join Date: Jul 2017
Location: California
Posts: 7
Bloody brilliant.

Thank you Ken.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Migrating FactoryTalk View Projects to Windows 7 64 bit Rob S. LIVE PLC Questions And Answers 27 November 29th, 2015 08:17 AM
BCD to Integer conversion DellSuperman LIVE PLC Questions And Answers 2 April 15th, 2011 01:14 AM
BCD conversion bigrthanur LIVE PLC Questions And Answers 15 March 27th, 2009 07:29 AM
BCD conversion error Annie LIVE PLC Questions And Answers 1 August 27th, 2007 02:39 AM
BCD conversion error Krcedinac LIVE PLC Questions And Answers 10 June 26th, 2007 12:58 PM


All times are GMT -5. The time now is 01:49 PM.


.