We use cookies to provide our visitors with an optimal site experience. View our privacy notice and cookie notice to learn more about how we use cookies and how to manage your settings. By proceeding on our website you consent to the use of cookies.
What are real code and complementary code in rotary DIP switches?
Answer:
There are two types of rotary DIP switch output methods: real codes and complementary codes. Most codes are real codes (positive logic), but the opposite codes are complementary. The codes are selected according to the circuit design at microcontroller input.
Explanation:
Omron rotary DIP switches have a 4-bit signal output, and the real and complementary code outputs are below. Our rotary DIP switches have both output codes for A6A, while other rotary DIP switches have only real codes.
Those various codes are mostly a historic / confusing thing today. They used to be more important decades ago, when swiches were connected to hardwired logic. Whether a switch common was connected to gnd or vcc, or what was the required functionality, changed the required code unless another ic (a set of inverters) was added. Nowadays the different codes are easy to adopt in software, and I’ve sometimes even coded somewhere a bit that lets easily select the code in the swithches, based on what is available at the manufacturing day. May be easier to turn that bit in the sw than wait another 2 months for swithces with a different code.
Thank you for the inspiration for this related post.
I agree that the actual device isn’t too important as it is easy to change the values in the code. However, at a system level the complementary switch may be better as it provides positive logic input to the microcontroller. That is assuming internal pull-up resistors are used. Less mental work and faster troubleshooting.
Then again, as you suggested, a single bit or zero-Ohm jumper will keep the production line running.