Skip to content
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

Remove MarlinSerial #2945

Closed

Conversation

AnHardt
Copy link
Contributor

@AnHardt AnHardt commented Jan 29, 2016

Replace it by original Arduino HardwareSerial

The maximum working BAUDRATE is 115200 then. 250000 skips incoming chars occasionally. The stepper interrupt takes too long and the 'hack' is removed, because the Arduino HardwareSerial does not have the needed function.

To set the SERIAL_RX_BUFFER_SIZE and SERIAL_TX_BUFFER_SIZE you need a platform.local.txt or a similar system to set compiler options.

compiler.c.extra_flags='-D SERIAL_RX_BUFFER_SIZE=128 -D SERIAL_TX_BUFFER_SIZE=32'
compiler.cpp.extra_flags='-D SERIAL_RX_BUFFER_SIZE=128 -D SERIAL_TX_BUFFER_SIZE=32'

Placing the defines 'inside' the sketch does not work because of Marlin.ino.cpp includes the HardwareSerial. An alternative would be to change all possibly involved HardwareSerial.h files - what's not what we want.

Compiled with the config. in the main-directory.
MarlinSerial (before):
Der Sketch verwendet 50.270 Bytes (19%) des Programmspeicherplatzes. Das Maximum sind 253.952 Bytes.
Globale Variablen verwenden 2.846 Bytes (34%) des dynamischen Speichers, 5.346 Bytes für lokale Variablen verbleiben. Das Maximum sind 8.192 Bytes.

HardwareSerial (after):
Der Sketch verwendet 51.794 Bytes (20%) des Programmspeicherplatzes. Das Maximum sind 253.952 Bytes.
Globale Variablen verwenden 2.968 Bytes (36%) des dynamischen Speichers, 5.224 Bytes für lokale Variablen verbleiben. Das Maximum sind 8.192 Bytes.

This change uses 1524byte Progmem and 122byte RAM more than the version with MarlinSerial.

Tested with unmodified ARDUINO 1.6.7 core files. In older versions the definition of the buffers may not work. (needs arduino/Arduino@d259512)
Tested only with Arduino Mega 2560.
Needs more testing.

@AnHardt
Copy link
Contributor Author

AnHardt commented Jan 29, 2016

This is more a HowTo than a must be done. @Wackerbarth askend for it.

@Wackerbarth
Copy link
Contributor

"@Wackerbarth askend for it." -- @AnHardt -- Please reword this. As written, I don't understand what you mean.

@AnHardt
Copy link
Contributor Author

AnHardt commented Jan 29, 2016

Maybe i misinterpreted #2839 (comment)

@Roxy-3D
Copy link
Member

Roxy-3D commented Feb 12, 2016

"@Wackerbarth asked for it." -- @AnHardt -- Please reword this. As written, I don't understand what you mean.

Specifically :
#2839 (comment)

I would love to see a simpler solution which still allows the very rapid stepper motion.
Perhaps you can make some suggestions.

@Wackerbarth
Copy link
Contributor

@AnHardt -- I don't think that your "solution" addresses my concern.

The difficulty is that the stepper ISR runs far too long when in the mode that performs very rapid movements by performing multiple steps in response to a single timer interrupt.

To accomplish this, the ISR must test to see if there is a character available in the UART and, if there is, transfer it to the received character queue. The code to perform that test is not compatible with the Arduino hardware serial code from the IDE 1.5 era.

There have been some subsequent changes to that Arduino code which may make it possible to rewrite the process to use the current Arduino core. However, I haven't had the opportunity to dig into it sufficiently to see if we can do so with both the MEGA2560 and the AT90USB1286 cores.

(PS: I also note that the displayed patch includes a number of changes that appear to be related to a different issue)

Replace it by original Arduino HardwareSerial

The maximum working BAUDRATE is 115200 then. 250000 skips incoming chars occasionally. The stepper interrupt takes to long and the 'hack' is removed, because the Arduino HardwareSerial does not have the needed function.

To set the SERIAL_RX_BUFFER_SIZE and SERIAL_TX_BUFFER_SIZE you need a platform.local.txt or a similar system to set compiler options.

```
compiler.c.extra_flags='-D SERIAL_RX_BUFFER_SIZE=128 -D SERIAL_TX_BUFFER_SIZE=32'
compiler.cpp.extra_flags='-D SERIAL_RX_BUFFER_SIZE=128 -D SERIAL_TX_BUFFER_SIZE=32'
```
Placing the defines 'inside' the sketch does not work because of Marlin.ino.cpp includes the HardwareSerial. An alternative would be to change all possibly involved HardwareSerial.h files - what's not what we want.

Compiled with the cinfig. in the main-directory.
MarlinSerial (before):
Der Sketch verwendet 50.270 Bytes (19%) des Programmspeicherplatzes. Das Maximum sind 253.952 Bytes.
Globale Variablen verwenden 2.846 Bytes (34%) des dynamischen Speichers, 5.346 Bytes für lokale Variablen verbleiben. Das Maximum sind 8.192 Bytes.

HardwareSerial (after):
Der Sketch verwendet 51.794 Bytes (20%) des Programmspeicherplatzes. Das Maximum sind 253.952 Bytes.
Globale Variablen verwenden 2.968 Bytes (36%) des dynamischen Speichers, 5.224 Bytes für lokale Variablen verbleiben. Das Maximum sind 8.192 Bytes.

This change uses 1524byte Progmem and 122byte RAM more than the version with MarlinSerial.


Tested with unmodified ARDUINO 1.6.7 core files. In older versions the definition of the buffers may not work. (needs arduino/Arduino@d259512)
Tested only with Arduino Mega 2560.
Needs more testing.
@AnHardt AnHardt force-pushed the Remove-Marlin-Serial branch from 45bb160 to a6d826b Compare February 13, 2016 15:15
@thinkyhead
Copy link
Member

Is this PR still wanted? It implies that 250K is no longer supported. But documentation like the Marlin page on RepRap wiki list 250K baud as the standard speed. Should we just update documentation and switch to 115K everywhere? I am happy to merge this if MarlinSerial is not needed. Is it already removed from MarlinDev?

@AnHardt
Copy link
Contributor Author

AnHardt commented Feb 17, 2016

Thanks for asking. I don't think so.
I made my tests with it.
Two fewer files we'd have to care about versus too big and not able to handle 250000bd, is a bad deal.
To implement the hack into the newer Arduino HardwareSerial is not too complicated but when modified the files again should reside in the Marlin directory - not in the core.

@AnHardt AnHardt closed this Feb 17, 2016
@jbrazio jbrazio modified the milestone: 1.1.0 Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants