Go Down

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


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


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 will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131