Anyone tried to make a 3D Printer controller?

What are you developing?
ag123
Posts: 798
Joined: Thu Jul 21, 2016 4:24 pm

Re: Anyone tried to make a 3D Printer controller?

Post by ag123 » Mon Sep 25, 2017 3:20 pm

i'm starting to think in terms if it may be worth it to have a 'highly optimised' marlin for stm32 instead, stm32 has lots of h/w timers, if we let the timers (generate the square wave train) run the motors, the isr may be able to do 'fire and forget' but the design may be drastically different.
e.g. set the timer set the counts 1 timer for each motor and go, we'd only need to monitor if the timer is done with the counts ;)
the main thing that'd be hard to do with timers is if we want to precisely control acceleration, constant speed moves, deceleration. Doing that with timers would seem pretty difficult as the period varies during acceleration and deceleration

xebbmw
Posts: 15
Joined: Tue Aug 02, 2016 3:34 am

Re: Anyone tried to make a 3D Printer controller?

Post by xebbmw » Mon Sep 25, 2017 4:34 pm

victor_pv wrote:
Sun Sep 24, 2017 11:45 pm
The steps are normally in the range of 10s of Khz in the AVR, depending on what speed you are moving and how many microsteps per full step, but in the AVRs, people is hitting the limit, at which point the moves become jerky when the CPU can't keep up with the required number of steps. But that's at 8 or 16Mhz. So even though at the moment I don't think just moving motors would hog the CPU, when you add to that reading from an SDCard, or reading/writting to USB, plus a diplay, plus bed leveling calculations (those are cpu intensive), then CPU usage goes higher an higher.
At the moment Marlin has trouble keeping up with certain speeds when bed levelling is enabled. I am sure as the 32bit platforms become the norm, more features, more precission, etc will be added, until again reaches a point where the CPU alone can't keep up.
So that's why I'm planning ahead and making sure hw peripherals and DMA can be used in the future.
In case you are worried about performance later, would not be a good solution to use RTOS and efficiently switch between tasks/threads?
The following example http://jhnet.co.uk/projects/makebed describes an implementation of RTOS however for LPC1768 micro controller.

The latest version of Smoothieware 2 runs also on RTOS and it seems that DuetWifi does it also.

I have built a delta printer and now I am looking to replace the controller board to a more more powerful one (as a project, not really buying an existing solution). I also thought that an STM32F407VET board would be the best candidate for a new firmware. I have a STM32DiscoveryF4 based on STM32F407 board, this might serve for testing purpose.

Building a firmware for STM32 micro controllers based on a shield where existing board (like STM32F407VET board) and Polulu stepper drivers can be used, would be a very nice solution.

victor_pv
Posts: 1745
Joined: Mon Apr 27, 2015 12:12 pm

Re: Anyone tried to make a 3D Printer controller?

Post by victor_pv » Tue Sep 26, 2017 3:16 pm

Using an RTOS would help with scheduling threads, but not in making the CPU do more tasks at the same time once cycles are not spent waiting.
On the AVR implementation the CPU can not keep up with the pace if the stepper speed is too fast and there are things like bed leveling enabled. By the way in Marlin the stepper code does not wait for anything, instead uses a timer to generate interrupts as often as needed.
There is just not enough cycles to do it all at some speeds.

If the STM32 MCUs, hitting that limit may take a while, but at that point being able to use DMA would offload the GPIO access to the DMA controller, so the CPU would be totally free do something else while the DMA controller takes care of the steppers for a number of steps (could be hundreds or thousands depending on the size of the dma buffer).
Using DMA and an RTOS are not exclusive of each other, you can use DMA to offload peripheral access, and still use an RTOS to manage task scheduling and what's done in the CPU, while the DMA is on its own doing its job.

About a printer board for the Nucleo, I don't know if anyone has designed one already, but could possibly be a good idea for development. I am designing my own board in a way that the CPU is in a daughter board. I may have a look about using a nucleo as the daughter board.

User avatar
RogerClark
Posts: 7474
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Anyone tried to make a 3D Printer controller?

Post by RogerClark » Tue Sep 26, 2017 9:14 pm

This may sound a very negative comment, but arent there a strange clause in the usage license on the Nucleo boards that say they can only be used for "evaluation", i.e not for a real use, like controlling a 3D printer.

I may PM Frederic about this, as its technically a real limitation on the Nucelo boards.

But I agree, when going to the effort of designing a daughter board, you need to do so for a CPU platform which will not suddenly go out of production, or get modified by the manufacturer in ways that would effect the daughter board.


I would suggest the Seeed Arch Max (F4) board as a host, but Seeed could stop production of it at any time.

ag123
Posts: 798
Joined: Thu Jul 21, 2016 4:24 pm

Re: Anyone tried to make a 3D Printer controller?

Post by ag123 » Wed Sep 27, 2017 1:09 pm

my guess is if u're using it yourself it probably wouldn't matter too much if after all you are running a 3d printer with a nucleo or discovery board ;)
but that may be a catch for those selling the board as a 3d printing solution
doubt any vendor would give a promise of 'perpetual' production. Hence, i'd guess if the boards are after all affordable, one could buy a couple as spares

recently among them are one of the favourite here the stm32f407vet black are looking rather attractively priced on ebay
https://www.ebay.com/sch/i.html?_nkw=stm32f407&_sacat=0

actually i'm half way hoping stm would sell their L6470 stepper motor controllers for less, so that perhaps there'd be 'cheaper' L6470 breakout boards
https://www.ebay.com/sch/i.html?_sacat= ... 70&_sop=15
as the L6470 runs on SPI
http://www.st.com/content/st_com/en/pro ... l6470.html
it would just take a mere 8 pins to run 5 motors
then we can probably run a 3d printer with 3 motors (X, Y, Z) and 2 extruders (i.e. 2 colors filaments simultaneously) on just a blue pill or maple mini
:lol:
Last edited by ag123 on Wed Sep 27, 2017 1:26 pm, edited 1 time in total.

xebbmw
Posts: 15
Joined: Tue Aug 02, 2016 3:34 am

Re: Anyone tried to make a 3D Printer controller?

Post by xebbmw » Wed Sep 27, 2017 1:24 pm

ag123 wrote:
Wed Sep 27, 2017 1:09 pm
recently among them are one of the favourite here the stm32f407vet black are looking rather attractively priced on ebay :lol:
https://www.ebay.com/sch/i.html?_nkw=stm32f407&_sacat=0
I agree with you on black stm32f407vet. It is cheaper than Nucleo board and a perfect match as daughter board in 3D printer controller board. A shield like the ones for Arduino Due is all that is needed.
Last edited by xebbmw on Wed Sep 27, 2017 1:54 pm, edited 2 times in total.

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Anyone tried to make a 3D Printer controller?

Post by fpiSTM » Wed Sep 27, 2017 1:28 pm

Roger asked me some information about the use of ST Nucleo board, I've asked internally and this is the answer:
The license for ST boards does not authorize their use in end-products to ensure ST does not get exposed to any liability.
ST boards can be used in home projects, considered as prototypes.
ST tolerates that people use ST boards in end-products, however ST recommends that users clone ST boards if they want to include them in their end-products.

ag123
Posts: 798
Joined: Thu Jul 21, 2016 4:24 pm

Re: Anyone tried to make a 3D Printer controller?

Post by ag123 » Wed Sep 27, 2017 1:37 pm

xebbmw wrote:
Wed Sep 27, 2017 1:24 pm
ag123 wrote:
Wed Sep 27, 2017 1:09 pm
recently among them are one of the favourite here the stm32f407vet black are looking rather attractively priced on ebay :lol:
https://www.ebay.com/sch/i.html?_nkw=stm32f407&_sacat=0
I agree with you on black stm32f407vet. It is cheaper than Nucleo board and a perfect match as daughter board in 3D printer controller board. A shield like the ones for Arduino Due is all that is needed.
well actually i bought this RAMPS
http://www.ebay.com/itm/3D-Printer-Cont ... 0699832639
http://www.ebay.com/itm/RAMPS-1-4-Contr ... 1691531028
and even this RAMPS-FD
http://www.ebay.com/itm/RAMPS-FD-32bit- ... 2017526524
http://www.ebay.com/itm/GE-Pololu-Shiel ... 2312531140

the idea is that you could basically connect them with dupont wires
https://www.ebay.com/sch/i.html?_nkw=du ... e&_sacat=0
hence a shield isn't really necessary

RAMPS FD being designed for Arduino Due which is basically a 3.3v arm based board would likely be easier interfacing with stm32 boards
but RAMPS FD is quite a bit pricier than RAMPS

