Skip to content

Commit

Permalink
First commit. Starting to get files up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Hawes committed Apr 22, 2020
0 parents commit 115206d
Show file tree
Hide file tree
Showing 2,005 changed files with 2,705,841 additions and 0 deletions.
Empty file added .gitignore
Empty file.
Binary file added feeder/.DS_Store
Binary file not shown.
31,703 changes: 31,703 additions & 0 deletions feeder/cad/v0.2.0.step

Large diffs are not rendered by default.

Binary file added feeder/code/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions feeder/code/firmware_feeder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
67 changes: 67 additions & 0 deletions feeder/code/firmware_feeder/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choose one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#


#
# Template #1: General project. Test it using existing `platformio.ini`.
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
# - platformio update
#
# script:
# - platformio run


#
# Template #2: The project is intended to be used as a library with examples.
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
7 changes: 7 additions & 0 deletions feeder/code/firmware_feeder/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
39 changes: 39 additions & 0 deletions feeder/code/firmware_feeder/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
46 changes: 46 additions & 0 deletions feeder/code/firmware_feeder/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
158 changes: 158 additions & 0 deletions feeder/code/firmware_feeder/lib/ring/ring.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#include "../../src/define.h"
#include "ring.h"

int Ring::call(){

/*
call() sends a message over RING. it is dependent on:
-class variable "timeout" which determines how long it waits for a response before exiting
-message_out class variable, which is a byte with all the bits to be sent.
If call() returns 0, the message was sent successfully and the recipient acknowledged it.
if it returns 1, the recipient never picked up.
if it returns 2, the recipient picked up, but did not acknowledge
*/

int status = 0;

//getting ready to detect response to ring
pinMode(DAT, INPUT_PULLUP);

//starting to ring with pulling clock low
pinMode(CLO, OUTPUT);
digitalWrite(CLO, LOW);

//waiting for response
unsigned long start_millis;
start_millis = millis();

while(digitalRead(DAT)){
if(millis() - start_millis > timeout){
status = 1;
break;
}
}

if(status == 0){ //if we didn't timeout, sent the message

digitalWrite(CLO, HIGH);

//give a bit of a delay to wait for recipient to set pins to the appropriate mode
delay(15);

//set DAT to output
pinMode(DAT, OUTPUT);
digitalWrite(DAT, HIGH);

//start sending the data!
for(int i = 0; i<8; i++){
digitalWrite(DAT, message_out[i]);
delay(20);
digitalWrite(CLO, LOW);
delay(10);
digitalWrite(CLO, HIGH);
delay(20);

}

//listen for ACK bit
pinMode(DAT, INPUT_PULLUP);

delay(20);

//9th ACK CLO Pulse

digitalWrite(CLO, LOW);
int ack = digitalRead(DAT);
delay(10);

pinMode(CLO, INPUT_PULLUP);

if(!ack){
Serial.println("Received ACK bit");
}
else{
Serial.println("Did not receieve ack bit");
}


}

return status;

}

int Ring::pickUp(){

/*
pickUp() listens to a message over RING. pickUp() should be called when it's detected that CLO is pulled low
If pickUp() returns 0, the message was received successfully and the data has been stored in class variable message_in.
if it returns 1, the communication failed due to timeout.
*/

//setting status to 0 as default
int status = 0;

//Send signal back through DAT line that we picked up
pinMode(DAT, OUTPUT);
digitalWrite(DAT, LOW);
delay(5);

pinMode(DAT, INPUT_PULLUP);

//Listen to 8 bits get clocked in and store them

for (int i = 0; i<8; i++){

unsigned long start_millis;
start_millis = millis();

while(digitalRead(CLO)){
//do nothing while CLO == HIGH, waiting for clock pulse low from sender

//timeout
if(millis() - start_millis > 100){
status = 2;
break;
}
}
int bit = digitalRead(DAT);
Serial.println(bit);
message_in[i] = bit;

if(!digitalRead(CLO)){
while(!digitalRead(CLO)){
//do nothing, waiting for clock pulse to end
}
}

}

delay(30);

//Respond with reciept of response
pinMode(DAT, OUTPUT);
digitalWrite(DAT, LOW);

while(digitalRead(CLO)){ //waits for clock pulse to start
//do nothing
//ADD TIMEOUT
}
delay(2);
while(!digitalRead(CLO)){ //waits for clock pulse to end
//do nothing
//ADD TIMEOUT
}

//returning clock pin to input pullup
pinMode(DAT, INPUT_PULLUP);

//returning status of message
return status;

}
13 changes: 13 additions & 0 deletions feeder/code/firmware_feeder/lib/ring/ring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <Arduino.h>

class Ring
{
public:
unsigned long timeout = 3000;
int message_in[8];
int message_out[8];

int call();
int pickUp();

};
27 changes: 27 additions & 0 deletions feeder/code/firmware_feeder/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
;PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino

upload_protocol = stk500v1
upload_flags =
-P$UPLOAD_PORT
-b$UPLOAD_SPEED

# edit these lines
upload_port = /dev/cu.usbserial-14240
upload_speed = 19200



lib_extra_dirs = ../../../lib/cpp
13 changes: 13 additions & 0 deletions feeder/code/firmware_feeder/src/define.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#define OPTO A3
#define nSLEEP 2
#define MOTOR_EN 3
#define MOTOR_PH 4 //high is ____, low is ____
#define LED 8 //high is Orange (bottom LEd), low is GREEN (top led)
#define SW1 7
#define SW2 6
#define TDS 5


#define BLINK_FREQ 500

//#define DEBUG
Loading

0 comments on commit 115206d

Please sign in to comment.