User Tools

Site Tools


haas:fall2023:c4eng:projects:eap0

Corning Community College

ENGR1050 C for Engineers

PROJECT: Explore A Project (EAP0)

OBJECTIVE

Explore some new component from the electronics kit: construct and test a circuit, demonstrate operations with software.

PROCESS

Do note, the productive way to go about this project involves taking the following steps:

  • starting early
  • reading the project page
  • asking questions regarding things you do not know, are not clear on, or are confused about
  • as information, concepts, processes become clear, that is something you can contribute to the project documentation (so you can better remember)

If you start too late, and do not ask questions, and do not have enough time and don't know what is going on, you are not doing the project correctly.

TASK

This is part one of a sequence: decide on some project you’d like to pursue, this project lays the groundwork of understanding of individual components.

  • Part 1: Select some component(s) to explore (circuit and program to demo)
  • Part 2: integrate together on some new circuit with other components (circuit and program to demo)
  • Part 3: Finished product (circuit, program)

Peruse the Freenove tutorial PDF, generate ideas, don’t bite off more than you can chew (considering you have about 3 weeks).

And document your selection, progress, and final results on the project documentation page!

GRABIT

No grabit for this project: you should be able to reference previous project demos and create working programs from what you’ve used and what you’ve learned.

It would be highly recommended to create a eap0/ directory in your repository, alongside your other projects, and perhaps to call your program eap0.c

The Makefile from other projects can be adapted to work with your current endeavour (would only need to change perhaps one line near the top of the Makefile in a text editor).

EDIT

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

EAPX

Edit your section here and provide a description of what it is you’d like to build by the end of this endeavour.

From the tutorial or other resources, identify what components from your electronics kit you are going to be testing, and provide any pertinent information regarding its operation (ie not entire programs, but succinct nuggets of information that could be useful to others wanting to get up and running).

Edit your section here and provide that pertinent information.

acuno

premise

My plan is to control a stepper motor using two buttons. One button will make the stepper motor rotate some fixed amount clockwise. The other button will make the stepper motor rotate the same fixed amount counterclockwise. The rotation amount will be hard-coded into the program. Perhaps if everything else goes smoothly, I'll try to use a potentiometer to control the motor rotation amount.

part1

For the first week I started with wiring and coding a stepper motor. I have a program which continuously moves the stepper motor either clockwise or counterclockwise. Next I need to expand the program to rotate a certain fixed amount and also use the states of the buttons to control direction.

part2

The buttons have been added in to the wiring. The feedback from the buttons has also been incorporated into the program. Currently, the stepper motor rotates continuously one direction while one button is pressed, and continuously in the other direction while the other button is pressed. Next I need to program the motor to rotate a fixed amount upon each button press.

part3

The stepper motor system works well. There are two buttons. When one of the buttons is pressed, the motor rotates clockwise. When the other button is pressed, the motor rotates counterclockwise. The amount that the motor rotates is set within the program. 20231108_204902.jpg

cgaffne1

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

clamphi3

premise

I want to use joystick to change the color of a 4 legged light.

part1

I used the following code to read the x,y & z values of the joystick as it moves.

#include <wiringPi.h> #include <stdio.h> #include <stdlib.h> #include <softPwm.h> #include “ADCDevice.cpp” #include <time.h> /

#define Z_Pin 1 define pin for axis Z ADCDevice *adc; Define an ADC Device class object

/

              int main(void){
      adc = new ADCDevice();
      printf("Program is starting ... \n");
      if(adc->detectI2C(0x48)){ // Detect the pcf8591.
      delete adc; // Free previously pointed memory
      adc = new PCF8591(); // If detected, create an instance of PCF8591.
      }
      else if(adc->detectI2C(0x4b)){// Detect the ads7830
       delete adc; // Free previously pointed memory
       adc = new ADS7830(); // If detected, create an instance of ADS7830.
      }
      else{
      printf("No correct I2C address found, \n"
      "Please use command 'i2cdetect -y 1' to check the I2C address! \n"
      "Program Exit. \n");

return -1; }

      wiringPiSetup();
      pinMode(Z_Pin,INPUT); //set Z_Pin as input pin and pull-up mode
      pullUpDnControl(Z_Pin,PUD_UP);
      while(1){
              int val_Z = digitalRead(Z_Pin); //read digital value of axis Z
              int val_Y = adc->analogRead(0); //read analog value of axis X and Y
              int val_X = adc->analogRead(1);
      printf("val_X: %d ,\tval_Y: %d ,\tval_Z: %d \n",val_X,val_Y,val_Z);
      delay(100);

} return 0; }

part2

I set up the leds circuit and using softPwmWrite made it so the lights numerical sate coresponded to the x,y or z value it was linked to. Although the z value can only be 1 or 0 so when it equaled 0 the third pin to the light would equal 100.

val_Z = digitalRead(Z_Pin); read digital value of axis Z if(val_Z == 0){ softPwmWrite(HREPIN, 100); } else{ softPwmWrite(HREPIN, 0); } / val_Y = adc→analogRead(0); read analog value of axis X and Y

              softPwmWrite(TWOPIN , val_Y);
              /////////////////////////////////////////////////////////////
              val_X = adc->analogRead(1);
              softPwmWrite(ONEPIN , val_X);

https://youtu.be/nE6sX5U6sz4

part3

When moving the joystick around the light changes color and when any of the values hit their max one of the single led's will turn on.

/

              val_Z = digitalRead(Z_Pin); //read digital value of axis Z
              if(val_Z == 0){
                      softPwmWrite(HREPIN, 100);
                       digitalWrite (GRNLED, 1);
              }
              else{
                      softPwmWrite(HREPIN, 0);
                       digitalWrite (GRNLED, 0);
              }
              /////////////////////////////////////////////////////////////
              val_Y = adc->analogRead(0); //read analog value of axis X and Y
              softPwmWrite(TWOPIN , val_Y);
                      if (val_Y == 247){
                              digitalWrite (REDLED, 1);
                      }
                      else{
                              digitalWrite (REDLED, 0);
                      }
              /////////////////////////////////////////////////////////////

https://www.youtube.com/playlist?list=PLpR-bDNsxP5swtO5DQ5bhKbo7tLxqU75V

clovell3

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

dcookjr

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

jklotz2

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

jparrish

premise

for the project, i plan on creating a circuit utilizing the ultrasonic sensor, 3 leds , and a buzzer. The overall goal is to make it so that at a certain distance an object is from the sensor, the leds will fill up, and when the leds are all on, a buzzer will go off.
I understand the premise of the circuit, and believe this will be an easy but tedious task.

part1

ULTRASONIC SENSOR - a sensor that measures distance based on how long a sound wave takes to bounce back
ACTIVE BUZZER - a buzzer that makes noise when power is sent to it
LED - a light emitting diode

part2

all that had to be done, was grab the c code downloaded with the starter manual for the pi, then add a couple if statements to compare the distance to a set distance, and if the distance was smaller, to turn on each light and then the buzzer, all of which were put into an array
the sensor needed to be hooked up to two different pins, with the echo pin needing 3 1kohm resistors also leading to our ground
the buzzer only needed a 1kohm resistor leading to a transistor, which ultimatly controls the buzzer
each led needed a 220ohm resistor.

part3

looks like a piece of junk, but the closer you move your hand, the more lights pop up. the lights are put out of the way of the wires so its easier to see. Essentially, the pi is generating distance info with the sonar, then comparing that to a set distance, and turning on and off pins as it exceeds or fails to exceed those set distances

lbond1

premise

I want to use the seven segment display as a counter of some kind. I will probably use it with a button and a switch that makes the number displayed increase or decrease.

part1

I am testing the Seven Segment Display, which uses the 74HC595 chip to display a variety of symbols. It can be used in counting, and I want to test its ability to count in hexadecimal.

part2

In this part, I wanted to test how I could use the button with the seven segment display. I decided to have the button change the speed at which the display counted. Pressing the button more, means that the counter will slow down, since the delay is greater. I could also use another button or a switch to make it speed up as well, but this was mostly to confirm that the button could work and affect the seven segment display

part3

For the finished product, I have a seven segment display that shows a hexadecimal counter that can be slowed down or sped back up to regular speed. Pressing the blue button slows the counter down the more you press it. Pressing the red button sets the speed at which it counts back to normal. These two buttons can be used to slow or speed up the counter in a way, without having to worry about a negative delay happening.

lrogers3

premise

For my project I will be working with the 7-Segment Display and learning more about its functions along with 74HC595 chip. The display allows you to see an actual number or letter.

part1

I left enough room at the bottom to test out using a button to control the display, one button to count up and another button to count down. Thats not definite.

part2

I would like to explore using the 74HC595 chip with the seven segment display. I would like to program it to count even, odd then 0-9 number.

part3

description of finished project details (not full source code), but present your finished product

lwebb3

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

mgillet3

premise

The end project will be a timer that is turned on and off with a button and utilizes the 4 digit 7-segment display

