User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240828)
wcp2 (due 20240904)
pct0 (bonus; due 20240905)
pct1 (bonus; due 20240905)
pct2 (due 20240905)
abc0 (due 20240906)
gtf0 (due 20240911)
pct3 (bonus; due 20240911)
wcp3 (due 20240911)
dtr0 (due 20240918)
pct4 (due 20240918)
wcp4 (due 20240918)
pct5 (bonus; due 20240926)
stl0 (due 20240926)
wcp5 (due 20240926)
gfo0 (due 20241002)
pct6 (due 20241002)
stl1 (due 20241002)
wcp6 (due 20241002)
pct7 (bonus; due 20241009)
stl2 (due 20241009)
wcp7 (due 20241009)
bwp1 (bonus; due 20241016)
pct8 (due 20241016)
ptb0 (due 20241016)
wcp8 (due 20241016)
pct9 (bonus; due 20241023)
ptb1 (due 20241023)
wcp9 (due 20241023)
gfo1 (due 20241030)
pctA (due 20241030)
ptb2 (due 20241030)
wcpA (due 20241030)
pctB (bonus; due 20241106)
wcpB (due 20241106)
wus0 (due 20241106)
pctC (due 20241113)
wcpC (due 20241113)
wus1 (due 20241113)
pctD (bonus; due 20241120)
wcpD (bonus; due 20241120)
wus2 (due 20241120)
bwp2 (bonus; due 20241204)
gfo2 (due 20241204)
pctE (bonus; due 20241204)
wcpE (bonus; due 20241204)
EoCE (due 20241216)
haas:fall2024:c4eng:projects:fso0

Corning Community College

ENGR1050 C for Engineers

PROJECT: Figure Something Out (FSO0)

OBJECTIVE

Create circuitry and configure software to discover and demonstrate the functionality of some as-yet unutilized component from your electronics kit.

Be sure to contribute useful background and operational information to this project documentation, to serve as a reference for others.

OVERVIEW

Your task is to:

  • discover how to hook up and operate some component we've not otherwise utilized so far throughout our explorations in the course.
  • write a program that demonstrates its functionality.
  • there will be two more parts to this project, so if you want to take a broader-term view:
    • fso0: figure out how to use some component
    • fso1: prototype some circuit putting it to greater use
    • fso2: finished product

Example:

  • fso0: figure out how to use an ultrasonic sensor
  • fso1: prototype a “useless” machine, using the ultrasonic sensor as a proximity sensor to determine if the user's hand is still near the switch (to avoid injury)
  • fso2: finished product of a “useless” machine

GRABIT

To assist with consistency across all implementations, data files for use with this project are available on lab46 via the grabit tool. Be sure to obtain it and ensure your implementation properly works with the provided data.

lab46:~/src/SEMESTER/DESIG$ grabit DESIG PROJECT

EDIT

You will want to go here to edit and fill in the various sections of the document:

JOYSTICK

https://www.youtube.com/watch?v=qjP3HpbPJTM&list=PLOkhax8xuWu0Yj-jJAzSNiDJfHfXVaY9_&index=14

A Joystick is a kind of input sensor used with your fingers. It can receive input on two axes (Y and or X) at the same time (usually used to control direction on a two dimensional plane). And it also has a third direction capability by pressing down (Z axis/direction).

Hard Wiring

Parts Needed: Raspberry Pi, Ribbon cable, Breadboard, Joysick, 10k Resistor, ADC module, Wires

Enable I2C

The I2C interface in Raspberry Pi is disabled by default. You will need to open it manually and enable the I2C interface as follows: Type command in the Terminal: sudo raspi-config Then open the following dialog box: Choose “5 Interfacing Options” then “P5 I2C” then “Yes” and then “Finish” in this order and restart your RaspberryPi.The I2C module will then be started. Type a command to check whether the I2C module is started: lsmod | grep i2c If the I2C module has been started, the following content will be shown. Install I2C-Tools Next, type the command to install I2C-Tools. It is available with the Raspberry Pi OS by default. sudo apt-get install i2c-tools I2C device address detection: i2cdetect -y 1 When you are using the PCF8591 Module, the result should look like this: Install Smbus Module sudo apt-get install python-smbus sudo apt-get install python3-smbus

C Code 7.1.1 ADC

For C code for the ADC Device, a custom library needs to be installed.

1. Use cd command to enter folder of the ADC Device library. cd ~/Freenove_Kit/Libs/C-Libs/ADCDevice

2. Execute command below to install the library. sh ./build.sh A successful installation, without error prompts, is shown below:

Joystick code

1. Use cd command to enter 12.1.1_Joystick directory of C code. cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/12.1.1_Joystick/

2. Use following command to compile “Joystick.cpp” and generate executable file “Joystick”. g++ Joystick.cpp -o Joystick -lwiringPi -lADCDevice

3. Then run the generated file “Joystick”. sudo ./Joystick

Keypad Matrix

DESCRIPTION

A Keypad Matrix is a device that integrates a number of keys in one package. As is shown below, a 4×4 Keypad Matrix integrates 16 keys (think of this as 16 Push Button Switches in one module). The 4×4 Keypad Matrix has each row of keys connected with one pin and this is the same for the columns. Such efficient connections reduce the number of processor ports required.

The method of usage is by using a row or column scanning method to detect the state of each key’s position by column and row. Take column scanning method as an example, send low level to the first 1 column (Pin 1), detect level state of row 5, 6, 7, 8 to judge whether the key A, B, C, D are pressed. Then send low level to column 2, 3, 4 in turn to detect whether other keys are pressed. Therefore, you can get the state of all of the keys.

APPLICATION

The Keypad Matrix is best used when there is a need for a large number of buttons. Such a component can be used for something such as a pin code, but it is basically just a grid of 16 buttons that function the same way a single button does, and a button is a component that, when pressed, sends an electrical signal to some sort of output.

DEMONSTRATION

A great way to demonstrate the Keypad Matrix is a program that prints a message telling the user when a button has been pushed, and which button.

The first thing that someone would need to do to do this is to go to

https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi

and download the files here onto their raspberry pi. Once in the command terminal for your raspberry pi, you can type a series of commands to run the sample code provided in these files.

  • Use cd command to enter 22.1.1_MatrixKeypad directory of C code.

cd ~/Freenove_Kit/Code/C_Code/22.1.1_MatrixKeypad

  • Code of this project contains a custom header file. Use the following command to compile the code MatrixKeypad.cpp, Keypad.cpp and Key.cpp generate executable file MatrixKeypad. The custom header file will be compiled at the same time.

g++ -o MatrixKeypad.cpp Keypad.cpp Key.cpp MatrixKeypad -lwiringPi

  • Run the generated file “MatrixKeypad”.

./MatrixKeypad

After the program is executed, pressing any key on the Keypad Matrix, will display the corresponding key code on the Terminal:

ultrasonic proximity sensor & lcd 1605 display screen

DESCRIPTION

It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.

In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.

For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.

APPLICATION

using the prox sensor i was able to use the data the is produces and use it to project on a lcd screen

DEMONSTRATION

Distance Sensor

DESCRIPTION

The distance sensor basically uses echolocation to detect distances. So on wonky surfaces the distance sensor struggles. The distance sensor likes to read against flat surfaces.

APPLICATION

Basically my code reads a distance inputted by the distance sensor. Then, uses fprintf to display the distance.

DEMONSTRATION

LED Lights & Proximity Sensor

DESCRIPTION

An LED light is an electronic device that emits light when an electric current flows through it. So, an LED converts electrical energy into a light source. LED lights can also be used as an ON/OFF switch for a specific duration of code.

A proximity sensor is a device that can detect or sense the approach or presence of nearby objects without touching it. These sensors also convert the information that is received from the approach or presence of the objects into an electrical signal.

Parts Needed: Arduino Uno, LED x3, Breadboard, Ultrasonic Distance Sensor - HC-SR04, Wires.

Side Note: Even though there is a buzzer in the diagram, it was not used for the project. However, the buzzer, if wanted, is easy to add to the breadboard for the project. Just some of the code would need to be changed since there will be sound to the buzzer, showing that the buzzer is passive.

APPLICATION

The proximity sensor reads an object placed in front of it and the LED lights tell how close the object is to the proximity sensor. The red LED flashes when an object is very close to the proximity sensor. The yellow LED flashes when an object is halfway from the proximity sensor. The green LED flashes when an object is very faraway from the proximity sensor.

Another way to think about the colors connecting with the distance from the proximity sensor is through the amount of risk each color is. The green LED represents that there is little to no risk where the object is to the proximity sensor. The yellow LED represents that there is a medium amount of risk where the object is to the proximity sensor. The red LED represents that there is a large amount of risk where the object is to the proximity sensor.

DEMONSTRATION

If an object is extremely close to the proximity sensor, then the distance will be between 0 and 10. If an object is somewhat close or halfway from the proximity sensor, then the distance will be between 11 and 31. If an object is very far away from the proximity sensor, then the distance will be between 32 and beyond to a never ending stopping number.

DESCRIPTION

APPLICATION

DEMONSTRATION

Stepper Motor

DESCRIPTION

A Stepper motor is a brushless DC motor that divides a full rotation into a series of equal steps and can be used to hold a specific position. The steps remove the need for a position sensor as the computer already knows the number of steps said motor has taken and therefore it can calculate its position. In order for a stepper motor to spin the pins must be powered ON and OFF in a specific sequence. the sequence for the stepper motor in the kit is

SEQ# - [ [IN1],[IN2],[IN3],[IN4] ]

step 0 - [1,0,0,0]

step 1 - [1,1,0,0]

step 2 - [0,1,0,0]

step 3 - [0,1,1,0]

step 4 - [0,0,1,0]

step 5 - [0,0,1,1]

step 6 - [0,0,0,1]

step 7 - [1,0,0,1]

the following sequence will move the stepper motor 1/64 of a full rotation because the stepper motor in the kit has a 1:64 gear reduction so it will take 512 step to make a full rotation with this stepper motor or 64 sequences of the steps given above.

APPLICATION

Stepper motors have a wide variety of uses and are commonly used in.

-3D printers

-slot machines

-paper printers

-CNC machines

-camera lenses

-disc drives

DEMONSTRATION

LED BAR GRAPH

DESCRIPTION

The LED bar graph component is comprised of 10 separate LED light circuits. Each LED require both power and ground similarly to single LED bulbs.

APPLICATION

The LED bar graph can be used in a multitude of different applications.

Its applications include;

-Feedback of potentiometer position

-Motor speed feedback

-Sound level

-Distance from proximity sensor }

DEMONSTRATION

Programming a simple function of sequencing the lights down and then back up the LED Bar Graph is rather simple. If you follow the diagram depicted above, you will command the pin low to turn on the LED since we are wiring the GPIO to the cathode side of the LED.

For the code, we will use an array with our wiringPi pin assignments and ensure we set the pins as outputs. Then we will use index to cycle through the array and light our LED's in sequence

HC-SR501 SENSOR

DESCRIPTION

The PIR sensor allows you to detect when a person or animal moves in or out of sensor range. This sensor is what you’ll find in most modern security systems, automatic light switches, garage door openers and similar applications where we want to react to motion.

APPLICATION

Common applications include automatic house or garden light, burglar alarms, security cameras and motion detectors, tracking animal movements. For my project, i started with hooking up the PIR sensor just to detect motion. After that was successful, i wired an LED to the sensor. Every time there is motion being detected, the LED lights up. I am currently making a “smart door” that opens every time it is motion activated. This will also include a servo motor to open the door.

DEMONSTRATION

4 Digit 7 Segment LED Display

DESCRIPTION

This device requires nothing but the display itself and 11 wires to attach the the breadboards pins. There is no ground or voltage pins require either. There are 12 pins on the display but 11 of them are used to attach to the pins of the breadboard. 7 of the pins will control the segments that light up on the display to create the number desired. The other 4 pins will control the position of the number displayed because the display is up to 4 digits. The display should be positioned in a specific direction for it to work and the pins on the wiringPi should exactly match the pins from the Arduino example.

APPLICATION

This device allows for 4 digit counting, similar to the LED counting we did weeks ago. This device clearly shows the numbers being displayed however and can count down or up to any number depending on the code written.

Wiring

LCD Display

DESCRIPTION

The LCD display contains 2 lines of 16 characters that can display any string of letters, number, or any ascii character. It can be used to display many data inputs such as time or temperature reading from a temperature sensor. It requires four pins: 5v in on the VCC pin, ground to the GND pin, a data connection to from an SDA pin on the pi to the SDA pin on the display, and finally a clock connection from an SCL pin on the pi to the SCL pin on the display.

APPLICATION

The library I used was made by the user TheRaspberryPiGuy on github and is a very useful library for running the display. However, it requires the code to be written in python, but he provides many sample programs for learning.

All of the proceeding steps should be executed on your pi, not Lab46.

1. Download the library

Run:

git clone https://github.com/the-raspberry-pi-guy/lcd.git

2. Enter the newly created directory

cd lcd

3. Install the library

sudo ./install.sh

if you are given the error 'permission denied' run:

chmod a+x setup.sh

to give setup.sh permission to excecute

4. Reboot your pi

5. View or run any demos

You can view or run any of the programs labeled demo after running ls. Programs can be excecuted by running:

python FILENAME.py

The code can also be viewed by using nano.

Gyroscope (GY-521)

Description The GY-521 contains both a 3-Axis Gyroscope and a 3-Axis accelerometer allowing measurements of both independently, but all based around the same axes, thus eliminating the problems of cross-axis errors when using separate devices.

Specification Accelerometer ranges: ±2, ±4, ±8, ±16g Gyroscope ranges: ± 250, 500, 1000, 2000 °/s Voltage range: 3.3V - 5V (the module include a low drop-out voltage regulator) This simple module contains everything required to interface to the Arduino and other controllers via I2C (use the Wire Arduino library) and give motion sensing information for 3 axes - X, Y and Z.

APPLICATION

The GY-521 can be used to measure the orientation of the device. It can sense motion including vertical and horizontal rotation. There are a lot of practical uses of gyroscope especially in aerospace. It can be used as a stability assistance device to make sure that a rocket, a spacecraft, or an aircraft maintains the correct orientation.

DEMONSTRATION

COMPONENT 13

DESCRIPTION

APPLICATION

DEMONSTRATION

COMPONENT 14

DESCRIPTION

APPLICATION

DEMONSTRATION

COMPONENT 15

DESCRIPTION

APPLICATION

DEMONSTRATION

COMPONENT 16

DESCRIPTION

APPLICATION

DEMONSTRATION

COMPONENT 17

DESCRIPTION

APPLICATION

DEMONSTRATION

 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • All code must compile cleanly (no warnings or errors)
    • Compile with the -Wall and –std=gnu18 compiler flags
    • all requested functionality must conform to stated requirements (either on this document or in a comment banner in source code files themselves).
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool (make submit on lab46 will do this) by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ make submit

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

65:fso0:final tally of results (65/65)
*:fso0:used grabit to obtain project by the Sunday prior to duedate [13/13]
*:fso0:picture of connected circuit to project page with description [13/13]
*:fso0:clean compile, no compiler messages [13/13]
*:fso0:program conforms to project specifications [13/13]
*:fso0:code tracked in lab46 semester repo [13/13]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 256 bytes (absolute value of data content change))
      • near the class content contribution average (a value of at least 1kiB)
      • no adding in one commit then later removing in its entirety for the sake of satisfying edit requirements
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2024/c4eng/projects/fso0.txt · Last modified: 2022/10/31 13:58 by 127.0.0.1