User Tools

Site Tools


haas:fall2023:c4eng:projects:stl0

Corning Community College

ENGR1050 C for Engineers

PROJECT: Seeing The Light (STL0)

OBJECTIVE

We commence on our exploration of the electronics kit, by creating and controlling an LED with a C program on our pi.

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

After exploring, assembling, and testing the intended circuit, adapt the provided C code to blink the LED on the circuit, cycling on/off at least once every second.

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:

STL0

PREPARATION

INSTALL CUSTOM WIRINGPI
yourpi:~$ wget https://project-downloads.drogon.net/wiringpi-latest.deb

NOTE: domain say “dr-OH-gon”, it does NOT say “dragon”

yourpi:~$ sudo dpkg -i wiringpi-latest.deb
ACCESSING STL0 FROM YOUR PI

Since you can't make and run the program on lab 46, you will need to add, commit, and push it onto your repository with the hg commands, so that you can pull it onto your pi. Once you've successflly pushed everything onto the repository, go to your pi and use this command to pull it back:

hg pull;hg update

Once you've done that, you should be able to cd into the stl0 directory, where you can compile and run your program with the make and ./stl0 commands. If your breadboard is set up, and the stl0.c file is being applied to the right pin #, you might notice a change in the LED.

USING WIRINGPI: THE gpio TOOL

“gpio readall” will open up a table showing the physical pin layout of your pi. It will also tell you whether a pin is set to input or output, and whether the pin is turned on or off (V=0 shows the pin is off, v=1 shows the pin is on).

“gpio mode WIRINGPI_PIN# MODE” will change the mode of the designated pin. You must use the WiringPi pin number. Mode can either be in (input) or out (output).

“gpio write WIRINGPI_PIN# STATE” will change the ON/OFF state of a pin. 0=off and 1=on

USING WIRINGPI: SETTING MODE OF PINS
USING WIRINGPI: WRITING TO PINS

ELECTRICITY

VOLTAGE / VOLTS

Voltage is the electric potential between two points. Volts is the SI unit used for voltage. Voltage is often described as the “pressure” that pushes electricity. An analogy often used to describe the relationship between voltage, amperage, and resistance, is water in a hose. Voltage can be imagined as the water pressure, amperage can be imagined as the flow rate, and resistance is imagined as the thickness of the hose.

For circuit projects using a breadboard and Raspberry Pi, the typical voltages are 3.3V and 5V.

Input on any of the Raspberry Pi's GPIO pins should not be 5V. The Raspberry Pi is not 5V tolerant. This is confusing, as there are pins to output 5V, which is used to power external components.

GROUND

The ground “pin” is extremely important if connecting a circuit together. If done without a ground you can easily fry your breadboard or even kill an L.E.D light. Your ground pins are indicated by a GND next to the designated pin. For every power source connection, you must have a ground wire going to one of the Negative column.

AMPERAGE / AMPS

Amperage is a measure of the magnitude of electrical current.

RESISTANCE / OHMS

Resistance, or electrical resistance, is a measure of how difficult it is for current to flow. Resistance is measured in the SI unit Ohms. Resistors are components for implementing electrical resistance in a circuit. Resistance is equivalent to V/I, where V is voltage and I is current, derived from V=I*R.

DIGITAL ELECTRONICS

LIGHT EMITTING DIODE
RESISTOR

A resistor is a component that slows down the flow of electrons through an electrical circuit. The specified resistance value can be decoded by looking at the coloured bands that surround the body of the resistor.

SERIES CIRCUIT

COMPONENTS

BREADBOARD

A breadboard is a tool used for prototyping circuits without the need for soldering components onto a board. They typically come with detachable rails on the side, usually used (and marked) for power and ground. These red and blue marked strips are connected along the entire length of the columns. This allows you to power and ground multiple components easily.

Between these detachable rails are rows of 5 connected notches on either side of the divot in the middle. The 5 notches in each row are connected, allowing you to form circuits between attached components.

T-COBBLER / INTERFACE TO PI GPIO PINS

GPIO.0 is actually GPIO17 on your T-cobbler

To discover this, you can use the command

 gpio redall 

This will bring up a table of all the pins on the t-cobbler. On your t-cobbler, you will count the pins left to right starting at one, until you get to the pin you are using. Then, you will find the number your pin is at, then use the list to line it up with the wpi name. The Wpi name is the one we will be referring to whenever we need to write or indicate a pin in our code

LED

Brief Definition:

A light-emitting diode (LED) is a semiconductor device that emits light
when current flows through it.

Light-emitting diodes only allow electrical current to pass through them one way. The longer lead is the positive connection, and the shorter lead is the negative connection.

RESISTOR

A resistor is a component for implementing electrical resistance in a circuit. This is useful for lowering the flow of current across a circuit. By applying a resistor to a circuit with an LED, you could prevent the LED from burning out, or simply make it dimmer without needing to adjust voltage. Resistors have color coded bands on the body of them to indicate resistance in Ohms. For instance, 3 bands that are orange, orange, red, indicates a 330 Ohm resistor. The color coding is defined in the international standard IEC 60062.

TARGET CIRCUIT

 

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:

39:stl0:final tally of results (39/39)
*:stl0:used grabit to obtain project by the Sunday prior to duedate [6/6]
*:stl0:clean compile, no compiler messages [7/7]
*:stl0:program conforms to project specifications [20/20]
*:stl0:code tracked in lab46 semester repo [6/6]

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/stl0.txt · Last modified: 2023/09/10 09:03 by 127.0.0.1