element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Back to Karnaugh
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: SGarciaV
  • Date Created: 2 Aug 2014 1:31 AM Date Created
  • Views 699 views
  • Likes 1 like
  • Comments 5 comments
Related
Recommended

Back to Karnaugh

SGarciaV
SGarciaV
2 Aug 2014

Back in school I had a few courses in digital electronics, so Karnaugh maps were not something alien to me. Unfortunately, my life experience never took me down a path where I had to simplify Boolean equations.

 

A current software development project required a screen with various UI options to allow the user to configure the application. Among the usual validations that I had to perform on the entered selections was one that was somewhat unusual.

 

The application provides logging functionality and also calls an external process that also performs logging functions. In both cases the folder location of the log file can be specified by the user. The UI elements to handle this were the following:

 

    1. A checkbox that allows the user to either enable or disable logging for the application.
    2. Another checkbox to specify that the external application should use the same log folder as the calling app.
    3. A text field where the user types in a valid folder specification where the log file will be created.

 

The validation is a success when either of these checkboxes are ticked and the folder specification is valid or when neither checkbox is ticked. Of course, I could have just put together an interesting IF statement that would accomplish the required tests, but I wondered if I could put together one Boolean formula (function) that would return the status of the validation given the rules above.

 

That’s when I remembered the Karnaugh maps. I also came to the realization that I did not remember how to use these maps. I already had the truth table:

 

a = Log enable/disable check box

b = External app uses same log folder as main app check box

c = Valid folder specification text field

 

 

a b c    Valid

0  0  0    1

0  0  1    1

0  1  0    0

0  1  1    1

1  0  0    0

1  0  1    1

1  1  0    0

1  1  1    1

 

I just needed to remember the technique for setting up the map, inserting the result values and deriving the resultant Boolean formula. After doing some research and reading I managed to perform the first two steps (left side of image):

I should note that I had completely forgotten that little rule that indicates that the rows (or columns) should be numbered such that only one bit changes. I had initially numbered the rows 00, 01, 10 and 11, but when I read that I changed it as shown above.image

 

After a bit more research I understood how to get the formula’s terms which are also shown above. The translation of this formula to code was easy from here:

 

Function fLoggingUIIsValid() as Boolean

 

    Return (Not chkboxEnLog.Checked and Not chkboxXAppLog.Checked) or

                     fFolderExists(txtboxLogFolder.Text)

End Function

 

And there it is. This worked nicely for my purposes. Regards.

  • Sign in to reply

Top Comments

  • michaelkellett
    michaelkellett over 11 years ago in reply to shabaz +1
    Frequently there is no point in optimizing the detail of the code if you are using a high level language (especially C or if logic VHDL or Verilog). The compiler/synthesiser will often do a better job…
Parents
  • SGarciaV
    SGarciaV over 11 years ago

    Thanks for the remarks all.

     

    Shabaz, your function will work as well. I guess I am just in the habit of testing for valid results, not invalid. Your code reflects a conversion of my formula from sum of products (/a/b + c) to product of sums (a+b) AND /c. The production code will contain enough of an explanation to allow me and anyone else to understand what the function is doing. I have way too many projects and will most likely not remember this function within a few months.

     

    Mcb1. In boolean algebra, the "+" operator is commonly used to denote an OR operation as a dot at mid height represents a AND operation. Having the formula /a/b + c is the same as saying not a AND not b OR c. Perhaps a bit clearer would be ((not a) AND (not b)) OR c. I hope I've answered your question since I am not sure if I understood it. Salvador

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 11 years ago in reply to SGarciaV

    Salvador

    In boolean algebra, the "+" operator is commonly used to denote an OR operation as a dot at mid height represents a AND operation

    never took algebra ...too keen to get away from school into work.

    Funnily enough maths has become very important in software image

     

    Thanks

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • mcb1
    mcb1 over 11 years ago in reply to SGarciaV

    Salvador

    In boolean algebra, the "+" operator is commonly used to denote an OR operation as a dot at mid height represents a AND operation

    never took algebra ...too keen to get away from school into work.

    Funnily enough maths has become very important in software image

     

    Thanks

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube