Previous in Forum: Biomass, Moisture and impurities control   Next in Forum: Cable Modem Problems
Close
Close
Close
9 comments
Rate Comments: Nested
Member

Join Date: Jan 2007
Location: KL, Malaysia
Posts: 9

Boolean Convert to Integer value

11/25/2008 3:25 AM

I have 12 bit and i would like to convert those 12 bit status into integer number show from 1 to 12. May i know how to do it in PLC program? What is the standard function i can use to do this. Those 12 bits only one bit will trigger on during whole control. Thank you very much

Vince

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#1

Re: Boolean Convert to Integer value

11/25/2008 4:44 AM

Hi, Vince,

What PLC are you using?

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Member

Join Date: Jan 2007
Location: KL, Malaysia
Posts: 9
#8
In reply to #1

Re: Boolean Convert to Integer value

11/27/2008 12:16 AM

I am using siemens S7-300. Sorry for late reply :)

Register to Reply
Guru
Engineering Fields - Marine Engineering - New Member

Join Date: May 2007
Location: Australia.
Posts: 1642
Good Answers: 81
#2

Re: Boolean Convert to Integer value

11/25/2008 5:25 AM

000000000000 = 0

000000000001 = 1

000000000010 = 2

000000000011 = 3

000000000100 = 4

000000000101 = 5

000000000110 = 6

000000000111 = 7

000000001000 = 8

000000001001 = 9

000000001010 = 10

000000001011 = 11

000000001100 = 12

?????

Regards JD.

Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#3
In reply to #2

Re: Boolean Convert to Integer value

11/25/2008 6:51 AM

Hi, JD,

I think he means

000000000001 = 1

000000000010 = 2

000000000100 = 3

etc.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 3)
Guru
Popular Science - Weaponology - New Member Safety - ESD - New Member Hobbies - Fishing - New Member

Join Date: Sep 2006
Location: Near Frankfurt am Main, Germany. 50.390866N, 8.884827E
Posts: 17996
Good Answers: 200
#7
In reply to #3

Re: Boolean Convert to Integer value

11/26/2008 7:22 AM

I understand exactly what you meant, it was also what our Blogger intended us to understand I believe too, but some of our other CR4 brethren got confused with normal binary!!!!!!!

***Forgive them as they know not what they do!!!***

Or you could call them Chumps!!! But the Yanks among them may not understand that either!!!

__________________
"What others say about you reveals more about them, than it does you." Anon.
Register to Reply
Guru
Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: El Lago, Texas, USA
Posts: 2639
Good Answers: 65
#4

Re: Boolean Convert to Integer value

11/25/2008 8:31 AM

Start with your output device. What indication do you want for your integers? If you want something like a 7 segment display then you will need to generate the correct code for each integer. Then set up a table like this:

000000000001 = code for 1

000000000010 = code for 2, etc.

Then you can do a Karnaugh map or Quine-McCluskey logic reduction for each bit of the code, and that will tell you what goes in your PLD. Assuming you don't have PLD sw that will do that reduction for you.

http://en.wikipedia.org/wiki/Karnaugh_map

http://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm

Register to Reply
Guru
Popular Science - Weaponology - New Member Netherlands - Member - New Member Fans of Old Computers - Commodore 64 - New Member

Join Date: Sep 2007
Location: Japan
Posts: 2703
Good Answers: 38
#5

Re: Boolean Convert to Integer value

11/25/2008 10:52 PM

Do you only use only the PLC instruction set or are you different software to set the PLC?

the easiest way i to add it with a masked bit

__________________
From the Movie "The Big Lebowski" Don't pee on the carpet man!
Register to Reply
Member

Join Date: Apr 2008
Location: Bangalore, India
Posts: 7
#6

Re: Boolean Convert to Integer value

11/25/2008 11:56 PM

Use a BCD to integer converter function in the PLC. This will solve your problem.

Move all the 12 bits into a temporary register. Then use the BCD to integer converter function to convert the Temporary register value to Integer value.

Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#9

Re: Boolean Convert to Integer value

11/27/2008 4:18 AM

Here's an algorithm using SHIFT RIGHT (SRW). No error checking is done; it is assumed that only one bit is set in INPUT.

[Note that this will loop forever (or until RESULT overflows & causes a crash) if INPUT is negative (i.e. high order bit is set) on entry. Edit - zeros are shifted in from the left.]

  1. RESULT=0
  2. INPUT =0 ? Y, DONE
  3. RESULT = RESULT + 1
  4. SRW INPUT
  5. GO TO 2

There are lots of ways of doing it in a loop - e.g. you could use CC1, which holds the bit shifted out after the SRW.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Register to Reply 9 comments
Copy to Clipboard

Users who posted comments:

Andy Germany (1); bhankiii (1); Epke (1); jdretired (1); JohnDG (3); protecsol (1); vince_02brad@yahoo.co.uk (1)

Previous in Forum: Biomass, Moisture and impurities control   Next in Forum: Cable Modem Problems
You might be interested in: Router Bits, Bit Error Rate Testers, Drill Bits

Advertisement