Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef0ac39c9b | ||
|
|
ad2ce8c33b | ||
|
|
8f5b33c554 | ||
|
|
592351c265 | ||
|
|
d473bf6b8c | ||
|
|
4cb6b41a6b | ||
|
|
bf87be2590 |
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.fcstd text
|
||||||
3
.gitignore
vendored
@@ -7,3 +7,6 @@ build
|
|||||||
|
|
||||||
# drawio files
|
# drawio files
|
||||||
*.bkp
|
*.bkp
|
||||||
|
|
||||||
|
# freecad backup files
|
||||||
|
*.FCStd1
|
||||||
|
|||||||
BIN
cad/box/box-holder_v1.0.FCStd
Normal file
BIN
cad/box/box_v1.0.FCStd
Normal file
2356
cad/box/panel.svg
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
cad/cable-mounts/clamps-startButtons.FCStd
Normal file
BIN
cad/cable-mounts/mounts-item.FCStd
Normal file
BIN
cad/cutter/angle-bracket_v2.0.FCStd
Normal file
BIN
cad/cutter/cutter-mount_2.2.FCStd
Normal file
BIN
cad/emergency-sw/sw_holder_v1.0.FCStd
Normal file
BIN
cad/encoder/disk-flat_SE.par
Normal file
BIN
cad/encoder/disk-flat_SE.stl
Normal file
BIN
cad/encoder/disk-half_SE.par
Normal file
BIN
cad/encoder/disk-half_SE.stl
Normal file
BIN
cad/encoder/holder_v1.0.FCStd
Normal file
BIN
cad/encoder/holder_v2.0.FCStd
Normal file
BIN
cad/encoder/holder_v3.2.FCStd
Normal file
4
cad/export/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
BIN
cad/guides/distance-rings.FCStd
Normal file
BIN
cad/guides/guide-cutter_spacer.FCStd
Normal file
BIN
cad/guides/guide-cutter_v1.0.FCStd
Normal file
BIN
cad/guides/guide-cutter_v2.0.FCStd
Normal file
BIN
cad/guides/guide-cutter_v3.0.FCStd
Normal file
BIN
cad/guides/guide-cutter_v4.2.FCStd
Normal file
BIN
cad/guides/guide-cutter_v5.0.FCStd
Normal file
BIN
cad/guides/guide-cutter_v5.1.FCStd
Normal file
BIN
cad/guides/guide-in-long-rolls_SE.par
Normal file
BIN
cad/guides/guide-in-long-rolls_SE.stl
Normal file
BIN
cad/guides/guide-in-long_SE.par
Normal file
BIN
cad/guides/guide-in-long_SE.stl
Normal file
BIN
cad/guides/guide-in_v1.0.FCStd
Normal file
BIN
cad/guides/guide-in_v1.1.FCStd
Normal file
BIN
cad/guides/guide-in_v2.1.FCStd
Normal file
BIN
cad/reel/cable-reel_v1_SE.par
Normal file
BIN
cad/reel/cable-reel_v1_SE.stl
Normal file
BIN
cad/reel/cable-reel_v2.1.FCStd
Normal file
BIN
docs/3SK1111-1AB30_con1.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
docs/3SK1111-1AB30_con2.jpg
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
docs/LPD3806-dimensions.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
docs/MAX7219-MAX7221-7-segment-display.pdf
Normal file
BIN
docs/vfd/T13-400W-12-HT13-750W-12H-1.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
docs/vfd/T13-400W-12-HT13-750W-12H-2.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
docs/vfd/T13-400W-12-HT13-750W-12H-4.jpg
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
docs/vfd/T13-400W-12-HT13-750W-12H.jpg
Normal file
|
After Width: | Height: | Size: 72 KiB |
2
docs/vfd/currently-used_T13-750W-12-h.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
currently the vfd 'T13-750W-12-h' is actually used.
|
||||||
|
Included documentation about T13-400W here too, modbus specification might be the same.
|
||||||
BIN
docs/vfd/mcu-t13-400w-12-h.pdf
Normal file
@@ -55,6 +55,9 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============================
|
||||||
|
//======= configuration =======
|
||||||
|
//=============================
|
||||||
//--------------------------
|
//--------------------------
|
||||||
//----- display config -----
|
//----- display config -----
|
||||||
//--------------------------
|
//--------------------------
|
||||||
@@ -79,11 +82,20 @@ extern "C" {
|
|||||||
//--------------------------
|
//--------------------------
|
||||||
//------ calibration -------
|
//------ calibration -------
|
||||||
//--------------------------
|
//--------------------------
|
||||||
//use encoder test for calibration and calculate STEPS_PER_METER
|
//enable mode encoder test for calibration
|
||||||
//#define ENCODER_TEST //show encoder count instead of converted meters
|
//if defined, displays always show length and steps instead of the normal messages
|
||||||
|
//#define ENCODER_TEST
|
||||||
|
|
||||||
|
//steps per meter
|
||||||
#define STEPS_PER_METER 2127 //roll-v3-gummi-86.6mm - d=89.8mm
|
#define STEPS_PER_METER 2127 //roll-v3-gummi-86.6mm - d=89.8mm
|
||||||
//#define MEASURING_ROLL_DIAMETER 86.6 //roll v3 large
|
|
||||||
//#define PI 3.14159265358979323846
|
//millimetres added to target length
|
||||||
|
//to ensure that length does not fall short when spool slightly rotates back after stop
|
||||||
|
#define TARGET_LENGTH_OFFSET 0
|
||||||
|
|
||||||
|
//millimetres lengthNow can be below lengthTarget to still stay in target_reached state
|
||||||
|
#define TARGET_REACHED_TOLERANCE 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ QueueHandle_t encoder_queue = NULL; //encoder event queue
|
|||||||
rotary_encoder_state_t encoderState;
|
rotary_encoder_state_t encoderState;
|
||||||
|
|
||||||
int lengthNow = 0; //length measured in mm
|
int lengthNow = 0; //length measured in mm
|
||||||
int lengthTarget = 3000; //target length in mm
|
int lengthTarget = 5000; //default target length in mm
|
||||||
int lengthRemaining = 0; //(target - now) length needed for reaching the target
|
int lengthRemaining = 0; //(target - now) length needed for reaching the target
|
||||||
int potiRead = 0; //voltage read from adc
|
int potiRead = 0; //voltage read from adc
|
||||||
uint32_t timestamp_motorStarted = 0; //timestamp winding started
|
uint32_t timestamp_motorStarted = 0; //timestamp winding started
|
||||||
@@ -54,7 +54,7 @@ int lengthBeeped = 0; //only beep once per meter during encoder test
|
|||||||
//automatic cut
|
//automatic cut
|
||||||
int cut_msRemaining = 0;
|
int cut_msRemaining = 0;
|
||||||
uint32_t timestamp_cut_lastBeep = 0;
|
uint32_t timestamp_cut_lastBeep = 0;
|
||||||
uint32_t autoCut_delayMs = 3000; //TODO add this to config
|
uint32_t autoCut_delayMs = 2500; //TODO add this to config
|
||||||
bool autoCutEnabled = false; //store state of toggle switch (no hotswitch)
|
bool autoCutEnabled = false; //store state of toggle switch (no hotswitch)
|
||||||
|
|
||||||
|
|
||||||
@@ -110,11 +110,11 @@ bool handleStopCondition(handledDisplay * displayTop, handledDisplay * displayBo
|
|||||||
void setDynSpeedLvl(uint8_t lvlMax = 3){
|
void setDynSpeedLvl(uint8_t lvlMax = 3){
|
||||||
uint8_t lvl;
|
uint8_t lvl;
|
||||||
//define speed level according to difference
|
//define speed level according to difference
|
||||||
if (lengthRemaining < 20) {
|
if (lengthRemaining < 40) {
|
||||||
lvl = 0;
|
lvl = 0;
|
||||||
} else if (lengthRemaining < 200) {
|
} else if (lengthRemaining < 300) {
|
||||||
lvl = 1;
|
lvl = 1;
|
||||||
} else if (lengthRemaining < 600) {
|
} else if (lengthRemaining < 700) {
|
||||||
lvl = 2;
|
lvl = 2;
|
||||||
} else { //more than last step remaining
|
} else { //more than last step remaining
|
||||||
lvl = 3;
|
lvl = 3;
|
||||||
@@ -190,12 +190,16 @@ void task_control(void *pvParameter)
|
|||||||
//---------------------------
|
//---------------------------
|
||||||
//--- RESET switch ---
|
//--- RESET switch ---
|
||||||
if (SW_RESET.risingEdge) {
|
if (SW_RESET.risingEdge) {
|
||||||
|
//dont reset when press used for stopping pending auto-cut
|
||||||
|
if (controlState != systemState_t::AUTO_CUT_WAITING) {
|
||||||
rotary_encoder_reset(&encoder);
|
rotary_encoder_reset(&encoder);
|
||||||
lengthNow = 0;
|
lengthNow = 0;
|
||||||
buzzer.beep(1, 700, 100);
|
buzzer.beep(1, 700, 100);
|
||||||
|
displayTop.blink(2, 100, 100, "1ST ");
|
||||||
//TODO: stop cutter with reset switch?
|
//TODO: stop cutter with reset switch?
|
||||||
//cutter_stop();
|
//cutter_stop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--- CUT switch ---
|
//--- CUT switch ---
|
||||||
//start cut cycle immediately
|
//start cut cycle immediately
|
||||||
@@ -205,6 +209,9 @@ void task_control(void *pvParameter)
|
|||||||
cutter_stop();
|
cutter_stop();
|
||||||
buzzer.beep(1, 600, 0);
|
buzzer.beep(1, 600, 0);
|
||||||
}
|
}
|
||||||
|
else if (controlState == systemState_t::AUTO_CUT_WAITING) {
|
||||||
|
//do nothing when press used for stopping pending auto-cut
|
||||||
|
}
|
||||||
//start cutter when motor not active
|
//start cutter when motor not active
|
||||||
else if (controlState != systemState_t::WINDING_START //TODO use vfd state here?
|
else if (controlState != systemState_t::WINDING_START //TODO use vfd state here?
|
||||||
&& controlState != systemState_t::WINDING) {
|
&& controlState != systemState_t::WINDING) {
|
||||||
@@ -250,7 +257,7 @@ void task_control(void *pvParameter)
|
|||||||
//read adc
|
//read adc
|
||||||
potiRead = gpio_readAdc(ADC_CHANNEL_POTI); //0-4095
|
potiRead = gpio_readAdc(ADC_CHANNEL_POTI); //0-4095
|
||||||
//scale to target length range
|
//scale to target length range
|
||||||
int lengthTargetNew = (float)potiRead / 4095 * 30000;
|
int lengthTargetNew = (float)potiRead / 4095 * 50000;
|
||||||
//apply hysteresis and round to whole meters //TODO optimize this
|
//apply hysteresis and round to whole meters //TODO optimize this
|
||||||
if (lengthTargetNew % 1000 < 200) { //round down if less than .2 meter
|
if (lengthTargetNew % 1000 < 200) { //round down if less than .2 meter
|
||||||
ESP_LOGD(TAG, "Poti input = %d -> rounding down", lengthTargetNew);
|
ESP_LOGD(TAG, "Poti input = %d -> rounding down", lengthTargetNew);
|
||||||
@@ -283,20 +290,20 @@ void task_control(void *pvParameter)
|
|||||||
//--- target length presets ---
|
//--- target length presets ---
|
||||||
if (controlState != systemState_t::MANUAL) { //dont apply preset length while controlling motor with preset buttons
|
if (controlState != systemState_t::MANUAL) { //dont apply preset length while controlling motor with preset buttons
|
||||||
if (SW_PRESET1.risingEdge) {
|
if (SW_PRESET1.risingEdge) {
|
||||||
lengthTarget = 1000;
|
|
||||||
buzzer.beep(lengthTarget/1000, 25, 30);
|
|
||||||
displayBot.blink(3, 100, 100, "S0LL ");
|
|
||||||
}
|
|
||||||
else if (SW_PRESET2.risingEdge) {
|
|
||||||
lengthTarget = 5000;
|
lengthTarget = 5000;
|
||||||
buzzer.beep(lengthTarget/1000, 25, 30);
|
buzzer.beep(lengthTarget/1000, 25, 30);
|
||||||
displayBot.blink(2, 100, 100, "S0LL ");
|
displayBot.blink(2, 100, 100, "S0LL ");
|
||||||
}
|
}
|
||||||
else if (SW_PRESET3.risingEdge) {
|
else if (SW_PRESET2.risingEdge) {
|
||||||
lengthTarget = 10000;
|
lengthTarget = 10000;
|
||||||
buzzer.beep(lengthTarget/1000, 25, 30);
|
buzzer.beep(lengthTarget/1000, 25, 30);
|
||||||
displayBot.blink(2, 100, 100, "S0LL ");
|
displayBot.blink(2, 100, 100, "S0LL ");
|
||||||
}
|
}
|
||||||
|
else if (SW_PRESET3.risingEdge) {
|
||||||
|
lengthTarget = 15000;
|
||||||
|
buzzer.beep(lengthTarget/1000, 25, 30);
|
||||||
|
displayBot.blink(2, 100, 100, "S0LL ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -305,7 +312,7 @@ void task_control(void *pvParameter)
|
|||||||
//--------- control ---------
|
//--------- control ---------
|
||||||
//---------------------------
|
//---------------------------
|
||||||
//calculate length difference
|
//calculate length difference
|
||||||
lengthRemaining = lengthTarget - lengthNow;
|
lengthRemaining = lengthTarget - lengthNow + TARGET_LENGTH_OFFSET;
|
||||||
|
|
||||||
//--- statemachine ---
|
//--- statemachine ---
|
||||||
switch (controlState) {
|
switch (controlState) {
|
||||||
@@ -342,7 +349,7 @@ void task_control(void *pvParameter)
|
|||||||
case systemState_t::TARGET_REACHED:
|
case systemState_t::TARGET_REACHED:
|
||||||
vfd_setState(false);
|
vfd_setState(false);
|
||||||
//switch to counting state when no longer at or above target length
|
//switch to counting state when no longer at or above target length
|
||||||
if ( lengthRemaining > 10 ) { //FIXME: require reset switch to be able to restart? or evaluate a tolerance here?
|
if ( lengthNow < lengthTarget - TARGET_REACHED_TOLERANCE ) {
|
||||||
changeState(systemState_t::COUNTING);
|
changeState(systemState_t::COUNTING);
|
||||||
}
|
}
|
||||||
//switch initiate countdown to auto-cut
|
//switch initiate countdown to auto-cut
|
||||||
@@ -362,8 +369,13 @@ void task_control(void *pvParameter)
|
|||||||
//handle delayed start of cut
|
//handle delayed start of cut
|
||||||
cut_msRemaining = autoCut_delayMs - (esp_log_timestamp() - timestamp_changedState);
|
cut_msRemaining = autoCut_delayMs - (esp_log_timestamp() - timestamp_changedState);
|
||||||
//- countdown stop conditions -
|
//- countdown stop conditions -
|
||||||
if (!autoCutEnabled || !SW_AUTO_CUT.state || SW_RESET.state || SW_CUT.state) { //TODO: also stop when target not reached anymore?
|
//stop with any button
|
||||||
|
if (!autoCutEnabled
|
||||||
|
|| SW_RESET.state || SW_CUT.state
|
||||||
|
|| SW_SET.state || SW_PRESET1.state
|
||||||
|
|| SW_PRESET2.state || SW_PRESET3.state) {//TODO: also stop when target not reached anymore?
|
||||||
changeState(systemState_t::COUNTING);
|
changeState(systemState_t::COUNTING);
|
||||||
|
buzzer.beep(5, 100, 50);
|
||||||
}
|
}
|
||||||
//- trigger cut if delay passed -
|
//- trigger cut if delay passed -
|
||||||
else if (cut_msRemaining <= 0) {
|
else if (cut_msRemaining <= 0) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ max7219_t display_init(){
|
|||||||
ESP_ERROR_CHECK(max7219_init_desc(&dev, HOST, MAX7219_MAX_CLOCK_SPEED_HZ, DISPLAY_PIN_NUM_CS));
|
ESP_ERROR_CHECK(max7219_init_desc(&dev, HOST, MAX7219_MAX_CLOCK_SPEED_HZ, DISPLAY_PIN_NUM_CS));
|
||||||
ESP_ERROR_CHECK(max7219_init(&dev));
|
ESP_ERROR_CHECK(max7219_init(&dev));
|
||||||
//0...15
|
//0...15
|
||||||
ESP_ERROR_CHECK(max7219_set_brightness(&dev, 8));
|
ESP_ERROR_CHECK(max7219_set_brightness(&dev, 8)); //TODO add this to config
|
||||||
return dev;
|
return dev;
|
||||||
//display = dev;
|
//display = dev;
|
||||||
ESP_LOGI(TAG, "initializing display - done");
|
ESP_LOGI(TAG, "initializing display - done");
|
||||||
@@ -50,7 +50,7 @@ void display_ShowWelcomeMsg(max7219_t dev){
|
|||||||
//show name and date
|
//show name and date
|
||||||
ESP_LOGI(TAG, "showing startup message...");
|
ESP_LOGI(TAG, "showing startup message...");
|
||||||
max7219_clear(&dev);
|
max7219_clear(&dev);
|
||||||
max7219_draw_text_7seg(&dev, 0, "CUTTER 20.08.2022");
|
max7219_draw_text_7seg(&dev, 0, "CUTTER 29.09.2022");
|
||||||
// 1234567812 34 5678
|
// 1234567812 34 5678
|
||||||
vTaskDelay(pdMS_TO_TICKS(700));
|
vTaskDelay(pdMS_TO_TICKS(700));
|
||||||
//scroll "hello" over 2 displays
|
//scroll "hello" over 2 displays
|
||||||
@@ -60,6 +60,11 @@ void display_ShowWelcomeMsg(max7219_t dev){
|
|||||||
max7219_draw_text_7seg(&dev, 0, hello + (22 - offset) );
|
max7219_draw_text_7seg(&dev, 0, hello + (22 - offset) );
|
||||||
vTaskDelay(pdMS_TO_TICKS(50));
|
vTaskDelay(pdMS_TO_TICKS(50));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//noticed rare bug that one display does not initialize / is not configured correctly after start
|
||||||
|
//initialize display again after the welcome message in case it did not work the first time
|
||||||
|
ESP_ERROR_CHECK(max7219_init(&dev));
|
||||||
|
ESP_ERROR_CHECK(max7219_set_brightness(&dev, 8)); //TODO add this to config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||