12th week Assignment
Intput Devices
Intput Devices
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.
Please for group assignment details visit Anderson Zelarayan Web Page.
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.
By acknowledging that switch function we select the following components for this main board:
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:
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.
To obtain PCB design and fabricate it, we need to take the following steps:
Select the PCB Editor File
from the KiCad Principal Menu.
Update PCB from Schemnatic
option located at Tools Menu on PCB Editor.
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.
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 diameterStart drawing the traces
selecting width and material correctlyThis is the pcb design where you can see all the components. You can download design file and the SVG files here.
To fabricate PCB design we use SVG files applying following steps within FabModules Software:
Upload SVG Board file
.
Convert SVG image
inverted it using 1000dpi.
Set mill traces (material)
using 1/64" end mill (select 2 as offsetting number).
Calculated Mill raster 2D
.Visualize the image
selecting width and material correctlySend file
as final stepApplied same steps for Cutting Edges
but use 1/32" End MillThe machining was made with a Modela MDX-20. I have got the following problems while machining:
The PCBs images:
To proceed with soldering I fixed the PCB with double contact tape. Thus, we can avoid any movement when tin soldering
The final PCB image is shown below
For functional testing I used two Arduino IDE libraries (button and bouncing). The first code for button is:
const int buttonPin = 2;
the number of the pushbutton pin.
const int ledPin = 13;
the number of the LED pin.
int buttonState = 0;
variable for reading the pushbutton status
void setup() {
initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
initialize the pushbutton pin as an input:
}
void loop() {
buttonState = digitalRead(buttonPin);
read the state of the pushbutton value:if (buttonState == HIGH) {
check if the pushbutton is pressed. If it is, the
buttonState is HIGH: digitalWrite(ledPin, HIGH);
turn LED on:} else {
digitalWrite(ledPin, LOW);
turn LED off:}
}
const int buttonPin = 2;
the number of the pushbutton pin.
const int ledPin = 13;
the number of the LED pin.
int ledState = HIGH;
the current state of the output pin
int buttonState;
the current reading from the input pin
int lastButtonState = LOW;
the previous reading from the input pin
unsigned long lastDebounceTime = 0;
the last time the output pin was toggled
unsigned long debounceDelay = 50;
the debounce time; increase if the output
flickers
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, ledState);
set initial LED state}
void loop() {
int reading = digitalRead(buttonPin);
read the state of the switch into a local
variableif (reading != lastButtonState) {
If the switch changed, due to noise or pressing
lastDebounceTime = millis();
reset the debouncing timer}
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 stateif (reading != buttonState) {
if the button state has changedbuttonState = reading;
if (buttonState == HIGH) {
only toggle the LED if the new button state is HIGHledState = !ledState;
}
}
}
digitalWrite(ledPin, ledState);
set the LEDlastButtonState = reading;
save the reading. Next time through the loop, it'll be
the lastButtonState }
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