Input Devices


  • Measure something: add a sensor to a microcontroller board that you have designed and read it.

What should be done

  • Described your design and fabrication process using words/images/screenshots.
  • Explained the programming process/es you used and how the microcontroller datasheet helped you.
  • Explained problems and how you fixed them
  • Included original design files and code

In this assignment I will be creating an SMD components tape counter which should count how many SMD components are in a cut tape (or reel).


The device will use synchronous detection which uses a phototransistor and LED as an encoder to detect the holes on the tape's side and count the components according to the count of these holes and the distance between them.

For Example, from the chip resistor packing datasheet of Yageo, the manufacturer of SMD resistors of the Fab Inventory:

So, by counting the holes on the tape we will be able to count how many components are in it.

Testing the Phototransistor

As the aim here is developing an optical encode, I wanted to test the Synchronous Detection example.

The problem was that we are almost running out of OP580DA phototransistor. Which is now obsolete according to digikey page. Also we ran out of the PT15-21C/TR8 visible-light phototransistor; So I order an alternative from Farnell UK "we have a distributer here in Egypt" KP-3216P3C .

Also, we ran out of FTDI pin headers (S1143E-36-ND ) and what was available was right angle SMD pin headers (WURTH ELEKTRONIK 61003218221).

KP-3216P3C is a 1206 package component and WURTH ELEKTRONIK 61003218221 has a different pad configuration descried in their drawing.

So, I had to change the boards accordingly.

This was a nice opportunity to test electronics design using .cad files. I changed the cad file for the board and rendered it using the old fabmodules.

Now after fabrication of the board, I went to see if the pin headers fits.

And it did. Although I mistakingly cut 5 pin headers instead of 6, the last one wasn't connected (RTS) so it didn't matter here.

The thing that I found here is that probably I need another alternative pad configuration for the headers if the available first pin in the row is on the opposite direction to decrease waste.

And then I soldered and programmed the board using the example code without modifications.

When running the code, I found that the difference in value isn't significant.

After some debugging, I found that the problem was that the phototransistor was reversed as I misread its datasheet. After reversing it it worked fine.

The Encoder Boards

I started designing the "Components Counter" board. The target here was to design 3 boards.

  • The main board:which will contain the MCU and a 2x2 pin header two connect to the other two boards.
  • The LED board:which will pulsate an LED which is controlled by PBP3.
  • The phototransistor board:which will read the light intensity difference and detect when a hole passes between it and the LED.

The cut tape will run between the two boards and the holes will run between the LED and the phototransistor.

I designed the main board by removing the phototransistor and the LED along with their pull-up resistors. I did this by modifying the .cad file.

TODO: Add diff

And for the LED and Phototransistor board. I sketched out the board with their connections.

The aim was to make the LED and Phototranistor be in the center of the height on one side of the boards to create a straight beam and the connector on the other sides and a border to be able to slide them into slots.

And the designed the in .cad and fabricated them.

As I was soldering the phototransistor I found that I routed the wrong connection so I edited the board and made it again.

TODO: Add diff