{"action":"closed","issue":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2370","labels_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2370/labels{/name}","comments_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2370/comments","events_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2370/events","html_url":"https://github.com/MarlinFirmware/Marlin/issues/2370","id":92911078,"number":2370,"title":"Two observed stepper signal discrepancies during diagonal moves","user":{"login":"maicrodrop","id":13168739,"avatar_url":"https://avatars.githubusercontent.com/u/13168739?v=3","gravatar_id":"","url":"https://api.github.com/users/maicrodrop","html_url":"https://github.com/maicrodrop","followers_url":"https://api.github.com/users/maicrodrop/followers","following_url":"https://api.github.com/users/maicrodrop/following{/other_user}","gists_url":"https://api.github.com/users/maicrodrop/gists{/gist_id}","starred_url":"https://api.github.com/users/maicrodrop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maicrodrop/subscriptions","organizations_url":"https://api.github.com/users/maicrodrop/orgs","repos_url":"https://api.github.com/users/maicrodrop/repos","events_url":"https://api.github.com/users/maicrodrop/events{/privacy}","received_events_url":"https://api.github.com/users/maicrodrop/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/Developers","name":"Developers","color":"FF77AA"},{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/Potential%20bug?","name":"Potential bug?","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-07-03T17:12:07Z","updated_at":"2015-08-03T16:38:55Z","closed_at":"2015-08-03T16:38:55Z","body":"During all of the below testing, unless otherwise noted, the movements that showed an issue were from X0 Y0 to X220 Y245, or back to X0 Y0, at F90000 (faster than the machine or firmware can go, but it produced this issue reliably; I've seen this occur at lower speeds, but less frequently).  These tests were performed on a MakerGear M2 using a stock RAMBo (basically an Arduino Mega 2560 - 16MHz clock, etc.), and a copy of the main Release branch of Marlin downloaded the morning of 7/2/2015 (most recent change at that point 5 days prior; \"commit b1dc722c83864ad4ed61b1d4b79c51a7fb57c01e\").\r\n\r\nThe following changes were made to Marlin before testing:\r\nconfiguration.h:\r\n-Baud rate set to 115200\r\n-Motherboard set to BOARD_RAMBO\r\n-T0 and T1 thermistors changed to table 0\r\n-Added custom PID values, commented out defaults\r\n-Changed Z home direction to 1 (MAX)\r\n-Disabled software endstops\r\n-Changed XYZ MAX_POS values to match machine\r\n-Steps/mm values changed to {88.88,88.88,400,471.5}\r\n-Changed Z Home and max feedrates to 20mm/s and 25mm/s respectively\r\n\r\nGiven these settings, and the default max step frequency of 40,000, the actual max XY motor feedrate is ~450mm/s; the default Marlin value of 500mm/s was left for this testing.\r\n\r\nTest setup: DS1074Z-S oscilloscope probing the X- and Y-STEP test points between the Atmega2560 chip and the A4982 stepper driver chips, with and without motors physically connected to the drivers.  Manual and macro gcode being sent from Pronterface.\r\n\r\nObserved behavior:\r\nIssue 1:  During a diagonal move (primarily from (0,0) to (220,245) for testing) a glitch occurs in the middle of the move, causing the machine to shudder violently, frequently resulting in a layer shift.  This glitch is the result of a period of time where the firmware/Atmega2560 does not send STEP signals to the stepper motor driver; as the axes are in motion at the time, this is the equivalent of trying to immediately go from 200+mm/s to 0mm/s, which the masses of the axes and the strength of the steppers cannot support.\r\n\r\nThe non-signal time is between 32.7 and 32.8ms long (I suspect 32.768ms [16MHz timer with 8 prescaler, 16bit timer overflow period], but cannot measure a gap that large, accurately enough, easily)[1].  Sometimes this glitch occurs multiple times in a row, separated by some number of short periods of correct-signal-sending[2,3].  There seems to be a slight increase of glitch occurrence during the transition from 2 steps/interrupt to 4 steps/interrupt (or 4>2)[11,12], but it also occurs in the middle of a solid block of 4 steps/interrupt signals[3].\r\n\r\nIssue 2:  While I've investigated this one less, during my testing/investigation of Issue 1 above, I found that there is occasionally a set of max speed commands sent at the end of a single move, after the expected deceleration; generally this is a set of 7 blocks of 4 steps/interrupt, with a 1 step/interrupt block before and after the set of 7[8,9,10].\r\n\r\nInvestigation for Issue 1:  Have tested many different things, including:\r\n-Arduino version: tested 0023, 1.0.5, 1.6.3, and my primary version of 1.5.5, with no apparent difference.\r\n-Disabled all other functions from the main Marlin loop, one by one and all at the same time (so no manage_heater, manage_inactivity, checkHitEndstops or lcd_update), with no apparent difference.\r\n-Tested changing the MAX_STEP_FREQUENCY from 40000 to 35000; rate of glitch occurrence did definitely drop, though the glitch did still occur (went from ~1 glitch in 3 moves, to ~1 in 20).\r\n-Glitch also observed when XY feedrate limited in compiled firmware to 300mm/s, though rate of occurrence did decrease.\r\n-Compared X- and Y-STEP signals against CLKO output, which show timing changes between when steps are being sent, and step idle time; during the glitch period, the CLKO signal continues, while X- and Y-STEP signals do not.  I believe that this shows that the timer responsible for step timing/signaling is still active, though my AVR/Arduino/Marlin knowledge is not deep enough to confirm that.[4,5,6,7]\r\n-Briefly tested Repetier-Firmware and saw similar behavior.\r\n-Briefly tested our \"stock\" Marlin firmware from 2012, and saw similar behavior.\r\n\r\nThe included pictures are screenshots from the 'scope, showing various tests and measurements of these issues.  In all pictures, the yellow trace is CH1/X-STEP, the blue trace is CH2/Y-STEP, and the purple trace (if present) is CH3, CLKO; all three are offset vertically for clarity.\r\n1: A shot showing the gap timing of ~32.7ms (measured with cursors placed by hand/eye).\r\n2: A shot showing the general, correct movement profile with full move timing of ~422ms.\r\n3: A shot showing the same move with two gaps, separated by some steps; total move timing of ~488ms.\r\n4: A shot showing the continuation of the CLKO output during the gap in X- and Y-STEP signals, at the beginning of the gap.\r\n5: Another view of 4.\r\n6: The same as 4, but viewing the end of the gap (X- and Y-STEP signals starting again).\r\n7: A zoom of normal movement showing the timing changes of CLKO during idle, X-STEP, [between X- and Y-STEP], Y-STEP, and back to idle.\r\n8: A shot showing the timing increase as the axes decelerate at the end of a move.\r\n9: A zoom of the end of 8, showing the block of high-speed moves at the end of the deceleration ramp (axes should be on their way to 0mm/s speed/full stop at this point).\r\n10: A further zoom of 9, showing 7, 4 step/interrupt blocks with 1 step/interrupt blocks before and after, and then X- and Y-STEP signals stopping completely.\r\n11: A shot showing a gap, zoomed in on the left side, showing the 4 step/interrupt blocks.\r\n12: A shot showing the right side of the gap in 11, showing the 2 step/interrupt blocks.\r\n\r\nIf there are any other tests you guys would like me to run, or if you have any questions about my testing/setup, please let me know - I've been digging through Marlin to try to figure out what could be happening here, but haven't had any luck, so finally decided to come to you all with this information.\r\n\r\n1:\r\n![1](https://cloud.githubusercontent.com/assets/13168739/8502895/7a16a042-2184-11e5-8009-33e9354d152c.png)\r\n2:\r\n![2](https://cloud.githubusercontent.com/assets/13168739/8502897/80061c4e-2184-11e5-94e0-5dee2ece6270.png)\r\n3:\r\n![3](https://cloud.githubusercontent.com/assets/13168739/8502901/806a7554-2184-11e5-9735-f250959560bd.png)\r\n4:\r\n![4](https://cloud.githubusercontent.com/assets/13168739/8502902/806dd74e-2184-11e5-8c55-dba2e9a565df.png)\r\n5:\r\n![5](https://cloud.githubusercontent.com/assets/13168739/8502903/806ff588-2184-11e5-8268-40eb46562921.png)\r\n6:\r\n![6](https://cloud.githubusercontent.com/assets/13168739/8502898/8044bb52-2184-11e5-92b4-dfdaf0aa0f97.png)\r\n7:\r\n![7](https://cloud.githubusercontent.com/assets/13168739/8502900/806a0434-2184-11e5-93ed-d3709c3013f3.png)\r\n8:\r\n![8](https://cloud.githubusercontent.com/assets/13168739/8502899/8063f710-2184-11e5-99ea-a14702687814.png)\r\n9:\r\n![9](https://cloud.githubusercontent.com/assets/13168739/8502904/8075d23c-2184-11e5-8fb0-02706f20f695.png)\r\n10:\r\n![10](https://cloud.githubusercontent.com/assets/13168739/8502905/808f38da-2184-11e5-9350-82d6900a7a49.png)\r\n11:\r\n![11](https://cloud.githubusercontent.com/assets/13168739/8502906/80945e96-2184-11e5-8f9d-509174f75187.png)\r\n12:\r\n![12](https://cloud.githubusercontent.com/assets/13168739/8502907/80aa9c7e-2184-11e5-9a3e-bc2020411661.png)\r\n\r\n"}}