using the generic RAMPS or RAMPS FD boards frees one up to mix and match the boards, one could basically get any of the various f4 vet, zet (or f1) boards out there on ebay, aliexpress, olimex and even ST nucleo, discovery boards, then map the pins between those boards to RAMPS, RAMPS-FD using the dupont cables

and to save time, one of the easier way is to buy one of the lower costs 3d printer kits some of which goes for about usd 200 (or less) and you could replace the controller

xebbmw
Posts: 15
Joined: Tue Aug 02, 2016 3:34 am

Re: Anyone tried to make a 3D Printer controller?

Post by xebbmw » Wed Sep 27, 2017 1:55 pm

ag123 wrote:
Wed Sep 27, 2017 1:09 pm
actually i'm half way hoping stm would sell their L6470 stepper motor controllers for less, so that perhaps there'd be 'cheaper' L6470 breakout boards
https://www.ebay.com/sch/i.html?_sacat= ... 70&_sop=15
as the L6470 runs on SPI
http://www.st.com/content/st_com/en/pro ... l6470.html
it would just take a mere 8 pins to run 5 motors
then we can probably run a 3d printer with 3 motors (X, Y, Z) and 2 extruders (i.e. 2 colors filaments simultaneously) on just a blue pill or maple mini
:lol:
Why not on TMC2130 stepper driver that runs also on SPI? There is already a fork of Marlin that was adapted for TMC2130 https://github.com/teemuatlut/Marlin. I guess would not be needed to have a STM32F4 running the board, but only an STM32F1 aka bluepill. The board would need less pins than it was explained in the post below:
victor_pv wrote:
Sun Sep 10, 2017 4:32 am
There is already 2 Marlin HALs for STM32, one that I am working on, based on libmaple, and nother one from Chriss Bar based on the GENERIC core.
Mine, depending what options you pick, fits in about 90KB of flash, so can run on a CB (or a C8 with 128KB). The biggest issue with those MCUs is that they don't have enough pins for everything, so you have to pick what you leave out.
So I'm testing mine in an RCT6 board, with 256KB of flash and 48 of RAM, and so far fake printing works fine (no steppers connected). I have tested the same print takes the same time on my HAL on a STM32F1, as in the LPC1768 HAL that runs in the Re-arm or smothieware boards, so the stepper code is running at the right pace. I still ned to plug it to a printer and run an actual test, but I am still working on other parts of the HAL.

Normally you need at least this many pins:
Min 4 steppers, 3 pins each (DIR, STEP, EN): 12 pins
Min 2 thermistors: 2 pins
Min 2 PWM outputs for heated bed and extruder
End stops: 3 pins
USB 2 pins
If you use sdcard 4 pins
If you use an LCD, 4-6 pins, depending which.
If you use a rotary encoder for navigatins menus, 3 pins.
Beeper 1 pin

ag123
Posts: 798
Joined: Thu Jul 21, 2016 4:24 pm

Re: Anyone tried to make a 3D Printer controller?

Post by ag123 » Wed Sep 27, 2017 1:57 pm

xebbmw wrote:
Wed Sep 27, 2017 1:55 pm
Why not on TMC2130 stepper driver that runs also on SPI? There is already a fork of Marlin that was adapted for TMC2130 https://github.com/teemuatlut/Marlin. I guess would not be needed to have a STM32F4 running the board, but only an STM32F1 aka bluepill. The board would need less pins than it was explained in the post below:
Thanks , didn't realise TMC2130 is SPI too
https://www.ebay.com/sch/i.html?_sacat= ... 30&_sop=15
it is also rather interesting that TMC2130 and ST's L6470 breakouts are priced around the same range on ebay both SPI motor controllers
https://www.ebay.com/sch/i.html?_nkw=L6470+&_sacat=0

the other thing would be that TMC2130 seemed to be designed towards a 5v system
https://www.trinamic.com/fileadmin/asse ... asheet.pdf
while L6470 it seemed would be easier to interface with 3.3v logic as it seemed to have been designed for it
http://www.st.com/en/motor-drivers/l6470.html

oh and someone has actually tried it
https://github.com/hendorog/Marlin_L6470

and found a big list of motor drivers here
http://reprap.org/wiki/Stepper_motor_driver
:)

Post Reply