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 7)

Posted on 2021-04-032021-10-25 by Lucky Resistor

The seventh part of this series is all about the sensor board. It hosts the position sensor and four fill sensors. Speaking of sensors sounds complex, but these are just pairs of IR-LEDs and phototransistors. All design files for the board are in the GitHub repository and if you missed one of the previous parts, look at the overview page.

  • Downloads
  • About the Sensor Board
  • The Position Sensor
    • Why using a 100kΩ Resistor?
    • Mechanical Design
  • The Fill Sensors
    • Mechanical Design
    • Fill Sensor Measurements
    • Connectors
  • How to Order the Board
  • 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 Sensor Board

The sensor board has two main functions: It contains the position sensor to rotate the turntable exactly one slot and there are four fill sensors to detect if food is in the compartments.

It is a minimal design, each sensor is a pair of IR LED with a phototransistor.

The Position Sensor

The circuit for the position sensor is straight forward. If VCC is applied to POS-IN, LED5 will light up, and there is a working voltage on Q5. If more light falls on the phototransistor, more current will flow from the collector to the emitter and therefore, the voltage on POS-OUT will drop.

You can see this voltage drop in the measurement above. With no light on the phototransistor, the voltage is around 3.0V and drops down to 1.5V.

Why using a 100kΩ Resistor?

Let’s have a look at the specification of the phototransistor:

The “Collector Dark Current” is at a maximum of 100nA and the “On State Collector Current” is typical around 3mA. You can imagine the circuit with R14 and Q5 as a voltage divider. To find a suitable value for R14, you just need to do a rough calculation how the phototransistor in this voltage divider will behave.

To simplify things, just assume the phototransistor is a resistor. At full light, it will passes a current of 3mA, therefore with 3.3V it will be a 1.1kΩ resistor.

With no light, it will pass in the worst case 100nA, which is like a 33MΩ resistor.

To be clear, a phototransistor will never act like a resistor. This is only a very rough estimation to see if the chosen resistor will give us measurements in a usable range.

The no light situation, with almost no current flowing makes no huge difference, no mater which resistor we choose for R14.

Choosing the right value for R14 ist about the some light situation. Here, the resistor defines how fast the voltage drops and how low it goes.

If we would have chosen an 1kΩ resistor, the voltage would never drop below 1.73V. It would be still possible to use the position sensor, but it limits the range of possible voltages. Also, with the 1kΩ resistor, you could not use a digital input to detect the position.

Probably, using a ~250kΩ resistor would have been better. Using these generic 10Ω, 100Ω, 1kΩ, 10kΩ, 100kΩ resistors reduces the number of different components on the board. It is the same reason, why I use an 100Ω resistor in front of the IR LED and not a 82Ω one.

Mechanical Design

I repeat this part for completeness: The turntable has five position slots.

They lead into a small excavation, reflecting the light from the infrared LED to the phototransistor.

The Fill Sensors

The circuit for the fill sensors is similar to the position sensor. There are four inputs, SENS-IN-1 to SENS-IN-4, but only one output line SENS-OUT. The output is pulled low, with resistor R2. If all inputs are at GND, SENS-OUT is at GND too.

Now if you set one of the inputs to VCC, the IR LED in the compartment lights up and the phototransistor gets a voltage at its collector. Therefore, you only measure the response on one single phototransistor. All other phototransistors will get a voltage on the emitter and will block most of the current flowing back to GND.

If you look into the data sheet of the PT333-3B, there is a “Emitter-Collector Breakdown Voltage” of minimum 5V. Because your input voltage never exceeds 3.3V, this should be no problem at all.

Still, it is important you set all unused inputs to GND and do not keep these lines in a high-z state. Otherwise, very little current will flow in reverse through all other phototransistors, and through all other IR LEDs – which would distort the measurements.

The arrangement is reversed compared to the position sensor. If the phototransistor passes more current, the voltage will rise.

If no light is received by the phototransistor, the output is at a low voltage level.

A resistor is not a great simulation of a phototransistor, but it is enough to roughly verify the values.

Mechanical Design

If the compartment is empty, the light from the IR LED is reflected at the sides and the lid back to the phototransistor in the middle. Therefore, we get a high voltage reading from the sensor.

If food filled in the compartment, the light is blocked. Therefore, we get a lower voltage reading.

Fill Sensor Measurements

If you look at actual measurements, there is an initial voltage spike before the phototransistor stabilises. I am not sure what causing this effect. I tried to simulate the circuit using NPN transistors, but never got this spikes.

After 30ms, the signal stabilises, so I wait 50ms before I read the value from the ADC. At a later time, I will publish detailed measurements with different revisions of the turntable platform.

Connectors

The last element on the board are connectors to connect it with the controller board.

There are pads to solder a TE MicroMaTch or similar connector to the board and eight plated through-holes. So you have different methods to chose, connecting this board with the controller.

  • I personally recommend using the MicroMaTch system:
    • The female connector TE 2178711-8 for the board.
    • The male connector TE 2178712-8 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 plated through-holes where you can solder wires directly to the board.

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.

Conclusion

I hope this part gave you an idea, how to design the sensor board. Instead of a complex design, I use something simple and reliable and solve smaller problems in software.

In the next part, I will talk about the controller board. It will complete the electronic design, host the microcontroller and stepper motor driver. As stated at the begin of this series, I have no plans to provide ready made controller boards for the device. Therefore it may take a while until the next part is released. If it does, it will contain details about the controller I personally built and tested.

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

 

More Posts

The Importance of Wall Profiles in 3D Printing

The Importance of Wall Profiles in 3D Printing

In this post, I write about wall profiles in 3D printing, and I will explain why they are essential to creating stable parts with minimal filament use. Also, I will show common mistakes that result ...
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
Better Bridging with Slicer Guides

Better Bridging with Slicer Guides

I got questions about a particular feature you find if some of my 3D models. In this short text, I will explain why I add it and why you should add features like this too ...
Read More
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
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
Update to the Storage Boxes System

Update to the Storage Boxes System

Last week I sent all subscribers a small update to my storage boxes system. There are new split boxes for the tall boxes (LR2052-300C-S) and a new extensive PDF catalogue with a great overview, but ...
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

  • How and Why to use Namespaces
  • Storage Boxes System for 3D Print
  • Use Enum with More Class!
  • Circle Pattern Generator
  • Real Time Counter and Integer Overflow
  • Circle Pattern Generator
  • Logic Gates Puzzles
  • C++ Templates for Embedded Code
  • C++ Templates for Embedded Code (Part 2)
  • Logic Gates Puzzle 101

Latest Posts

  • The Importance of Wall Profiles in 3D Printing2023-02-12
  • The Hinges and its Secrets for Perfect PETG Print2023-02-07
  • 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

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...