Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking for Help With StallGuard #58

Open
Legohead259 opened this issue Nov 8, 2018 · 5 comments
Open

Looking for Help With StallGuard #58

Legohead259 opened this issue Nov 8, 2018 · 5 comments

Comments

@Legohead259
Copy link

Good day. I've gotten the StallGuard example to work on my Arduino Mega, however, I am confused on how to properly read if the STALL flag has been triggered. I've been able to Jerry-Rig it with (drv_status & SG_RESULT_bm)>>SG_RESULT_bp <= 5 to disable the motor but I know there has to be a cleaner way to get this value. Is there a function I can call to get the STALL flag without that clunkiness?

Also, is there any better documentation on the timer interupt system that is running the motor in the StallGuard example? I'd like to implement it, but I have no idea how it works past TIMSK1 is the clock and OCR1A is the clock speed.

Thanks!

@dmitrif
Copy link

dmitrif commented Nov 8, 2018 via email

@teemuatlut
Copy link
Owner

To get the stallguard flag

bool sg_status = driver.stallguard();

To get the stallguard measurement

uint16_t sg_measurement = driver.sg_result();

@dmitrif
Copy link

dmitrif commented Nov 8, 2018 via email

@pilhuhn
Copy link

pilhuhn commented Jan 3, 2019

Should the motor be turning in that example, as I see no digitalWrite(STEP_PIN,..); commands

@teemuatlut
Copy link
Owner

teemuatlut commented Jan 3, 2019

Yes. AVR timer interrupt with direct port manipulation:

ISR(TIMER1_COMPA_vect){
  PORTF |= 1 << 0;
  PORTF &= ~(1 << 0);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants