Skip to content

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
+ addjust FabWaage to Arduino 2.0
  • Loading branch information
holzheu committed Mar 31, 2023
1 parent dc4476e commit 0037de5
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 8 deletions.
11 changes: 6 additions & 5 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# atmega328p or atmega328pb
#
##############################################################
menu.variant=Board Variant
menu.BoardModel=Board Model

fabwaage_atmega328.name=FabWaage

Expand All @@ -15,7 +15,7 @@ fabwaage_atmega328.upload.speed=57600

fabwaage_atmega328.bootloader.low_fuses=0xE2
fabwaage_atmega328.bootloader.high_fuses=0xDA
fabwaage_atmega328.menu.cpu.mega328p_8mhz2.bootloader.extended_fuses=0x05
fabwaage_atmega328.bootloader.extended_fuses=0x05
fabwaage_atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_bayeos_8MHz_RTC.hex
fabwaage_atmega328.bootloader.unlock_bits=0x3F
fabwaage_atmega328.bootloader.lock_bits=0x0F
Expand All @@ -29,11 +29,12 @@ fabwaage_atmega328.build.mcu=atmega328p
fabwaage_atmega328.build.f_cpu=8000000L
fabwaage_atmega328.upload.maximum_size=30720

fabwaage_atmega328.menu.variant.nokia=Nokia 5110 LCD
fabwaage_atmega328.menu.BoardModel.nokia=Nokia 5110 LCD


## Variant 7Seg
fabwaage_atmega328.menu.variant.7seg=LED 7-Segment
fabwaage_atmega328.menu.variant.7seg.build.variant=7seg
fabwaage_atmega328.menu.BoardModel.7seg=LED 7-Segment
fabwaage_atmega328.menu.BoardModel.7seg.build.variant=7seg



Expand Down
130 changes: 130 additions & 0 deletions libraries/HX711Array/examples/calibration/calibration.ino
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.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void loop(void){
delay(1000);
ntc.readResistance();
float temp=ntc.getTemp(0);
scale.power_up();
long adc = scale.read_average(5);

Serial.print(temp);
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions package_fabwaage_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -43,4 +43,4 @@
"tools": []
}
]
}
}

0 comments on commit 0037de5

Please sign in to comment.