<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Reprap_new_firmware + 1/16 microstepping = trouble</title>
		<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble</link>
		<description>Posts in the discussion thread &quot;Reprap_new_firmware + 1/16 microstepping = trouble&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Fri, 06 Nov 2026 19:12:46 +0000</lastBuildDate>
		
					<item>
				<guid>http://www.contraptor.org/forum/t-275140#post-1313857</guid>
				<title>Re: Reprap_new_firmware + 1/16 microstepping = trouble</title>
				<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-1313857</link>
				<description></description>
				<pubDate>Fri, 25 Nov 2011 08:00:39 +0000</pubDate>
				<wikidot:authorName>Albanetc</wikidot:authorName>				<wikidot:authorUserId>381022</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I tried your code and can see (or rather hear) a slight improvement over Arthur's fix. I'm running a different revs/inch ratio, but recalculated to your ratios, previously I could hear a stutter in acceleration/deceleration when moving at 400&#160;mm/min (but not at 375&#160;mm/min). Now I can't hear that stutter at 400&#160;mm/min, but can detect it at 425&#160;mm/min and can clearly hear it at 500&#160;mm/min. Not sure if the acceleration rate plays a role here, or if it's the pulse duration improvement (that I don't have) that results in a smooth motion. I'd be interested to try out the pulse duration modification.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.contraptor.org/forum/t-275140#post-1305614</guid>
				<title>Re: Reprap_new_firmware + 1/16 microstepping = trouble</title>
				<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-1305614</link>
				<description></description>
				<pubDate>Mon, 14 Nov 2011 17:07:15 +0000</pubDate>
				<wikidot:authorName>alexmos</wikidot:authorName>				<wikidot:authorUserId>1242039</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Thanks for your investigation! I had the same problem with the high pulse rates, and this topics helps to find it. But your solution works not well in my case. My setup needs 1280 steps/mm, and maximum fedrates I have got with default firmware, was 250mm/min running at 16MHz microprocessor. The problem rises when a step interval becomes lower than 150-200 us in the acceleration phase, because the code to calculate it takes the same time, and TIMER1 skips it's interrupt and runs until it overflow (~32000).</p> <p>You solution reset the timer and prevent overflow run, but as negative result, it doubles the step interval. Motors sounds &quot;noisy&quot; in the acceleration phase (and I suppose they skip steps).</p> <p>I have a better solution. On non-modified firmware, add a line after</p> <div class="code"> <pre><code> if (inTimer1InterruptRoutine) return; inTimer1InterruptRoutine = true; // set very long time to disable timer1 interrupt until we are finished here OCR1A = 0xffff;</code></pre></div> <p>and replace</p> <div class="code"> <pre><code> OCR1A = timer1LoadValue;</code></pre></div> <br /> with <div class="code"> <pre><code> OCR1A = max(timer1LoadValue, TCNT1+10);</code></pre></div> <p>If the calculation time is longer than the wanted step time, next step will follow just after calculations will be finished.</p> <p>Another problem of current firmware is variable (and not-predicted) pulse duration. I have added a code to set precise and configurable pulse duration using second timer. It is to complicated to write differences here, but it is about 10 lines of code total.</p> <p>As a result, I can now get smooth motion with feeds 300 and even 500&#160;mm/min without skipping steps. It is 2 times better than before.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.contraptor.org/forum/t-275140#post-903091</guid>
				<title>Re: Reprap_new_firmware + 1/16 microstepping = trouble</title>
				<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-903091</link>
				<description></description>
				<pubDate>Thu, 21 Oct 2010 03:48:40 +0000</pubDate>
				<wikidot:authorName>Albanetc</wikidot:authorName>				<wikidot:authorUserId>381022</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Wow, good find! Will test this as soon as I try microstepping.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.contraptor.org/forum/t-275140#post-897494</guid>
				<title>Re: Reprap_new_firmware + 1/16 microstepping = trouble</title>
				<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-897494</link>
				<description></description>
				<pubDate>Thu, 14 Oct 2010 20:51:42 +0000</pubDate>
				<wikidot:authorName>arthurwolf</wikidot:authorName>				<wikidot:authorUserId>471107</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Ok, found it !</p> <p>The problem was the following : changing the upper limit for the timer (OCR1A) to a lower value without stopping it/reseting it, caused it to run all the way to overflow before starting again.<br /> The problem is solved by removing this line in the interrupt :</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-identifier">OCR1A</span><span class="hl-code"> = </span><span class="hl-identifier">timer1LoadValue</span><span class="hl-code">;</span></pre></div> </div> <p>and doing this at the beginning of the interrupt :</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-identifier">ISR</span><span class="hl-brackets">(</span><span class="hl-identifier">TIMER1_COMPA_vect</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code"> </span><span class="hl-identifier">TCNT1</span><span class="hl-code"> = </span><span class="hl-number">0</span><span class="hl-code">; </span><span class="hl-comment">//reset timer</span><span class="hl-code"> </span><span class="hl-identifier">OCR1A</span><span class="hl-code"> = </span><span class="hl-identifier">timer1LoadValue</span><span class="hl-code">; </span><span class="hl-comment">//change timer value</span></pre></div> </div> <p>Solves my problem, does not seem to create more.<br /> However, it seems like the correct solution to this is <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=81190">to use the fast PWM mode using OCR1A for defining TOP (WGM13:0 = 15) since the OCR1A then will be double buffered</a>, but I have very little idea how to do it.</p> <p>I strongly recommand testing then commiting this to the svn repo in case someone else later tries to use it for 1/16&nbsp;microstepping.</p> <p>Pfew !</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.contraptor.org/forum/t-275140#post-896952</guid>
				<title>Re: Reprap_new_firmware + 1/16 microstepping = trouble</title>
				<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-896952</link>
				<description></description>
				<pubDate>Thu, 14 Oct 2010 05:09:10 +0000</pubDate>
				<wikidot:authorName>Albanetc</wikidot:authorName>				<wikidot:authorUserId>381022</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hmm, very interesting. Can you increase the sampling rate near the spikes, just to see if there is a pattern?</p> <p>Not sure what to make of it. Seems like an issue with the timer, but I'm wondering if it's helped by the fact that ISR routine modifies its own triggering timer.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.contraptor.org/forum/t-275140#post-896401</guid>
				<title>Reprap_new_firmware + 1/16 microstepping = trouble</title>
				<link>https://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-896401</link>
				<description></description>
				<pubDate>Wed, 13 Oct 2010 19:16:10 +0000</pubDate>
				<wikidot:authorName>arthurwolf</wikidot:authorName>				<wikidot:authorUserId>471107</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hello.</p> <p>So, I'm still trying to get my mini-cnc to work with the pololu steeper drivers and my sanguino.<br /> I have run into some trouble, all of which seeming to be related to the fact that I use 1/16 micro steeping.</p> <p>This leads me to values like :</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-prepro">#define</span><span class="hl-code"> </span><span class="hl-identifier">X_STEPS_PER_MM</span><span class="hl-code"> </span><span class="hl-number">2500</span><span class="hl-code"> </span><span class="hl-prepro">#define</span><span class="hl-code"> </span><span class="hl-identifier">X_MOTOR_STEPS</span><span class="hl-code"> </span><span class="hl-number">3200</span></pre></div> </div> <p>Which the firmware seems not to like.</p> <p>First problem I ran into was the firmware didn't do accelerations for feed-rates superior to 217&#160;mm/m ( went directly to full speed ).<br /> I'm not sure who writes this firmware so I'm posting this here, tell me if you know who to report this to.<br /> Fix is, in stepper_control.pde , replace :</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-identifier">next_move_ptr</span><span class="hl-code">-&gt;</span><span class="hl-identifier">steps_to_accelerate</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-types">int</span><span class="hl-brackets">)</span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-identifier">square</span><span class="hl-brackets">(</span><span class="hl-identifier">master_axis_feedrate</span><span class="hl-brackets">)</span><span class="hl-code"> * </span><span class="hl-identifier">steps_per_unit</span><span class="hl-code"> / </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-number">120</span><span class="hl-code"> * </span><span class="hl-identifier">units_based_constants</span><span class="hl-brackets">[</span><span class="hl-identifier">MAX_ACCEL</span><span class="hl-brackets">]</span><span class="hl-code"> </span><span class="hl-brackets">))</span><span class="hl-code">;</span></pre></div> </div> <br /> with: <div class="code"> <div class="hl-main"> <pre><span class="hl-identifier">next_move_ptr</span><span class="hl-code">-&gt;</span><span class="hl-identifier">steps_to_accelerate</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-types">long</span><span class="hl-brackets">)</span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-identifier">square</span><span class="hl-brackets">(</span><span class="hl-identifier">master_axis_feedrate</span><span class="hl-brackets">)</span><span class="hl-code"> * </span><span class="hl-identifier">steps_per_unit</span><span class="hl-code"> / </span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-number">120</span><span class="hl-code"> * </span><span class="hl-identifier">units_based_constants</span><span class="hl-brackets">[</span><span class="hl-identifier">MAX_ACCEL</span><span class="hl-brackets">]</span><span class="hl-code"> </span><span class="hl-brackets">))</span><span class="hl-code">;</span></pre></div> </div> <br /> Otherwise you get negative values for values bigger than int, and it skips acceleration. <p>The second problem is one I'm still stuck with :<br /> During acceleration, at higher feedrates, the motor stops working after accelerating for a while. Depending on values, it might start working again when maximam speed is reached, then stop working again during deceleration.<br /> I asked on pololu forums, where I was told it may be resonnance from the stepper, or a problem with the signals my microcontroller sends.<br /> I disconnected the stepper driver, and connected a speaker on the step pin instead : the problem is with the signal the step pin sends.<br /> I have read most of the code for this pin, and still can't find where the problem is.<br /> Here is the detail of the problem:</p> <p>I have added the following code just before the end of the pin interrupt loop thing ( OCR1A = timer1LoadValue; ) :</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-code"> </span><span class="hl-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">sequence_step_number</span><span class="hl-code"> % </span><span class="hl-number">100</span><span class="hl-code"> == </span><span class="hl-number">0</span><span class="hl-code"> </span><span class="hl-brackets">){</span><span class="hl-code"> </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-identifier">millis</span><span class="hl-brackets">()</span><span class="hl-code">-</span><span class="hl-identifier">last_dump</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string"> </span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-identifier">sequence_step_number</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string"> </span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">println</span><span class="hl-brackets">(</span><span class="hl-identifier">timer1LoadValue</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">last_dump</span><span class="hl-code"> = </span><span class="hl-identifier">millis</span><span class="hl-brackets">()</span><span class="hl-code">; </span><span class="hl-brackets">}</span></pre></div> </div> <p>Note :&nbsp;the problem exists even without this debug code, it's not causing it, it just adds a bass line to the sound from the speaker.<br /> So now every 100 steps I get the time it took to do that step, the step's number, and the duration we will wait untill sending the next step signal.<br /> I made a graph with the data :&nbsp;</p> <a href="https://www.flickr.com/photos/arthurwolf/5079202984/"><img src="https://farm5.static.flickr.com/4108/5079202984_b3b47b8ede.jpg" alt="flickr:5079202984" class="image" /></a> <p>X is step number, green Y&nbsp;is timer1LoadValue, and red Y is the time the step took ( it's supposed to be the same as the green one ).</p> <p>What it looks like is that when the timer1LoadValue variable gets near 255 and 127, the steps take a lot longer to iterate than they should.<br /> These two values don't seem random, but I&nbsp;don't find the problem in the code.</p> <p>Anybody has an idea ?</p> <p>Thanks a lot !<br /> ( will post this in the reprap forums in a few days if no answer here )</p> <p>EDIT :&nbsp;</p> <p>To get only the iterations that are too long, I put the following debug code :</p> <div class="code"> <div class="hl-main"> <pre><span class="hl-code"> </span><span class="hl-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-types">double</span><span class="hl-brackets">)(</span><span class="hl-identifier">micros</span><span class="hl-brackets">()</span><span class="hl-code">-</span><span class="hl-identifier">last_dump</span><span class="hl-brackets">)</span><span class="hl-code"> &gt; </span><span class="hl-number">30000</span><span class="hl-code"> </span><span class="hl-brackets">){</span><span class="hl-code"> </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">((</span><span class="hl-types">double</span><span class="hl-brackets">)(</span><span class="hl-identifier">micros</span><span class="hl-brackets">()</span><span class="hl-code">-</span><span class="hl-identifier">last_dump</span><span class="hl-brackets">))</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string"> </span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-identifier">sequence_step_number</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">print</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string"> </span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-identifier">Serial</span><span class="hl-code">.</span><span class="hl-identifier">println</span><span class="hl-brackets">(</span><span class="hl-identifier">timer1LoadValue</span><span class="hl-brackets">)</span><span class="hl-code">; </span><span class="hl-brackets">}</span><span class="hl-code"> </span><span class="hl-identifier">last_dump</span><span class="hl-code"> = </span><span class="hl-identifier">micros</span><span class="hl-brackets">()</span><span class="hl-code">;</span></pre></div> </div> <p>Here is an example of the data this outputs :</p> <div class="code"> <pre><code>start 1775536.00 2 23432 ok 32876.00 13308 246 32876.00 13315 246 32876.00 13322 246 32876.00 13379 244 32876.00 13510 244 32872.00 14889 232 32876.00 14910 232 32876.00 14916 232 32876.00 14964 232 32876.00 14989 232 32876.00 15010 232 32876.00 15183 230 32876.00 15218 230 32880.00 15234 230 32876.00 15249 230 32876.00 15252 230 32876.00 15265 230 32876.00 15330 228 32876.00 15334 228 32872.00 15367 228 32876.00 15383 228 32876.00 15589 226 32876.00 15748 226 32884.00 15758 226 32884.00 15764 226 32876.00 15779 226 32876.00 15791 226 32888.00 15793 226 32876.00 15795 226 32876.00 15797 226 32876.00 15799 226 32876.00 15801 226 32876.00 15805 226 32876.00 15807 226 32888.00 15809 226 32876.00 15811 226 32876.00 15813 226 32876.00 15815 226 32876.00 15817 224 32876.00 15831 224 32876.00 15841 224 32876.00 15853 224 32876.00 15862 224 32884.00 15866 224 32876.00 15870 224 32888.00 15877 224 32876.00 15881 224 32876.00 15886 224 32876.00 15896 224 32884.00 15930 224 32872.00 15962 224 32876.00 16030 224 32876.00 16036 224 32872.00 16053 224 32876.00 16063 224 32872.00 16068 224 32876.00 16073 224 32876.00 16096 222 32876.00 16103 224 32876.00 16119 222 32876.00 16130 222 32876.00 16133 222 32884.00 16136 222 32876.00 16148 222 32884.00 16152 222 32876.00 16159 222 32892.00 16182 222 32888.00 57610 214 32872.00 57661 214 32872.00 57666 214 32872.00 57676 216 32872.00 57682 216 32872.00 57726 216 32872.00 57880 216 32872.00 57891 216 32872.00 57899 216 32872.00 57927 216 32880.00 57935 216 32872.00 57939 216 32872.00 57950 216 32868.00 57956 216 32872.00 57968 216 32872.00 57979 218 32872.00 57989 218 32868.00 57991 218 32872.00 57993 216 32872.00 58015 218 32872.00 58024 218 32872.00 58026 218 32872.00 58035 218 32872.00 58050 218 32872.00 58055 218 32872.00 58067 218 32868.00 58073 218 32884.00 58099 218 32892.00 58129 218 32884.00 58498 220 32876.00 58538 220 32876.00 58558 220 32872.00 58571 220 32872.00 58574 220 32872.00 58601 222 32872.00 58612 222 32876.00 58614 222 32872.00 58616 222 32872.00 58661 222 32872.00 58803 222 32884.00 58823 222 32876.00 58838 222 32872.00 58850 222 32872.00 58866 222 32876.00 58872 222 32872.00 58878 222 32872.00 58886 224 32876.00 58898 224 32872.00 58922 222 32876.00 58935 224 32876.00 58952 224 32872.00 58958 224 32872.00 58973 224 32872.00 58997 224 32880.00 59086 224 32872.00 59166 224 32876.00 59183 226 32884.00 59200 226 32872.00 59217 226 32872.00 59252 226 32872.00 59258 226 32876.00 59301 226 32872.00 59426 226 32876.00 59435 226 32876.00 59456 226 32884.00 59489 228 32876.00 60514 236 32872.00 60942 238 32872.00 60949 238 32876.00 61045 240 32828.00 75002 120</code></pre></div> <p>So it seems the loop lasts 32768 microseconds too long for some values.</p> <p>EDIT 2:</p> <p>Putting the last_dump = micros(); just after ISR(TIMER1_COMPA_vect) { shows the problem is not with the calculations being too long ( never lasts over 200microseconds ), so the problem is with the PWM thing.</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>