-
Notifications
You must be signed in to change notification settings - Fork 81
Description
I was trying to make the Grbl CNC software (https://github.com/gnea/grbl-Mega) work with some steppers in a couple sketches like https://wokwi.com/projects/328566930816369236 or the Uno like https://wokwi.com/projects/328163210406396500
In the Description/README.md file on https://wokwi.com/projects/328566930816369236 I wrote this:
This code does not appear to run the stepper timer correctly on wokwi as compared to a silicon Arduino Mega
Test: Run this simulation, and send this:
G1 X1 F1
??
$?
This initates a move to X=1mm, but as can be seen by the ?? output:
ok
<Run|MPos:0.000,0.000,0.000|FS:1,0>
error:8
The position doesn't update, and it remains stuck in "Run" mode, blocking and erroring commands like $?.
On a silicon Mega, this code produces:
ok
<Idle|MPos:1.000,0.000,0.000|FS:0,0>
[HLP:$$ $# $G $I $N $x=val $Nx=line $J=line $SLP $C $X $H ~ ! ? ctrl-x]
showing that it did move to the target position and then Idle. The $? command will function in Idle mode
The stepper scheduler is using Timer1 WGM=8 CTC mode with OCR1A in stepper.c
I'm not sure what the problem is. -- drf 2022-04-10
The grbl released hex file https://github.com/gnea/grbl/releases/download/v1.1h.20190825/grbl_v1.1h.20190825.hex from https://github.com/gnea/grbl/releases on a simulated Uno exhibits the same blocked behavior.
I think the TIMER1_COMPA_vect in stepper.h may not be triggering, but I'm not sure how to diagnose it. Do you have a test setup for timer modes that I could play with to see if can duplicate the problem with a simpler demo?