Go Down

Topic: Arduino Due + 200 pulse encoder + stepper + glcd SOLVED (Read 951 times) previous topic - next topic

pipo

Jan 27, 2014, 02:22 am Last Edit: Mar 04, 2014, 01:25 am by pipo Reason: 1
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

MarkT

#1
Jan 27, 2014, 04:02 pm Last Edit: Jan 30, 2014, 02:34 am by MarkT Reason: 1
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 ]
[ I won't respond to messages, use the forum please ]

Go Up