Pages: [1]   Go Down
Author Topic: Arduino Due + 200 pulse encoder + stepper + glcd SOLVED  (Read 922 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
first of all sorry, but my english is not  good.
I have a spindle with encoder (200 pulses/RPM);
stepper driver + motor;
serial LCD;
 my sketch
setting vars.....
setup() {
.......
attach interrupt(encoder_pin, read_encoder, CHANGE); // CHNAGE -  200 pulses rising + 200 falling = 400P/RPM
}
read_encoder()  { pulse++;}
loop() {
if (pulse >= 10)  { digital_writhe(stepper_pin, HIGH); digital_writhe(stepper_pin, LOW); pulse=0; position+=1.25;}
if (millis() - prev_time >= print_delay_time) { prev_time = millis(); Serial_print( position); }
}
The problem :
when need to put more data to LCD, printing take a time and stepper loses a pulses while printing especially when the spindle rotation going fastt
« Last Edit: March 03, 2014, 07:25:18 pm by pipo » Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12443
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You shouldn't be doing serial I/O in your interrupt handler, its orders of magnitude slower
than anything else in the handler.

[ whoops - think that's not actually an issue - but if you post the code in code
tags it would be substantially easier to decipher - please do so ]
« Last Edit: January 29, 2014, 08:34:05 pm by MarkT » Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: