-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ addjust FabWaage to Arduino 2.0
- Loading branch information
Showing
21 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
libraries/HX711Array/examples/calibration/calibration.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Calibration Sketch | ||
* | ||
*/ | ||
|
||
#include <HX711Array.h> | ||
#include <Sleep.h> | ||
|
||
//Make sure, that you have choosen the right board! | ||
uint8_t dout[] = { HX711_DOUT }; | ||
uint8_t sck = HX711_SCK; | ||
|
||
HX711_4PointCal scale; | ||
|
||
float sw = 3.00; | ||
float t[] = { 10.0, 20.0 }; | ||
long cal_adc[] = { -68137L, -73803, -378845L, -384611L }; | ||
|
||
|
||
volatile uint8_t tics; | ||
ISR(TIMER2_OVF_vect) { | ||
tics++; | ||
} | ||
|
||
|
||
void setup() { | ||
Serial.begin(9600); | ||
// put your setup code here, to run once: | ||
printHelp(); | ||
Serial.flush(); | ||
Sleep.setupTimer2(2); //init timer2 to 1/16 sec | ||
scale.set_no_sleep(1); | ||
scale.begin(dout, 1, sck); //start HX711Array with one ADCs | ||
scale.power_up(); | ||
|
||
} | ||
|
||
long adc; | ||
char c=0; | ||
void loop() { | ||
Serial.flush(); | ||
char cc=0; | ||
if (Serial.available()){ | ||
cc = Serial.read(); | ||
if ((cc >= 'a' && cc <= 'z') || (cc >= '0' && cc <= '1')) c = cc; | ||
} | ||
|
||
switch (c) { | ||
case 'h': | ||
printHelp(); | ||
c = '0'; | ||
break; | ||
case '1': | ||
case 't': | ||
adc = scale.read_average(10); | ||
if (c == 't') { | ||
scale.setTare(adc, 20); | ||
c = '1'; | ||
} | ||
Serial.print("ADC: "); | ||
Serial.print(adc); | ||
Serial.print(" -- Weight: "); | ||
Serial.println(scale.getWeight(adc, 20)); | ||
break; | ||
case 'z': | ||
Serial.print("Reading Zero ADC..."); | ||
Serial.flush(); | ||
adc = scale.read_average(50); | ||
Serial.println(adc); | ||
cal_adc[0] = adc; | ||
cal_adc[1] = adc; | ||
c = '0'; | ||
break; | ||
case 'w': | ||
Serial.print("Reading Weight ADC..."); | ||
Serial.flush(); | ||
adc = scale.read_average(50); | ||
Serial.println(adc); | ||
cal_adc[2] = adc; | ||
cal_adc[3] = adc; | ||
c = '0'; | ||
break; | ||
case 'r': | ||
Serial.println("Reading Conf..."); | ||
scale.readConf(); | ||
c = '0'; | ||
break; | ||
case 's': | ||
Serial.println("Saving Conf..."); | ||
scale.setConf(sw, t, cal_adc); | ||
scale.saveConf(); | ||
c = '0'; | ||
break; | ||
case 'p': | ||
scale.printConf(); | ||
c = '0'; | ||
break; | ||
case 'c': | ||
while (Serial.available()) { | ||
delay(1); | ||
Serial.read(); | ||
} | ||
Serial.println("Please enter calibration weight"); | ||
while (Serial.available() < 3) {} | ||
String s = Serial.readString(); | ||
s.trim(); | ||
sw = s.toFloat(); | ||
Serial.print("Calibration weight: "); | ||
Serial.println(sw); | ||
c = '0'; | ||
break; | ||
case '0': | ||
break; | ||
} | ||
} | ||
|
||
|
||
void printHelp(void) { | ||
Serial.println("Commands:"); | ||
Serial.println("z: Zero calibration"); | ||
Serial.println("w: Weight calibration"); | ||
Serial.println("c: Set calibration weight"); | ||
Serial.println("p: Print calibration"); | ||
Serial.println("r: Read calibration from EEPROM"); | ||
Serial.println("s: Save calibration to EEPROM"); | ||
Serial.println("t: Tare"); | ||
Serial.println("1: Continuous readings"); | ||
Serial.println("0: Stop readings"); | ||
Serial.println("h: Print help"); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ | |
"name": "FabWaage", | ||
"maintainer": "Fablab Bayreuth", | ||
"websiteURL": "http://www.fablab-bayreuth.de", | ||
"email": "holzheu@bayceer.uni-bayreuth.de", | ||
"email": "stefan.[email protected]", | ||
"help": { | ||
"online": "https://github.com/fablab-bayreuth/FabWaage/" | ||
}, | ||
"platforms": [ | ||
{ | ||
"name": "BayEOS AVR Boards", | ||
"name": "Fablab Bayreuth AVR Boards", | ||
"architecture": "avr", | ||
"version": "0.0.2", | ||
"category": "Fabwaage Arduino", | ||
|
@@ -43,4 +43,4 @@ | |
"tools": [] | ||
} | ||
] | ||
} | ||
} |