technik-gegg / SMuFF-1.1

Latest version of the SMuFF firmware to be compiled in PlatformIO
https://sites.google.com/view/the-smuff/
193 stars 30 forks source link

Compatible LCDs and support for NUCLEO-F103RB #8

Closed sl1pkn07 closed 4 years ago

sl1pkn07 commented 4 years ago

Hi

im looking and buy the pieces for mount this awesome project!

but i have a lite questions

what type of LCDs is compatible with Smuff?

can work with SPI displays like the CR10/ENDER3 display? (10wires, display+encoder) (i have one wothout use)

if only use I2C, this display can work? https://es.aliexpress.com/item/32853228170.html (editer, the other display is SPI (damm SDA name XD)) 0.9" is little small for me (and +2" is quite expensive)

my project is based on ST NUCLEO-F103RB+CNC shield

greetings

technik-gegg commented 4 years ago

Since you're planning not to use an aftermarket controller (i.e. SKR mini) but the Nucleo development board, you can use pretty much any display you pick. Though, you have to check beforehand whether or not the display controller you pick is supported by the U8G2 library from Oliver Kraus, since this is the one the SMuFF firmware builds upon. If it does, you only have to initialize the correct display (controller type) in SMuFF.cpp. I'd say, chances are pretty good you'll be able to reuse your CR10 display (aka standard RepRap 12864 display).

I've used the I2C OLED for two reasons:

  1. The SKR mini on board display connectors are driven through the SPI3 interface. U8G2 doesn't support this interface directly (only SPI1 and SPI2 in some cases). This would have required to clone the library and patch it where needed, which is somehow neglecting the meaning of a "standard library".
  2. The I2C OLED is pretty easy to integrate (4 pins only). Sure, it's physical size (0.9" or 1.3") isn't huge but it comes with a decent resolution of 128 x 64 px. In case of the SMuFF controller the physical size doesn't matter much, since you'll not be doing something major with it most of the time. It's being used only for setup and some status information display.
sl1pkn07 commented 4 years ago

Hi

the TFT i posted use the SSD1327 controller, and seems is supported by U8G2

i use the nucleo because have the same family of MCU (STM32F103XXX6) and i have already one

thanks

PD: a litle offtopic. you know this board?

https://wiki.fysetc.com/AIO_II/ https://github.com/FYSETC/AIO_II

i think is perfect for you project (up to V3, i think is not compatible with servos). have 4 drivers (exist a module for 4xTMC2208 in UART), have integrated LCD, encoder, SD and reset button. also have a free Serial pin header (include I2C pinout)

technik-gegg commented 4 years ago

Yes, the display is supported although, it's got twice the resolution in height (128px), so you might need to modify some of the screens of the SMuFF firmware.

The FYSETC controller is nice! Great find. It's a combination of the Wanhao i3 mini (first controller of the SMuFF) and the SKR - I might want one ;o)

sl1pkn07 commented 4 years ago

i have one, but i want to use for other project (DVD drive printer). sadly the missing servo. i'm not sure if can be used the fancy RGB port as servo

greetings

technik-gegg commented 4 years ago

You can use the RGB if you get access to the signal before the MOSFETS. That's the price you pay for highly integrated stuff...

sl1pkn07 commented 4 years ago

Hi, sorry for hihacked my own thread, but i need little help with support for Nucleo-f103rb

~~~patch diff --git a/Configs/NUCLEO_F103RB/SMUFF_Duet.CFG b/Configs/NUCLEO_F103RB/SMUFF_Duet.CFG new file mode 100644 index 0000000..39770dc --- /dev/null +++ b/Configs/NUCLEO_F103RB/SMUFF_Duet.CFG @@ -0,0 +1,70 @@ +{ + "Serial1Baudrate": 56700, + "Serial2Baudrate": 56700, + "SerialDueBaudrate": 56700, + "ToolCount": 5, + "BowdenLength": 620.0, + "SelectorDist": 34.0, + "LCDContrast": 190, + "I2CAddress": 136, + "MenuAutoClose": 20, + "FanSpeed": 50, + "DelayBetweenPulses": false, + "PowerSaveTimeout": 300, + "Duet3DDirect": true, + "EmulatePrusa": false, + "UnloadCommand": "", + + "Selector": { + "Offset": 0.5, + "Spacing": 21.0, + "StepsPerMillimeter": 80, + "Acceleration": 12000, + "MaxSpeed": 2000, + "MaxSpeedHS": 2500, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 10 + }, + "Revolver": { + "StepsPerRevolution": 9600, + "Offset": 1275, + "Acceleration": 22000, + "MaxSpeed": 10000, + "ResetBeforeFeed": true, + "HomeAfterFeed": false, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 5, + "Wiggle": false, + "UseServo": false, + "ServoOffPos": 30, + "ServoOnPos": 90 + }, + "Feeder": { + "ExternalControl": true, + "StepsPerMillimeter": 410, + "Acceleration": 20000, + "MaxSpeed": 1400, + "InsertSpeed": 20000, + "ReinforceLength": 0, + "UnloadRetract": 0, + "UnloadPushback": 0, + "PushbackDelay": 2.0, + "InvertDir": true, + "EndstopTrigger": 1, + "StepDelay": 3, + "EnableChunks": false, + "FeedChunks": 20, + "InsertLength": 5, + "DuetLaser": false + }, + "Materials": { + "T0": "PLA Green", + "T1": "PLA White", + "T2": "PLA Red", + "T3": "PLA Black", + "T4": "PLA Silver" + } +} + diff --git a/Configs/NUCLEO_F103RB/SMUFF_PMMU.CFG b/Configs/NUCLEO_F103RB/SMUFF_PMMU.CFG new file mode 100644 index 0000000..9725a21 --- /dev/null +++ b/Configs/NUCLEO_F103RB/SMUFF_PMMU.CFG @@ -0,0 +1,71 @@ +{ + "Serial1Baudrate": 56700, + "Serial2Baudrate": 56700, + "SerialDueBaudrate": 56700, + "ToolCount": 5, + "BowdenLength": 620.0, + "SelectorDist": 34.0, + "LCDContrast": 190, + "I2CAddress": 136, + "MenuAutoClose": 20, + "FanSpeed": 50, + "DelayBetweenPulses": false, + "PowerSaveTimeout": 300, + "Duet3DDirect": false, + "EmulatePrusa": true, + "UnloadCommand": "", + + "Selector": { + "Offset": 0.5, + "Spacing": 21.0, + "StepsPerMillimeter": 80, + "Acceleration": 12000, + "MaxSpeed": 2000, + "MaxSpeedHS": 2500, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 10 + }, + "Revolver": { + "StepsPerRevolution": 9600, + "Offset": 1275, + "Acceleration": 22000, + "MaxSpeed": 10000, + "ResetBeforeFeed": true, + "HomeAfterFeed": true, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 5, + "Wiggle": false, + "UseServo": false, + "ServoOffPos": 30, + "ServoOnPos": 90 + }, + "Feeder": { + "ExternalControl": true, + "StepsPerMillimeter": 410, + "Acceleration": 20000, + "MaxSpeed": 1400, + "InsertSpeed": 20000, + "ReinforceLength": 0, + "UnloadRetract": 0, + "UnloadPushback": 0, + "PushbackDelay": 2.0, + "InvertDir": true, + "EndstopTrigger": 1, + "StepDelay": 3, + "EnableChunks": false, + "FeedChunks": 20, + "InsertLength": 5, + "DuetLaser": false + + }, + "Materials": { + "T0": "PLA Green", + "T1": "PLA White", + "T2": "PLA Red", + "T3": "PLA Black", + "T4": "PLA Silver" + } +} + diff --git a/Configs/NUCLEO_F103RB/SMUFF_Servo.CFG b/Configs/NUCLEO_F103RB/SMUFF_Servo.CFG new file mode 100644 index 0000000..b26d3a0 --- /dev/null +++ b/Configs/NUCLEO_F103RB/SMUFF_Servo.CFG @@ -0,0 +1,71 @@ +{ + "Serial1Baudrate": 56700, + "Serial2Baudrate": 56700, + "SerialDueBaudrate": 56700, + "ToolCount": 5, + "BowdenLength": 620.0, + "SelectorDist": 34.0, + "LCDContrast": 190, + "I2CAddress": 136, + "MenuAutoClose": 20, + "FanSpeed": 50, + "DelayBetweenPulses": false, + "PowerSaveTimeout": 300, + "Duet3DDirect": false, + "EmulatePrusa": true, + "UnloadCommand": "", + + "Selector": { + "Offset": 0.5, + "Spacing": 21.0, + "StepsPerMillimeter": 80, + "Acceleration": 12000, + "MaxSpeed": 2000, + "MaxSpeedHS": 2500, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 10 + }, + "Revolver": { + "StepsPerRevolution": 9600, + "Offset": 1275, + "Acceleration": 22000, + "MaxSpeed": 10000, + "ResetBeforeFeed": true, + "HomeAfterFeed": true, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 5, + "Wiggle": false, + "UseServo": true, + "ServoOffPos": 30, + "ServoOnPos": 90 + }, + "Feeder": { + "ExternalControl": true, + "StepsPerMillimeter": 410, + "Acceleration": 20000, + "MaxSpeed": 1400, + "InsertSpeed": 20000, + "ReinforceLength": 0, + "UnloadRetract": 0, + "UnloadPushback": 0, + "PushbackDelay": 2.0, + "InvertDir": true, + "EndstopTrigger": 1, + "StepDelay": 3, + "EnableChunks": false, + "FeedChunks": 20, + "InsertLength": 5, + "DuetLaser": false + + }, + "Materials": { + "T0": "PLA Green", + "T1": "PLA White", + "T2": "PLA Red", + "T3": "PLA Black", + "T4": "PLA Silver" + } +} + diff --git a/Configs/NUCLEO_F103RB/SMUFF_Servo_Duet.CFG b/Configs/NUCLEO_F103RB/SMUFF_Servo_Duet.CFG new file mode 100644 index 0000000..d9e2dfa --- /dev/null +++ b/Configs/NUCLEO_F103RB/SMUFF_Servo_Duet.CFG @@ -0,0 +1,70 @@ +{ + "Serial1Baudrate": 56700, + "Serial2Baudrate": 56700, + "SerialDueBaudrate": 56700, + "ToolCount": 5, + "BowdenLength": 620.0, + "SelectorDist": 34.0, + "LCDContrast": 190, + "I2CAddress": 136, + "MenuAutoClose": 20, + "FanSpeed": 50, + "DelayBetweenPulses": false, + "PowerSaveTimeout": 300, + "Duet3DDirect": true, + "EmulatePrusa": false, + "UnloadCommand": "", + + "Selector": { + "Offset": 0.5, + "Spacing": 21.0, + "StepsPerMillimeter": 80, + "Acceleration": 12000, + "MaxSpeed": 2000, + "MaxSpeedHS": 2500, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 10 + }, + "Revolver": { + "StepsPerRevolution": 9600, + "Offset": 1275, + "Acceleration": 22000, + "MaxSpeed": 10000, + "ResetBeforeFeed": true, + "HomeAfterFeed": false, + "InvertDir": false, + "EndstopTrigger": 1, + "StepDelay": 5, + "Wiggle": false, + "UseServo": true, + "ServoOffPos": 30, + "ServoOnPos": 90 + }, + "Feeder": { + "ExternalControl": true, + "StepsPerMillimeter": 410, + "Acceleration": 20000, + "MaxSpeed": 1400, + "InsertSpeed": 20000, + "ReinforceLength": 0, + "UnloadRetract": 0, + "UnloadPushback": 0, + "PushbackDelay": 2.0, + "InvertDir": true, + "EndstopTrigger": 1, + "StepDelay": 3, + "EnableChunks": false, + "FeedChunks": 20, + "InsertLength": 5, + "DuetLaser": false + }, + "Materials": { + "T0": "PLA Green", + "T1": "PLA White", + "T2": "PLA Red", + "T3": "PLA Black", + "T4": "PLA Silver" + } +} + diff --git a/include/NUCLEO_F103RB/Pins.h b/include/NUCLEO_F103RB/Pins.h new file mode 100644 index 0000000..a3d86bc --- /dev/null +++ b/include/NUCLEO_F103RB/Pins.h @@ -0,0 +1,97 @@ +/** + * SMuFF Firmware + * Copyright (C) 2019 Technik Gegg + * Copyright (C) 2020 sL1pKn07 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +/* + * Pins configuration file for NUCLEO-F103RB biard + CNC Shield board + */ +#pragma once + +#define BOARD_INFO "NUCLEO-F103RB + CNC Shield" +// SELECTOR (X) +#define STEP_HIGH_X digitalWrite(X_STEP_PIN, HIGH); +#define STEP_LOW_X digitalWrite(X_STEP_PIN, LOW); +#define X_STEP_PIN PC6 +#define X_DIR_PIN PC7 +#define X_ENABLE_PIN PB15 +#define X_END_PIN PC2 +// REVOLVER (Y) +#define STEP_HIGH_Y digitalWrite(Y_STEP_PIN, HIGH); +#define STEP_LOW_Y digitalWrite(Y_STEP_PIN, LOW); +#define Y_STEP_PIN PB13 +#define Y_DIR_PIN PB14 +#define Y_ENABLE_PIN PB12 +#define Y_END_PIN PC1 +// FEEDER (E) +// moved from Z to E because of the pins for 2nd Serial port +#define STEP_HIGH_Z digitalWrite(Z_STEP_PIN, HIGH); +#define STEP_LOW_Z digitalWrite(Z_STEP_PIN, LOW); +#define Z_STEP_PIN PC5 +#define Z_DIR_PIN PB0 +#define Z_ENABLE_PIN PC4 +#define Z_END_PIN PC0 +#define Z_END2_PIN PA2 +#define Z_END_DUET_PIN PC3 // for testing only + +#define BEEPER_PIN PC10 + +//#define SERVO1_PIN PB1 // THB - Not usable. See SKR mini schematics +//#define SERVO2_PIN PA0 // TH0 - Not usable. See SKR mini schematics + +#define SERVO1_PIN PA1 // Endstop Y+ +#define SERVO2_PIN PC3 // Endstop Z+ +#define FAN_PIN PC8 +#define HEATER0_PIN PA8 +#define HEATBED_PIN PC9 + +#define NEOPIXEL_PIN PC10 + +#define SDCS_PIN -1 // use default +#define DSP_CS_PIN PB7 // These pins are only valid if a SPI display is being used +#define DSP_DC_PIN PC15 +#define DSP_RESET_PIN -1 + +#define DSP_SCL PB6 // By default we run the SMuFF controller display on TWI (I2C) +#define DSP_SDA PB7 + +#ifndef USE_TWI_DISPLAY +#define ENCODER1_PIN PD2 +#define ENCODER2_PIN PB8 +#else +#define ENCODER1_PIN PC14 // moved over to EXP1 for a more convenient cabeling +#define ENCODER2_PIN PC15 // (only possible if TWI display is used) +#endif +#define ENCODER_BUTTON_PIN PC11 + + +#ifdef USE_TWI_DISPLAY +#define DEBUG_OFF_PIN -1 // not needed on TWI display +#else +#define DEBUG_OFF_PIN PC3 // (PC3) Z+ pin - set to GND to re-enable debugging via STLink +#endif + +#define TX3_PIN PB10 // on SKR Mini usually used for Z-Axis STEP +#define RX3_PIN PB11 // on SKR Mini usually used for Z-Axis DIR + +/* + Those pins cannot be used for serial data transfer because they're + already in use on the SKR Mini V1.1 +*/ +#define TX2_PIN PA2 // on SKR Mini already used for X+ endstop (but might be reconfigured) +#define RX2_PIN PA3 // on SKR Mini already used for SD-Card DATA2 + diff --git a/include/SMuFF.h b/include/SMuFF.h index 3351218..7789f3b 100644 --- a/include/SMuFF.h +++ b/include/SMuFF.h @@ -137,6 +137,9 @@ extern U8G2_ST7565_64128N_F_4W_HW_SPI display; extern U8G2_UC1701_MINI12864_1_2ND_4W_HW_SPI display; #endif #endif +#ifdef __BRD_NUCLEO_F103RB +extern U8G2_SSD1327_WS_128X128_F_HW_I2C display; +#endif extern ClickEncoder encoder; diff --git a/platformio.ini b/platformio.ini index 058de0c..3888593 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,8 +10,8 @@ [platformio] #core_dir = D:/data/PlatformIO/ #src_dir = /SMuFF -default_envs = BIGTREE_SKR_MINI, WANHAO_I3_MINI -#default_envs = BIGTREE_SKR_MINI +;default_envs = BIGTREE_SKR_MINI, WANHAO_I3_MINI, NUCLEO_F103RB +default_envs = NUCLEO_F103RB [common] lib_deps = @@ -69,3 +69,22 @@ lib_deps = ${common.lib_deps} monitor_speed = 230400 upload_protocol = stlink debug_tool = stlink + +# +# NUCLEO_F103RB + CNC shield +# +[env:NUCLEO_F103RB] +platform = ststm32 +framework = arduino +board = genericSTM32F103RB +build_flags = ${common.build_flags} + -g + -I include/NUCLEO_F103RB + -D __BRD_NUCLEO_F103RB + -D __STM32F1__ + -D USE_TWI_DISPLAY +build_unflags = -std=gnu++11 $(common.build_unflags) +lib_deps = ${common.lib_deps} +monitor_speed = 230400 +upload_protocol = stlink +debug_tool = stlink diff --git a/src/SMuFF.cpp b/src/SMuFF.cpp index 344fe4b..276e97c 100644 --- a/src/SMuFF.cpp +++ b/src/SMuFF.cpp @@ -33,6 +33,9 @@ U8G2_ST7565_64128N_F_4W_HW_SPI display(U8G2_R2, /* cs=*/ DSP_CS_PIN, /* dc=*/ D U8G2_UC1701_MINI12864_1_2ND_4W_HW_SPI display(U8G2_R0, /* cs=*/ DSP_CS_PIN, /* dc=*/ DSP_DC_PIN, /* reset=*/ DSP_RESET_PIN); #endif #endif +#ifdef __BRD_NUCLEO_F103RB +U8G2_SSD1327_WS_128X128_F_HW_I2C display(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); +#endif ZStepper steppers[NUM_STEPPERS]; ZTimer stepperTimer; ~~~

https://github.com/sl1pkn07/SMuFF-1.1/tree/nucleo_f103rb

Linking .pio/build/NUCLEO_F103RB/firmware.elf
/home/sl1pkn07/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld: .pio/build/NUCLEO_F103RB/firmware.elf section `.rodata' will not fit in region `rom'
/home/sl1pkn07/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld: region `rom' overflowed by 320 bytes
collect2: error: ld returned 1 exit status
*** [.pio/build/NUCLEO_F103RB/firmware.elf] Error 1

:cry:

how i can redute that 320Bytes? in one of your post in thinkiverse (i don't rebember what) you say i can put the json files into the headers, and i can get rid the SD code and json parser

how?

greetings and sorry

technik-gegg commented 4 years ago

I don't think you'll get it 320 bytes down by removing the JSON parser. I'd rather say, shorten the texts in String.h, since those will be put into the ROM section as well.

To get rid of the JSON parser, you have to put your values as defaults into the smuffConfig structure in SMuFF.h and comment out the code in Config.cpp.

Edit: Be aware that you won't be able to change or rather store changed parameters from the menus anymore if you kick out the JSON / SD-Card part.

sl1pkn07 commented 4 years ago

with

diff --git a/include/SMuFFBitmaps.h b/include/SMuFFBitmaps.h
index a2ac3cd..42028e6 100644
--- a/include/SMuFFBitmaps.h
+++ b/include/SMuFFBitmaps.h
@@ -22,7 +22,11 @@

 #define logo_width  128
 #define logo_height 64
-static const unsigned char logo_bits[] PROGMEM = {
+#ifdef __BRD_NUCLEO_F103RB
+  static const unsigned char logo_bits[] PROGMEM = {
+  0x00, };
+#else
+  static const unsigned char logo_bits[] PROGMEM = {
   0x00, 0x00, 0xE0, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x1F, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7F, 0x00, 
@@ -109,5 +113,5 @@ static const unsigned char logo_bits[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, };
-
+  #endif
 #endif
diff --git a/src/SMuFF.cpp b/src/SMuFF.cpp
@@ -109,5 +113,5 @@ static const unsigned char logo_bits[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, };
-
+  #endif
 #endif
Checking size .pio/build/NUCLEO_F103RB/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=====     ]  53.9% (used 11032 bytes from 20480 bytes)
Flash: [==========]  99.5% (used 130368 bytes from 131072 bytes)
================================================================================================================== [SUCCESS] Took 4.79 seconds ==================================================================================================================

Environment       Status    Duration
----------------  --------  ------------
WANHAO_I3_MINI    IGNORED
BIGTREE_SKR_MINI  IGNORED
NUCLEO_F103RB     SUCCESS   00:00:04.785
================================================================================================================== 1 succeeded in 00:00:04.785 ==================================================================================================================

should be ok?

technik-gegg commented 4 years ago

WTF?

technik-gegg commented 4 years ago

Well, ok ;o)

sl1pkn07 commented 4 years ago

the code is not for merge to upstream, so don't worry xd

sl1pkn07 commented 4 years ago

well, the branch experimental overflow the nucleo by 1264 bytes

well, time to mod the nucleo! (STM32F103RET6 incoming!)