Welcome! Log In Create A New Profile

Advanced

Marlin multithread?

Posted by chik 
Marlin multithread?
October 31, 2013 05:44AM
Hi all,

I want to know if arduino is multithreading or not, because when I read Gcode from SD Card, it reads the 16 commands of BLOCK BUFFER SIZE "Buffer of plan motion", and begins their excutions in parallel!! It stops reading when it get the 16 command "Buffer full", after that, it will read command per command. For exemple, it will read a command number 35, then excute the command number 19 !!, if I send "M25 => stop SD Card", the printer stops after excuting 16 commands "The buffer of plan motion will be empty".

I don't realy understand how it separates the reading of SD Card, and the execution of the buffer of motors!! I can't found when it empties the buffer of plan motion!!
Re: Marlin multithread?
October 31, 2013 06:31AM
your best bet is to come into the irc room #reprap and talk to Evdz




-=( blog )=- -=( thingiverse )=- -=( 3Dindustries )=- -=( Aluhotend - mostly metal hotend)=--=( Facebook )=-



Re: Marlin multithread?
October 31, 2013 08:23AM
Safe to say - the Arduino is *not* mulit thread. There isn't even an OS in there to *do* multi thread, let alone the CPU horsepower.

As to what Marlin does or does not do - that's a different question.
Re: Marlin multithread?
October 31, 2013 08:23AM
Some g code, such as the G1 moves, are, and have to be, executed in sequence. Not in parallel. The buffer is so that the movement planner never runs out of work to do.

If you manually enter a command that is of the buffered variety, it will just be placed into the buffer behind whatever happens to be there. If you manually enter an immediate command, it will be executed immediately ahead of what's in the buffer. The g code reference here at this wiki attempts to identify buffered commands versus non-buffered.
Re: Marlin multithread?
October 31, 2013 11:50AM
Thank all of you for your responses,

But I want to understand, when Marlin wait the new space of buffer!!
Re: Marlin multithread?
October 31, 2013 12:54PM
chik Wrote:
-------------------------------------------------------
> Thank all of you for your responses,
>
> But I want to understand, when Marlin wait the new
> space of buffer!!

Do you want to know:

1) When the Marlin will stop and not do anything at all because there is not enough data in the buffer?
2) How the code allocates the buffer in the first place and how long it waits for it to be allocated?
3) How much data it reads from the SD card into the buffer with each read and how long this takes?
4) Why Marlin stops reading data from your SD card and then waits for it?
5) How the buffer is filled and used?

What are is your objective? Are you trying to debug a printer problem - if so what problem? Are you trying to understand the structure of the code to re-write it? If so what are you trying to fix or improve?

If you are actually trying to debug an SD card issue - There are a *lot* of SD cards out there and they don't all like SPI mode very much. The read times from SD will be very dependant on how it handles this little used read mode. Your PC reads the SD in a very different fashion and it's speed rating is based on that approach rather than SPI.
Re: Marlin multithread?
October 31, 2013 01:22PM
Thank you uncle_bob for your quick response,

My questions is how does Marlin use BLOCK_BUFFER_SIZE!! I know that there are different buffers on different functions of Marlin!! I see that Marlin has buffered functions, and unbeffered functions : [reprap.org]

For the function (plan_buffer_line), Marlin use a lot of buffers, but I think that the buffer for commanding motors is "block_t block_buffer[BLOCK_BUFFER_SIZE]; "

I want to know how does Marlin use this buffer " block_t block_buffer[BLOCK_BUFFER_SIZE]; " for executing G1; and reading from sd card until this buffer will be full. After that, it will read when there will be a place on that buffer!!
Re: Marlin multithread?
December 03, 2013 11:35AM
Hey did you ever get an answer to this problem my group are having a similar issue?
Re: Marlin multithread?
December 03, 2013 12:25PM
There are multiple duplicate (maybe 5?) threads from the same OP where this exact question was asked. It's answered in one of them. The simple answer is that the gcode is doing the blocking, not the buffers.
Re: Marlin multithread?
April 29, 2014 04:07AM
Hi ZarinaCampbell and uncle_bob,

Sorry for the late reply. I worked on another thing than the Marlin!
Last week, I sew this part, and it seems exactly as I put on another topic!

plan_buffer_line() will be called to place the move into the block buffer.
plan_discard_current_block() remove the command when it is finished!!

All this function are in interruption on stepper.c

Thank you!!

PS : If you have any problems, you can send me a message
Sorry, only registered users may post in this forum.

Click here to login