part1

I have decided to start with testing out the single digit 7-segment display and trying to display numbers 0 through 9

part2

Now I will be using to 4 digit seven segment display as opposed to the 1 digit display. My main goal for this segment of the project is to get the numbers to both display and to change.

part3

description of finished project details (not full source code), but present your finished product

mmatti11

premise

Use a proximity sensor to determine the distance and display on an lcd screen.

part1

I will be using a proximity sensor or ultrasonic sensor and an lcd screen for this project.

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

mwinter4

premise

In my project, I would like to control some servos using data from the mpu6050. Ultimately, these will be attached to control surfaces in an “autopiloted” glider. Eventually, I would also like to use an ultrasonic sensor to detect how far this system is from the ground and initiate a landing sequence.

Components

The components I have selected are the mpu6050 and servos attached to an Arduino Nano. The mpu6050 is a “motion tracking” device that provides accelerometer and gyroscope data necessary for this project. The mpu6050 only needs to be connected through SDA and SCL to provide data to our microcontroller (and of course power/gnd).

The servos are motors that can be used to precisely control our glider's control surfaces. The servos can be controlled via data line and must be connected to a PWM pin on the Arduino Nano. There is a handy-dandy Arduino library called “Servo.h” that simplifies the process of controlling servos greatly. You can initialize servos as objects in the code and easily write angles to servos without needing to worry about PWM (Pulse-Width Modulation).

The Arduino Nano is the microcontroller I am using to control the components in this circuit. Using the Arduino IDE we can load “sketches” (instructions) onto the Arduino Nano. The Arduino IDE uses its own modification of C/C++. The Arduino can be provided power (and sketches) through its mini USB port, or can be powered by a battery up to 12V (recommended). Before submitting code sketches to the Arduino Nano, you can click the verification button in the IDE to compile the code and see any errors.

part2
video
updates

The MPU6050, Arduino Nano, and Servos have all been integrated on a circuit together. The servo meant to control the rudder has been fixed. Instead of using accelerometer data from the MPU6050, registers ACCEL_ZOUT_H (0x3F) and ACCEL_ZOUT_L (0x40) as specified on the register map, the code has been updated to use the gyroscopic data located at registers GYRO_ZOUT_H (0x47) and GYRO_ZOUT_L (0x48).

code

After initial setup (everything outside of the “main” loop() function); where we create our Servo objects and attach them (via Servo.h), initialize important variables, and set up communications to our mpu6050; the remaining code simply reads data from the MPU6050, scales down the data by a factor of 180, and delivers that “angle” in degrees to our servos.

This process is repeated for each Euler angle necessary (yaw, pitch, roll), so we need only to dissect one block to understand the rest:

  //// X-axis: "Yaw", although this would normally be the Z-axis
  Wire.beginTransmission(mpu6050);
  Wire.write(0x47); // gyroscope instead of accelerometer 
  Wire.endTransmission(false);
  Wire.requestFrom(mpu6050, 4, true);
  AcX = Wire.read() << 8 | Wire.read();
  x_ang = AcX/180;

The first 3 lines of this block,

  Wire.beginTransmission(mpu6050);
  Wire.write(0x47); // gyroscope instead of accelerometer 
  Wire.endTransmission(false);

are mostly self-explanatory.

On the first line, we're starting an I2C connection to the MPU6050 using it's address (0x68). From the second line, we queue up the information we want to send; namely, the register we're trying to access. And the third line ends the transmission, sending that information on its merry way over to the MPU6050.

The next three lines of code:

 
  Wire.requestFrom(mpu6050, 4, true);
  AcX = Wire.read() << 8 | Wire.read();
  x_ang = AcX/180;

On the first, we're requesting bytes at the register address 0x47 (as previously set up) from the MPU6050. Specifically, we're requesting 4 bytes. Our final argument, true, releases the MPU6050 from the connection.

On the second line, we read the bytes we requested on the previous line. We left shift a byte to read the data from the adjacent register, 0x48, and OR those bytes together to retrieve the full information we need.

The final line is simply our scaling factor and a variable assignment.

part3
video
finished project details

As shown in the video above, all of the electronics are attached to a glider, with the main components (Arduino Nano, MPU6050, breadboard, etc.) stored in the fuselage. Wires have been ran under the red material on the wings from the “brain” in the fuselage to each aileron servo. As seen in the video, there are also wires wrapped around the black rod (arrow shaft) reaching to the servos on the tail.

