-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] ADVANCED_OK support, base code implemented already #2819
Comments
Wow I finally stumble upon the right track. I have recently rebuilt my delta and I started to notice these blobs and pauses. Even when I dial the feedrate/speed to 75%. I'll keep an eye here :) |
As I shared here #2761 (comment) -- BAUDRATE 57600 seems to have solved or greatly improved the situation 🤔 |
Certainly too high baudrates can cause issues, I run 3 printers at 500K, but 1 printer doesn't work well if I don't go down to 250K. Note that at 57K, you can only send 5.7K bytes per second, so if the gcode command is 57 bytes long, then you can only send 100 commands per seconds and basically at least have a 10ms delay between each command (the TFT waits for an "ok" after each command before sending the next command). |
@rondlh thanks for that info, I'll recompile with those settings tomorrow and try it with more customer prints as they come in. |
The code changes are minimal, just pickup the ADVANCED_OK feedback (parseACK.c) and do some buffer administration in interfaceCmd.c. Just copy and replace the 3 files in the July 2023 release. The code is a bit different than above because it also handles the case that ADVANCED_OK is not enabled. I recommend to enable ADVANCED_OK, that's your safest bet. Note, there is no Reprap support added, only Marlin. |
@carlosjln Any results? Questions? |
I will also try the code changes out that you suggested, because even after the four buffer changes and lowering the baudrate to 57k I just encounterd the issue a couple of minutes ago while printing. Though I must say my TFT is not running of the newest FW because I dont have a full size SD Card currently. I've been having these freezing issue for a couple of months now and been following on whats happening here on github, since the freezes occured the fun for 3D printing has been drasticly lowered because I'm kinda scared to print longer than 3h because of a sudden halt. Few things I noticed aswell, after the buffer and baudrate changes, when I save to eeprom during printing the printers halts for a second or so and sometimes not only does the printer freeze, when it does, the extruder starts spinning fast too and unloads the filament. I'll let you know after I've done the changes and tested it properly. |
@Nerdcaught Sorry, there was a missing opening bracket in interfaceCMD.c |
Between you and me I wont officially know the true difference but if I have any hiccups Ill let you know. It compiled with your new updated files. Thank you! |
Great, make sure to enlarge RX_BUFFER_SIZE in Configuration_adv.h, I recommend 512 or 1024. |
I can provide this solution on a PR. That feature will be configurable at runtime (Advanced OK feature ON or OFF). For backward compatibility (also with mainboard fw different than Marlin), in case Advanced OK feature is disabled in TFT then the current logic (one gcode at a time) will be used. |
I've been using the pre-compiled version I was shared some weeks ago and so far had two freezes, one at normal speeds on a big print, but I was able to restart the printer and resume it. The other one I increased the speed to 150% just to mess around as the print was not coming well and I was going to stop it anyways. I think I'll try the 512 or 1024 buffer config later. |
it is better you don't close a FR o BR once a PR is available. PR marked this FR as resolved (you can see that from the number linked in |
I thought it was merged already... but it is not.. |
@carlosjln I'm not sure what pre-compiled version you are talking about. I did not provide one, and as far as I know there is none for ADVANCED_OK, but there is one for the hesitations issues. The hesitations issue should be solved in the current release (2023-08-24). |
Sorry I mixed up issues because I'm tracking this other conversation #2761 And I was referring to these pre-compiled versions https://github.com/kisslorand/BTT-TFT-FW |
OK, that is what I guessed, unfortunately I don't know what is changed in this FW, but it seems to solve the hesitation issue too. I recommend to just go for the latest FW or even add the ADVANCED_OK update. |
Yes, that's what I did. Last night I installed the current release you mentioned (I didn't realize the repo update) and did a couple of prints and didn't see anything out of order. I will try a dry run print of a vase at faster speeds later on. |
yes I also saw that. Furthermore, printing from onboard (Marlin) I see 0 tx_slots and not possible to stop/control the print. EDIT: just fixed a check I changed in the past. Please check if it works now |
The problem is in interfaceCmd.c, infoHost.tx_count != 0, so if only 1 command is send it's TRUE already. The condition should be something like:
|
just edited my previous post with the same issue (I remembered that I changed that condition in the past). |
Condition I personally monitor this from Marlin side, not from TFT side. But adding some debug code could be useful. BTW:
|
last cleanup in main.c. PR ready for merge. |
If so, it seems not to be working for me, ADVANCED_OK enabled in Marlin(BUFSIZE=8) and TFT(Reset default settings, but ADVANCED_OK enabled). I can see that only 1 command is queued anyway, I would expect 8.
|
no, I changed the logic to be easy to understand:
Even if ADVANCED_OK is enabled in Marlin, for some gcodes the OK ACK returned by mainboard will not provide an indication of new available tx slots (e.g. answer for M105
The master config.ini must be provided only in "\TFT\src\User" since some time now. They will be copied in "\Copy to SD Card root directory to update" when merged by BTT. |
So does this mean that ADVANCED_OK is not correctly detected? It's enabled in Marlin and the TFT, but still not used by the TFT. |
Marlin ADVANCED_OK (its buffer size (e.g. 15 in my case)) is properly detected by TFT if ADAVNCED_OK is enabled in Marlin. If not detected then static ADVANCED_OK is used. |
About 1. Fixed now, good job.
In that case be aware that the config.ini in "\TFT\src\User" is incorrect, the one in "\Copy to |
oh yes right, thanks for the review. Fixed 2 and 4 (as I said master folder for |
About 2. 50% complete now (#define TX_SLOTS 2 // Default: 1) I noticed another issue. When I start a print and immediately cancel it via the TFT, then the motherboard is flooded with M108 commands, sometimes causing a buffer overruns (my buffer is even at 1024 bytes). I'm not sure what is causing this, perhaps the initialization of the BLTouch (quite slow) or the ongoing homing process is causing a delay giving time to send too many M108 commands. I guess it's better to limit the max number of M108 commands that can be send. In printing.c
|
yes I know that. I previously put a delay of 10 ms on that loop just to avoid that errors. I will see how to improve it |
A delay would probably do the trick just fine, or something like this:
The amount of commands that need to be cancelled is quite limited. |
While your are changing interfaceCmd.c, perhaps you could correct the error below ("for" and "wait" should be swapped in the last line)
|
ok, swapped. Fixed also the possible issue on print abort |
@digant73 YOU ARE UNSTOPPABLE! Great job. |
It is caused by the "improvements" done to the serial port read. I warned about it being buggy several times already, but I saw the new "enhancements" made it even more chaotic. Just check earlier builds (before PR #2788) or my builds where
It is the very unprofessional to mitigate the outcome of a bug instead of fixing its core root. It should be absolutely the last resort. I saw in a current open PR that it does exactly that, a patch was made to somehow overcome the issue not the cause of it. |
@kisslorand More code, less words please. If you want to help, then be concrete, your vague statements are useless to me, and so is closed source software. |
Transmission of M108 was previously based on polling |
Thanks, that's helpful, this is one of the areas in the code that I don't fully understand, it must be boring to have to explain things to newbies sometimes, thanks for that. It seems to work fine in my experience. |
no problem. The proposed logic works even better than the old one and overall (considering the logic for |
@digant73 Could you tell me what My advanced OK response looks like this: I added Target TX Slots to the monitoring screen, which reports a value of 5, my Marlin command buffer size is set to 8. |
my mistake! I forgot to push the correct |
OK, got it. I changed "M105" to "M107", now I get the correct value of 7. Thanks. I see instability in the Marlin RX data... (Seems to be something in my changes...) |
@digant73 I found a little issue in #2824...
I think the "#else" case should be: Otherwise you still get a 2nd useless "back icon" in the notification menu, while Advanced_OK seems to work fine, Marlin RX buffer use is very moderate, but when I add the DMA writing code, the buffer usage can become unstable, very odd, because your Advanced_ok implementation is smarter than mine and should not be affected by the serial send speed. I will look into it... |
yes of course. Wrong cut & paste. I will push the minor fix
Good it works now. Yes I think DMA writing should be investigated separately |
Yes, of course. I guess you are aware of this... but anyway. Some more ideas for the monitoring feature.... commands per second, kbytes sent, kbytes received, polling rate (Serial_Get). |
Yes I know the reported available buffer is 1 less than the configured value in Marlin. That's ok for me (safety value). |
@V1EngineeringInc/Everyone This would be a good time to test ADVANCED_OK #2824. I tested it fully, and it is working very well. |
#2824 now contains a performance benchmark that you can enable in Configuration.h (DEBUG_MONITORING). When enabled, you will find an info button in the in the notification screen. The button brings you to the monitoring screen. There you can monitor some system parameters, like the scan rate which shows how many times the core process (loopProcess) is executed every second. This way the impact of changes can be tested easily. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Marlin supports ADVANCED_OK, which returns info about the available buffers when acknowledging a command with "ok".
This is currently not used by the TFT, which sends 1 command and waits for the "ok" response before sending the next command.
I suspect that this is the reason for some random pauses and hesitations when printing #2761
Marlin support BUFFER_MONITORING, which can give you information about the buffer underruns, a buffer underrun occurs when Marlin is ready to process the next command, but no command is available yet. I found thousands of buffer underruns per hour. These underruns are likely to be of very short duration, but clearly that is not what you want. Some buffer underruns are normal and unavoidable because the TFT is holding back data during the heating phases, this accounts for about 100 underruns in my case.
I made a rudimentary support of ADVANCED_OK which works as follows:
In parseACK.c the "ok" acknowledgement is processed. I added a check for the "B" parameter. The parameter value is stored in the HOST struct (defined in main.h).
AvailableBuffers is initialized to 4 (Marlin's default) when the printer connection is established. (parseACK.c)
Now there are no more additional buffer underruns during the printing process and at least basic operations seem to work as before. (Move menu works, terminal works, adjusting values during printing works).
I think the current TouchScreen FW can even be improved significantly without using ADVANCED_OK by just assuming that at least 4 command buffers are available (can be made configurable), and keep track of the response count ("ok"). So you can send 4 commands, but then need to wait for an "ok". If an "ok" comes then another command can be send. This should solve the pauses and hesitations.
Update: I did some tests to see if this can work without having ADVANCED_OK enabled. It's possible, but a bit complicated by the fact the command and response count could be undefined at startup. Some commands could be send that are never acknowledged by Marlin.
UPDATE: Source Code files attached (based on the (currently latest) June 2023 release), just overwrite the 3 attached files. It will work both with ADVANCED_OK enabled and disabled in Marlin. If it's disabled then the default amount of 4 buffers is assumed. Make sure to increase RX_BUFFER_SIZE (Configuration_Adv.h) to at least 256 bytes, but 512 is recommended.
Updated Download: #2824
The text was updated successfully, but these errors were encountered: