Code Monkey home page Code Monkey logo

ringpong's Introduction

RingPong

Table of Contents

  1. Preface
  2. Build and Test
  3. Engineering and Design

Preface

This project was designed with Clang on OS X and the application was tested standalone in a terminal environment. The dev requirements for this project can be found in the CHALLENGE.MD file under the root of this project.

Tool Stack

This project uses:

  • C99 - 1999 C Standard

Platform Compliance

This project has been compiled and tested on:

  • Mac OS X
    • Compiler: Apple LLVM version 8.0.0 (clang-800.0.38)
    • Requires: Xcode CLI toolset
  • CentOS 7
    • Compiler: GCC 4.8.5 20150623 (Red Hat 4.8.5-16)
    • Requires: "Development Tools" and libnetd

Application Help

usage: ./ring-pong [button state] [current voltage]
button state is either 1 or 0, current voltage is 0.0 - 5.0 volts

----
example usage: ./ring-pong 1 3.5

Build and Test

After cloning the project, go into the base directory and create two subdirectories.

cd ./RingPong
mkdir bin obj

Following this, a simple make call should compile and drop the binary into the ./RingPong/bin folder

make #build the binary

make clean #remove the object files

make remove #remove the binary and object files 

The Makefile was originally hand-rolled from simple commands, but for better project management an open-source example was used that allowed for a refined directory structure.

Testing

The stdout is verbose in terms of logging the actions that happen; quickly the red LED flashing and the udp_server sending/receiving flood the terminal with output. The top few messages show the state of all the peripherals if they haven't been updating. Also note: for testing the TARGET_ADDR domain name macro found in udp_server.h was appended to localhost in the /etc/hosts file.

./ring-pong 1 3.5 #simulates button press, and 3.5V battery charge
./ring-pong 1 2.7 #simulates button press, and 2.7V battery charge
./ring-pong 0 4.5 #simulates no button press, and 4.5V battery charge
./ring-pong 0 1.3 #simulates no button press, and 1.3V battery charge 

Engineering and Design

Project Layout

File: hw_setup.c/.h

  • Contains all hardware setup functionality for interfacing with the various peripherals and modifying their states

File: udp_server.c/.h

  • Is the UDP server implementation; it uses a few global variables so that minimal state can be held while allowing control of sending and receiving to be handled outside the scope of the file directly. An educational reference for this development can be found at this Rutger's tutorial; the man pages for recvfrom and sendto were also used.

File: main.c

  • Imploys the CLI interface and main handling of the system logic. If it were implemented on a real embedded system, a loop that waits for a system signal would need to be employed around the main logic (the location of which is marked in main.c). As such, testing is limited to the states that one can change through the CLI and dynamic change in system state is currently not possible.

ADC Implementation

The determined resolution (as it was not explicitly stated) for the ADC was 12-bit or ( 212 - 1 ). Using calculations found at sparkfun.com for ADC measurments with millivolt system voltage reference (assumed to be 3.5V as that's when board functionality cuts off) made the equation come out to

(4095/3500 mV) * V * 1000 = Current Voltage Level

Where V is the voltage read in from the ADC and in the program from the second command line parameter.

Low Battery Indication

The embedded system has a red LED which must work at 2Hz and 25% duty cycle. With the average LED pulse width and the total signal period both at 1 second, a 25% duty cycle would end up being 1/4 the pulse width over a 1 second period. So in 1 second @ 2Hz the LED would be sent to a high state for two quarter pulse width periods. These are the sources for duty cycle and Hertz research.

ringpong's People

Stargazers

Brandon Watts avatar

Watchers

James Cloos avatar Joshua Shank avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.