There are two servos on the tail, one for the elevator and the other for the rudder. The rudder (yaw) is the “X-axis” as described in the code, but this is due to the mpu6050 being setup in an atypical way. That is to say, the relative orientation of the mpu6050 was arbitrarily chosen and the axes were programmed for that perspective.

The servos on the ailerons both function using the “Y-axis” (roll), and the elevator servo uses the “Z-axis.”

The glider is set on a flat surface before receiving power. As soon as the microcontroller, our Arduino Nano, receives power, the code starts. When the Arduino Nano turns on and supplies power to the MPU6050, the whole system calibrates itself to the orientation it currently sits at. This is why we need to make the glider level before supplying power.

Once the glider is calibrated, it can be freely moved wherever it needs to be moved before launching. Each of the servos will attempt to maintain a neutral position of all control surfaces. This results in a glider that maintains stabilization and heads straight (no rudder/aileron movement for turning).

The factors used to maintain these angles are described extensively in part 2.

This was a really fun project that I was more than happy to take part in. There are so many features that I imagine for future iterations that were beyond the scope, like having the glider follow a GPS-based path for a true “autopilot” system.

nbutler5

premise

Currently I am exploring the LCD screen component to use as my project, I don't exactly know the functionality of it yet or how to use it.

part1

LCD Module: A compact electronic component that consists of an LCD screen, a driver circuit, and a control interface (meaning very basic, not like a standard flat screen television with far better resolution & image processing).

A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device that uses the light-modulating properties of liquid crystals combined with polarizers. Liquid crystals do not emit light directly but instead use a backlight or reflector to produce images in color or monochrome. LCDs are available to display arbitrary images (as in a general-purpose computer display) or fixed images with low information content, which can be displayed or hidden: preset words, digits, and seven-segment displays (as in a digital clock) are all examples of devices with these displays. They use the same basic technology, except that arbitrary images are made from a matrix of small pixels, while other displays have larger elements. LCDs can either be normally on (positive) or off (negative), depending on the polarizer arrangement. For example, a character positive LCD with a backlight will have black lettering on a background that is the color of the backlight, and a character negative LCD will have a black background with the letters being of the same color as the backlight. Optical filters are added to white on blue LCDs to give them their characteristic appearance.

part2

The only additions made, was a Blinking REDLED, which indicated whenever the CPU temperature would update. The interesting thing about it is you have to use one of the pin slots on the LCD module D7.

part3

eap2 is the finished program, where the lcd module outputs the pi's CPU temperature and the time stamp associated with the temp readout. The temperature output is in Celsius and was 2 decimal places XX.XX. The program for the CPU temp updates every second, so I added a blinking led program for whenever the LCD display updates, giving a visual indicator.

rford5

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

stostan2

premise

The objective is to create code that will make the ultra-sonic sensor detect motions in front of it.

Ultra-sonic Motion sensor

To start you will need 5 wires,3 1k ohm resistors, and an ultrasonic motion sensor. Have one wire hooked to a 5V power source and the other end attached to the VCC Pin, a wire in a GPIO pin going to “TRIG” and another GPIO pin connected with a wire leading to a 1k ohm resistor, and the GND pin should be connected to a wire going to ground.

part2

The objective in eap1 is to make 3 leds flash for different distances. So for example I will have a red, blue and green LED all hooked up. When the ultra-sonic sensor reads any distance below 25cm the red LED will flash red. When the distance is between 26-50 the blue LED will flash up and the red one will turn off. When the distance exceeds 50cm the green LED will create a flash and the blue one will turn off.

img-7706.jpg

part3

My finished product consist of the ultrasonic Ranger, 3 LEDs and a buzzer. The LEDs turn on and off with certain distances. So the red will do 0-25, blue 26-50 and green 51-100. When the distance reads over 50 centimeters, the buzzer will begin to BUZZ! Using if and else statements for my lights and buzzer made this whole thing possible.

wjohns11

premise

description of what you are looking to do

part1

description of what component(s) you have selected and are testing

part2

description of changes made and construction pursuits, and some details of C program interaction

part3

description of finished project details (not full source code), but present your finished product

 

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 (assuming you have a program called uom0.c):

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:

78:eap0:final tally of results (78/78)
*:eap0:clean compile of code, no compiler messages [16/16]
*:eap0:picture of working test circuit posted to class discord [16/16]
*:eap0:code adequately initializes and tests, operates component [16/16]
*:eap0:code tracked in lab46 semester repo [14/14]
*:eap0:project documentation page updated with pertinent information [16/16]

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/fall2023/c4eng/projects/eap0.txt · Last modified: 2023/10/23 10:27 by 127.0.0.1