Lucky Resistor
Menu
  • Home
  • Learn
    • Learn C++
    • Product Photography for Electronics
      • Required Equipment and Software
    • Soldering for Show
  • Projects
  • Libraries
  • Applications
  • Shop
  • About
    • About Me
    • Contact
    • Stay Informed
  •  
Menu

Let’s Print a Cat/Pet Feeding Device (Part 6)

Posted on 2021-02-182021-10-25 by Lucky Resistor

The sixth part of this series is all about the input panel. We will talk about the layout of the front panel, the rotary encoder as the main component and I will explain my example circuit and board. As usual, you will find all required files as a free download from the GIT repository. If you missed one of the previous parts, visit the overview page to access them.

  • Downloads
  • About the Input Panel
    • Locations of the Input Panel Elements
    • About the Rotary Encoder
    • The Knob
    • Print this Knob
    • The LEDs
  • The Board Design Example
    • How to Order the Board
  • Elements of the Design
    • The Controller Connector
    • The Rotary Encoder and Filter
    • The Voltage-Level Shifter for the Display
    • The Power Controller for the Display
    • The Display Connector
    • The Four LEDs
  • Test the Panel
  • Conclusion
  • More Posts

Downloads

You will find all required files for the electronics and prints in the following GitHub repository:

Git Repository

Creative Commons Licence
Pet Feeder by Lucky Resistor is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Based on a work at https://luckyresistor.me.

About the Input Panel

The input panel has three main elements:

  • The LCD display, we covered in the fourth part of the series.
  • A rotary encoder with push function for any user input.
  • Four LEDs as a simple and visual status display.

In this part, we focus on the last two elements and how they are installed in the front panel. I assume, you already installed the LCD display in the front panel and it is ready for use.

The rotary encoder and the four LEDs are installed using a single board. It has four screw holes for M3 screws to fasten it to the front panel. These screws press the board to the plastic of the front panel, which creates a rigid construction to hold the rotary encoder at the right spot.

You need a rigid construction like this for a rotary encoder. There are not only forces to the sides while the user rotates the knob, there is an especially high force if the knob is pressed. Either you make sure your board is well attached to the front panel, or alternatively you provide supports, like grooves to hold the board in place.

If you design your own board, but use the standard front, you have to place the screw holes, rotary encoder and the LEDs at the right locations.

Locations of the Input Panel Elements

The locations for the screws, rotary encoder and LED follow a simple layout. You can see all locations and distances in the design above. For the M3 screws, I recommend 3.5mm diameter holes. These slightly larger holes will give some wiggle room for fine adjustments or in case the threads aren’t perfectly centred in the front panel.

For the rotary encoder, the location marks the center of the axis of the component. If you create a design from scratch, make sure you set the zero point of the rotary encoder footprint to the center of the axis.

For the LEDs, the location should be the centre of the lens. While the front panel is designed for 5mm LEDs, it will also work with 3mm LEDs and even with SMD LEDs in various package sizes.

About the Rotary Encoder

The rotary encoder has to be placed with its axis in the middle of the opening for the knob. For my input panel board, I use the Bourns PEC12R-4220F-S0024 rotary encoder. These encoders are cheap and reliable, with 24 steps per rotation and a nice tactile push feeling. If you like to invest in a really good one, check the E33 series from ELMA.

Incremental rotary encoders use two signals to transmit the rotation data to a processor. In most data sheets, you will find a signal/time diagram like this:

It’s made for the electrical engineer with an oscilloscope world-view. If you have more like a programmer-view of the world, you can think of it as a special sequence of two-bit binary numbers:

    A B  #
    0 0  0  CW ↓  
    1 0  1
    1 1  3
    0 1  2
    0 0  0
    1 0  1
    1 1  3  CCW ↑
    0 1  2

The Knob

The knob sits directly on the axis of the rotary encoder.

To fasten the knob to the rotary encoder, there is a hole where you insert an M3 grub screw.

Print this Knob

If you are using my example board and the recommended Bourns rotary encoder, you can print the knob as it is, using the file LR2051-421A.stl from the GIT repository.

  • File: LR2051-421A.stl
  • Material: PETG (Galaxy Black)
  • Layer height: 0.2 mm
  • Print bed: Powder coated
  • Supports: No supports required
  • Difficulty: Easy

The LEDs

The front panel design is made for 5mm LEDs. These produce a distinct light effect you can see in the demo video. Yet, it perfectly works with 3mm LEDs and SMD LEDs with various package sizes.

Best you do some tests before you design a own board, to make sure you get a nice light effect for the indicator.

The Board Design Example

I created a design example for the input panel board you can use on your own device. The design is modular and can be adjusted to your use, using various jumpers. Alternatively, just use the design as a good starting point and adjust it using your own components. Or even design a board from scratch and use this example as inspiration.

The board is a simple two-layer board with the rotary encoder and LEDs on the bottom side and all other components on the top side.

How to Order the Board

If you plan to use the original design, you can order the board from OSHpark using the following link:

Order from OSH Park

Alternatively, you find Gerber files, Eagle files and a Fusion360 design in the GitHub repository. Use them to order the boards from your favourite PCB manufacturer or as a good starting point for your custom design.

Elements of the Design

In the following sections, I will show parts of the circuit schema. You find the complete schema as PDF in the GitHub repository or here.

The Controller Connector

If you have a separate input panel, you need a connection between these boards. I use a ribbon cable with 14 wires and the MicroMaTch system from TE to connect the two boards. In order to make the board as versatile as possible, I designed the footprint for the connector in a way to allow several different ways to connect the cable.

  • I personally recommend using the MicroMaTch system:
    • The female connector TE 1-2178711-4 for the board.
    • The male connector TE 1-2178712-4 for the ribbon cable.
    • It makes reliable connections you can easily connect and disconnect.
  • The pads are large enough to solder a ribbon cable directly to the pads.
  • There are holes where you can solder wires directly to the board.
  • These holes have the 0.2″ spacing to solder two 7 pin headers into it and use these as cheap connectors.

I had one line I did not use for the board, therefore I connected it to a trough-hole with the label USR and J3. You can use it as you like, e.g. as a chip-select line if you like to a communicate to the display via SPI.

The Rotary Encoder and Filter

The rotary encoder is used for all user input of the device. I use the Bourns PEC12R-4220F-S0024 component. These are relatively cheap ones, but well suited for a device like this.

The switches in rotary encoders are really noisy, so I added a filter circuit for the two incremental inputs. This simple filter with two resistors and one capacitor removes most of the noise so you can use interrupt-based processing in the MCU, with little digital filtering. All shown resistor and capacitor values are verified for this rotary encoder and provide a clean signal.

If you do not need the filter, or your MCU has superior digital filtering, you can omit these components and close the two solder jumpers JP1 and JP2.

There is no filter for the push function in the rotary encoder. It is also a noisy switch, but I assume you like to use this push button for some kind of wake-up functionality on the controller board. So I just added an optional pull-up resistor on the input board.

If you want a filter for the push button, you only have to add an additional resistor and capacitor on the controller board.

The Voltage-Level Shifter for the Display

I use Adafruit standard LED 20×4 display with the Adafruit I2C/SPI character LCD backpack which requires 5V, with a 3.3V microcontroller, so I have to shift the voltage for the I2C bus.

For the level shifting I use the Microchip TCA9517. This chip simplifies the level shifting and works with a wide range of voltages.

If you do not need voltage level shifting, or like to implement it on the controller, just close the jumpers JP8 and JP9. It will bypass the whole section.

You may not need all pull-up resistors, especially if you have other devices on the I2C bus. The shown 10kΩ values give quite a low pull-up. These work for the short cable lengths I have, up to 400kHz on the bus. If you run into communication problems on the I2C bus, you may to use lower values (try 4.7kΩ).

The Power Controller for the Display

If you design a battery powered device as I do, you want to save as much power as possible. I use the Microchip MIC2005A power distribution controller chip. It is a compromise: Using a one single chip simplifies the circuit with a output leakage current of typical 12µA.

For a lower leakage current, you can implement a circuit like this:

The key is to use a N- and P-channel MOSFET with a low leakage current.

There are two jumpers JP6 and JP7 to choose the voltage for the display, and in case you do not want to control the power of the LCD display, you can close JP5 to bypass this part of the circuit.

The Display Connector

The board has pads for a display connector as well. You have the same options as with the controller connector:

  • I personally recommend using the MicroMaTch system:
    • The female connector TE 2178711-4 for the board.
    • The male connector TE 2178712-4 for the ribbon cable.
    • It makes reliable connections you can easily connect and disconnect.
  • The pads are large enough to solder a ribbon cable directly to the pads.
  • There are holes where you can solder wires directly to the board.
  • These holes have the 0.2″ spacing to solder two 2 pin headers into it and use these as cheap connectors.

The Four LEDs

Use four 5mm or 3mm LEDs you like. For the best effect, test the brightness and effect first on the front panel. There are two solder jumpers, JP3 and JP4 you can use to select the input voltage for the LEDs. If you use 5V as input voltage, make sure the microcontroller you can handle the voltage.

E.g. if you use a LED with a forward voltage of 1.4V, the microcontroller has to handle 3.6V on the IO pin. Not many 3.3V microcontroller are rated to handle more than 0.2V over VCC.

I use a simple LED tester to find the current that produces the brightness I like.

Next, I select the resistor for the supply voltage, forward voltage of the LED and current. For convenience, I added tables with the some common values to the circuit schema.

Test the Panel

After building the panel, do some tests. You will find the Arduino code I used in the video in the GitHub repository.

I used the code on an Adafruit Feather M0, if you use other boards you may have to rearrange lines to different pins. You find the pin assignments at the begin of the code:

// The connections from the input panel to the pins of the MCU.
//
const uint8_t statusLed = 13;
const uint8_t led1 = 5;
const uint8_t led2 = 6;
const uint8_t led3 = 10;
const uint8_t led4 = 11;
const uint8_t displayEnable = 12;
const uint8_t buttonPush = 9;
const uint8_t buttonRotB = 0;
const uint8_t buttonRotA = 1;

Conclusion

I hope this part of the series gave you some inspiration for your input panel design.

In the next part, we will talk about the sensor board. It is a simple design with the components required to sense the rotation and if the compartments are filled.

If you have any questions, missed information, or simply want to provide feedback, feel free to comment below or contact me on Twitter. 😄

Continue to Part 7

More Posts

Get Blog Updates With the New Mailinglist

Get Blog Updates With the New Mailinglist

In a few days, I will stop using Twitter for project notifications. If you like to get notified about new projects and updates, please subscribe to the new mailing list: It is a low-frequency mailing ...
Read More
Large Update to the Circle Pattern Generator

Large Update to the Circle Pattern Generator

Today I published a significant update to the circle pattern generator. Version 1.4.1 of the application is available for macOS and Windows for download. This new version adds various shapes, rotations, colours and a generator ...
Read More
Three Ways to Integrate LED Light Into the Modular Lantern

Three Ways to Integrate LED Light Into the Modular Lantern

After creating the modular lantern system, I experimented with different cheap ways to integrate LED lights into it and turn it into a decorative lamp. In this post, I describe the three ways I found ...
Read More
Extreme Integers – Doom from Below

Extreme Integers – Doom from Below

As a beginner or immediate C++ programmer, you heard never mixing unsigned and signed integer types or avoiding unsigned integers at all. There was also this talk about undefined behaviour. Yet, in embedded software development, ...
Read More
Build a Sustainable Refillable Active Coal Filter

Build a Sustainable Refillable Active Coal Filter

If you ever used air filters to keep smells, fumes and dust at a low level in your workshop, you for sure came in contact with these expensive throwaway active coal filters. While throwing-away the ...
Read More
Logic Gates Puzzle 101

Logic Gates Puzzle 101

The message you got does not make any sense. Can you decypher it with the following logic puzzle? The circuit was not optimised for functionality but to create a challenging puzzle and gorgeous artwork. If ...
Read More

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay Updated

Join me on Mastodon!

Top Posts & Pages

  • Storage Boxes System for 3D Print
  • Build a 3D Printer Enclosure
  • Event-based Firmware (Part 1/2)
  • Yet Another Filament Filter
  • Circle Pattern Generator
  • Circle Pattern Generator
  • Projects
  • It's Time to Use #pragma once
  • Real Time Counter and Integer Overflow
  • Units of Measurements for Safe C++ Variables

Latest Posts

  • Better Bridging with Slicer Guides2023-02-04
  • Stronger 3D Printed Parts with Vertical Perimeter Linking2023-02-02
  • Logic Gates Puzzle 1012023-02-02
  • Candlelight Emulation – Complexity with Layering2023-02-01
  • Three Ways to Integrate LED Light Into the Modular Lantern2023-01-29
  • The 3D Printed Modular Lantern2023-01-17
  • Rail Grid Alternatives and More Interesting Updates2022-12-09
  • Large Update to the Circle Pattern Generator2022-11-10

Categories

  • 3D Printing
  • Build
  • Common
  • Fail
  • Fun
  • Learn
  • Projects
  • Puzzle
  • Recommendations
  • Request for Comments
  • Review
  • Software
Copyright (c)2022 by Lucky Resistor. All rights reserved.
 

Loading Comments...