CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Stepper motor step/dir lib for drivers like A4988.. [SOLVED]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9113
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 13, 2020 5:57 am     Reply with quote

Both those stepper chips have 3 pins for 'microstepping' and you're not setting them so the chip is always in full step mode.

while I don't have either device it seems that ....
code like ...
...
select step size ( set M1,M2,M3 pins) [say using 'SWITCH']
issue 'step command to step'
...

should work...

Others who use these devices will have real World knowledge, I'm just reading the datasheets...
Ttelmah



Joined: 11 Mar 2010
Posts: 19225

View user's profile Send private message

PostPosted: Wed May 13, 2020 6:13 am     Reply with quote

The key thing is your existing code uses delay_ms between steps. Even
if the value is '1' for this, it limits your maximum step rate to just 1000*sec.
The code posted is instead using a timer interrupt at 25KHz for the minimum
step interval....

If you have a 400step motor, and you are using say 16* microstepping
(generally there is little reason to ever go beyond this - only special motors
have enough accuracy on the magnets to give worthwhile working beyond
this), then to do (say) 200RPM, you need a step pulse rate of:

(200*400*16)/60 = 21333Hz.

at 1000Hz, you can only get to about 20RPM.

In fact looking at it you use two delay_ms calls, so 10RPM.
The stepper controller should only require a pulse of perhaps 1uSec (not
mSec), and the repeat frequency of this will need to go up to tens
of kHz if you want to move the motor quickly.....
mednas



Joined: 09 May 2020
Posts: 7
Location: Algeria

View user's profile Send private message Send e-mail

PostPosted: Wed May 13, 2020 11:41 am     Reply with quote

The 3 pins in the driver to select the mode M1, M2 and M3 are connected to 3 interruptors i can select full step mode the 3 pins connected to GND and 1/16 microstep the 3 pins to VCC. My code work only for full step. I have to change delay to us for microsteps.
BTW i have tested the code of the link shared by Ttelmah it work fine with timer 25khz, this what i want. I will add some lines to use uart and receive data from uart and show it in lcd.
Thank you guys
_________________
''I never lose, I either win or learn!" Nelson Mandela
Ttelmah



Joined: 11 Mar 2010
Posts: 19225

View user's profile Send private message

PostPosted: Wed May 13, 2020 12:44 pm     Reply with quote

Good. Very Happy

Change the title of the thread, to include [Solved] please.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group