Group Assignment

Probe an input device's analog levels and digital signals

First, it is neccesary to notice that exist different input devices. I found something very useful that help me understand at Lydia Kuo - Fab Academy 2023 Web Page. We decided to test a photoresistor module for the analog signal and flame detector (digital flame) as digital signal.

Photoresistor module

Flame Detector

Please for group assignment details visit Anderson Zelarayan Web Page.

Individual Assignment

Selecting the input device

With my instructor support, we review the components that I'm gonna need for my final project in order to select input device. The only input is a limit switch, that is going to activate all the complete system to stop the stepper motor that will show the funko. The following picture show the potential devices that I would use for my final project.

Board Components

By acknowledging that switch function we select the following components for this main board:

  1. One Micro Switch 3P SPDT 1A 125V AC
  2. Male connector header 90° 1x3 (GND+2DIO)
  3. Resistor 1k

Micro Switch

Switches are basic methods for opening and closing an electrical circuit. Microswitch, also called a miniature snap-action switch, often used as safety devices because of their reliability and sensitivity. The micro switch has three pins: Common (C), Normally Closing (NC), and Normally Opening (NO). Here, the Common pin is an input pin, the NC pin is Output 1, and the NO pin is Output 2. The working principle of a micro switch is that when it touches an object, the contacts change position.
The normally closed pin of the circuit is opened and the normally open pin is closed when you press the lever of the switch. In the same way, when you open the lever of the switch, then the normally closed or NC pin of the circuit will carry the current, while the normally open or NO pin of the circuit can isolate electrically. There are different types of microswitches, for more details visit Eleron Web Page.

Regarding switches types, the circuits vary from simple make/break circuits to multi-makes and multi-break circuits. We will use a SPDT microswitch (Single Pole, Double Throw). Simply stated, there is one common terminal on the switch where the voltage and current is applied and that voltage and current can be either directed to the normally open or normally closed terminal. The direction of the current flow is typically directed by a mechanical roller lever that actuates the switch. For more details visit this web page .In summary its key technical characteristics are the following:

  1. It has 3 pins (C, NO, NC)
  2. Requires an resistor
  3. Current 1A
  4. Rated Current GP Load 125 V (AC)
  5. Max Operating Temperature: -40 up to +85 °C

Schematic Development with KiCad

We select KiCad to design our board, taking into account that we will need to upload a library for the microswitch. I search for platforms and forums, and localize this this web page . That suggest me to downloaded a library from snapEDA . You can download the KiDCad library here.The folder containts a how to import instructions for more details
When working on schematics, we need to be careful with labeling each component in/out or GND adequately having on mind its possible PCB paths. Further, we need to phycally recognise each component, because the microswitch will need to made perforations, and the library could present some diferences.

This is the schematic where you can see all the components. You can download Schematic design file and the PNG file here.

PCB Designing

To obtain PCB design and fabricate it, we need to take the following steps:

  1. Select the PCB Editor File from the KiCad Principal Menu.
  2. Update PCB from Schemnatic option located at Tools Menu on PCB Editor.
  3. Set track sizes (width) and appereance (material) option located at Edit Board SetUp Menu. Here we set 0.4 for traces width and 0.8 for ground and energy traces.
  4. Setup constraints option located at Edit Board SetUp Menu. The most important it is to setup cleareance at 0.4 to no exceed the end mill diameter
  5. Start drawing the traces selecting width and material correctly

This is the pcb design where you can see all the components. You can download design file and the SVG files here.

PCB Machining Setting

To fabricate PCB design we use SVG files applying following steps within FabModules Software:

  1. Upload SVG Board file.
  2. Convert SVG image inverted it using 1000dpi.
  3. Set mill traces (material) using 1/64" end mill (select 2 as offsetting number).
  4. Calculated Mill raster 2D.
  5. Visualize the image selecting width and material correctly
  6. Send file as final step
  7. Applied same steps for Cutting Edges but use 1/32" End Mill

The machining was made with a Modela MDX-20. I have got the following problems while machining:

  1. I forgot to change resolution and instead of using 1000dpi, used 100dpi, and PBC traces width generated a problem when removing cooper (a)
  2. While cutting the edge, the endmill desajusted, because the machine need a maintainance, but didn't affect the PCB (b)

The PCBs images:

PCB Soldering

To proceed with soldering I fixed the PCB with double contact tape. Thus, we can avoid any movement when tin soldering

  1. I started soldering the small components
  2. I kept as strategy was to fix one (pin) of each component and then the others
  3. At The final step I soldered the micro switch, because it needed pcb perforations

The final PCB image is shown below

The Programing

For functional testing I used two Arduino IDE libraries (button and bouncing).
The first code for button is:

  1. const int buttonPin = 2; the number of the pushbutton pin.
  2. const int ledPin = 13;the number of the LED pin.
  3. int buttonState = 0;variable for reading the pushbutton status
  4. void setup() { initialize the LED pin as an output:
  5. pinMode(ledPin, OUTPUT); initialize the pushbutton pin as an input:
  6. pinMode(buttonPin, INPUT);initialize the pushbutton pin as an input:
  7. }
  8. void loop() {
  9. buttonState = digitalRead(buttonPin);read the state of the pushbutton value:
  10. if (buttonState == HIGH) {check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  11. digitalWrite(ledPin, HIGH);turn LED on:
  12. } else {
  13. digitalWrite(ledPin, LOW);turn LED off:
  14. }
  15. }
The first code for bounce is:
  1. const int buttonPin = 2; the number of the pushbutton pin.
  2. const int ledPin = 13;the number of the LED pin.
  3. int ledState = HIGH;the current state of the output pin
  4. int buttonState; the current reading from the input pin
  5. int lastButtonState = LOW; the previous reading from the input pin
  6. unsigned long lastDebounceTime = 0;the last time the output pin was toggled
  7. unsigned long debounceDelay = 50;the debounce time; increase if the output flickers
  8. void setup() {
  9. pinMode(buttonPin, INPUT);
  10. pinMode(ledPin, OUTPUT);
  11. digitalWrite(ledPin, ledState);set initial LED state
  12. }
  13. void loop() {
  14. int reading = digitalRead(buttonPin);read the state of the switch into a local variable
  15. if (reading != lastButtonState) {If the switch changed, due to noise or pressing
  16. lastDebounceTime = millis();reset the debouncing timer
  17. }
  18. if ((millis() - lastDebounceTime) > debounceDelay) {whatever the reading is at, it's been there for longer than the debounce delay, so take it as the actual current state
  19. if (reading != buttonState) {if the button state has changed
  20. buttonState = reading;
  21. if (buttonState == HIGH) {only toggle the LED if the new button state is HIGH
  22. ledState = !ledState;
  23. }
  24. }
  25. }
  26. digitalWrite(ledPin, ledState);set the LED
  27. lastButtonState = reading;save the reading. Next time through the loop, it'll be the lastButtonState
  28. }

I have a major problem with the testing, because the resistor was the eight one, and was causing short circuit. Thus I have to change the resistor

The following photo shows all system connection to test. I used XIAO RP2040 from Week 8 to test the board and the output device (Servomotor)

The first test was made runing the coding Arduino IDE for buttom, like shown in the following video

The final test was made runing the coding Arduino IDE for bouncing, like shown in the following video