mirror of
https://github.com/usatiuk/EggbotWireless.git
synced 2025-10-28 17:57:48 +01:00
Compare commits
5 Commits
v2.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
574c69d41c | ||
| 4b46fc080c | |||
| 1c98e2670e | |||
| 54c8417f9d | |||
| 4621c3db8b |
16687
App/package-lock.json
generated
16687
App/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -22,18 +22,24 @@ board_hardware.oscillator = external
|
||||
board_hardware.uart = no_bootloader
|
||||
; Brown-out detection
|
||||
board_hardware.bod = 2.7v
|
||||
|
||||
; specify fuses because platformio burns wrong ones when uploading
|
||||
board_fuse.lfuse = 0xf7
|
||||
board_fuse.hfuse = 0xd7
|
||||
board_fuse.efuse = 0xfd
|
||||
build_unflags = -flto
|
||||
|
||||
board_upload.speed = 115200
|
||||
|
||||
monitor_speed = 9600
|
||||
|
||||
upload_protocol = stk500
|
||||
upload_port = COM3
|
||||
upload_flags = -PCOM3
|
||||
; Custom upload procedure
|
||||
upload_protocol = custom
|
||||
; Avrdude upload flags
|
||||
upload_flags =
|
||||
-C$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
|
||||
-p$BOARD_MCU
|
||||
-PCOM3
|
||||
-cstk500
|
||||
-e
|
||||
; Avrdude upload command
|
||||
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
|
||||
|
||||
|
||||
|
||||
lib_deps = 883 #Servo
|
||||
@@ -20,21 +20,21 @@ int calculateDelay(float rpm, int stepsPerRevolution) {
|
||||
}
|
||||
|
||||
void adjustRPM() {
|
||||
eggStepperRPM = curRPM;
|
||||
servoStepperRPM = curRPM;
|
||||
eggStepperDelay = calculateDelay(curRPM, STEPS_PER_REVOLUTION);
|
||||
servoStepperDelay = calculateDelay(curRPM, STEPS_PER_REVOLUTION);
|
||||
if (needAdjust) {
|
||||
unsigned int stepsX = servoStepper.getRemainingSteps();
|
||||
unsigned int stepsY = eggStepper.getRemainingSteps();
|
||||
if (stepsX != 0 && stepsY != 0) {
|
||||
if (stepsX > stepsY) {
|
||||
eggStepperRPM = (float)curRPM * (float)stepsY / (float)stepsX;
|
||||
} else if (stepsY > stepsX) {
|
||||
servoStepperRPM = (float)curRPM * (float)stepsX / (float)stepsY;
|
||||
eggStepperDelay =
|
||||
(float)servoStepperDelay * (float)stepsX / (float)stepsY;
|
||||
} else {
|
||||
servoStepperDelay =
|
||||
(float)eggStepperDelay * (float)stepsY / (float)stepsX;
|
||||
}
|
||||
}
|
||||
}
|
||||
eggStepperDelay = calculateDelay(eggStepperRPM, STEPS_PER_REVOLUTION);
|
||||
servoStepperDelay = calculateDelay(servoStepperRPM, STEPS_PER_REVOLUTION);
|
||||
}
|
||||
|
||||
Command command;
|
||||
@@ -77,8 +77,6 @@ void requestEvent() {
|
||||
|
||||
sts.toBytes(txBuffer);
|
||||
Wire.write(txBuffer, i2cStsBytes);
|
||||
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
void execCommand(Command cmd) {
|
||||
@@ -133,10 +131,11 @@ void setup() {
|
||||
OCR2A = 250;
|
||||
TCCR2A |= (1 << WGM20) | (1 << CS21);
|
||||
TIMSK2 |= (1 << OCIE2A);
|
||||
wdt_enable(WDTO_8S);
|
||||
wdt_enable(WDTO_500MS);
|
||||
}
|
||||
|
||||
volatile unsigned int tick = 0;
|
||||
volatile bool newTick = false;
|
||||
void steppersRoutine() {
|
||||
if (tick % eggStepperDelay == 0) {
|
||||
eggStepper.doStep();
|
||||
@@ -155,11 +154,31 @@ We use our own timer for more precise timings
|
||||
*/
|
||||
ISR(TIMER2_COMPA_vect) {
|
||||
tick++;
|
||||
steppersRoutine();
|
||||
newTick = true;
|
||||
}
|
||||
|
||||
volatile unsigned int tps = 0;
|
||||
volatile unsigned long long oldmillis = 0;
|
||||
void loop() {
|
||||
if (newCommand) {
|
||||
execCommand(command);
|
||||
}
|
||||
if (newTick) {
|
||||
steppersRoutine();
|
||||
tps++;
|
||||
newTick = false;
|
||||
}
|
||||
if (millis() - oldmillis > 1000) {
|
||||
oldmillis = millis();
|
||||
Serial.println(tps);
|
||||
Serial.print(eggStepper.getRemainingSteps());
|
||||
Serial.print(" ");
|
||||
Serial.println(servoStepper.getRemainingSteps());
|
||||
Serial.print(eggStepperDelay);
|
||||
Serial.print(" ");
|
||||
Serial.println(servoStepperDelay);
|
||||
|
||||
tps = 0;
|
||||
}
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ My attempt at making the ordinary egg-drawing robot a bit special, by ~adding a
|
||||
|
||||
<img src="docs/assembled1.jpg" width="30%">
|
||||
<img src="docs/assembled2.jpg" width="30%">
|
||||
<img src="docs/disassembled.jpg" width="30%">
|
||||
<img src="docs/board2.jpg" width="30%">
|
||||
|
||||
## Known issues
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 162 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 325 KiB After Width: | Height: | Size: 163 KiB |
BIN
docs/board2.jpg
Normal file
BIN
docs/board2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 347 KiB |
Reference in New Issue
Block a user