|
|
View previous topic :: View next topic |
Author |
Message |
erhane
Joined: 01 Jul 2014 Posts: 41
|
Calculation of Stepper Motor Ramp Profile (Linear or S-Ramp) |
Posted: Tue Aug 26, 2014 2:13 am |
|
|
Hello,
I want to create a pulse profile which should be send via an output to motor driver IC.
I have pre-calculated profile and filled to an array and when i want to start my motor i am collecting delay values from that array.
Code: |
unsigned int const periods[117]={2449,1015,779,656,578,523,481,447,420,397,378,361,346,333,322,311,302,293,285,277,271,264,258,253,247,243,238,234,229,226,222,
218,215,212,209,206,203,200,197,195,192,190,188,186,184,182,180,178,176,174,172,171,169,167,166,164,163,162,160,159,157,156,155,154,152,151,150,149,148,147,
146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,127,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,
107,106,105,104,103,102,101,100};
//delay_us values. start from 2449us and reaching maximum speed at 100us delay.
//for(i=0,i<117,i++)
//{
//output_high(pin)
//delay_us(periods[next])
//output_low(pin)
//}
|
The problem is, my new system has different speed profiles which will be given by user that is why ramp profile of movement changes time to time and i should re-calculate that ramp profile every start of movement.
Do you have any algorithm to help me to calculate and fill that array?
I will have max speed delay value, distance to move(in pulse) and steps to reach max speed values.
Thank you |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Aug 26, 2014 8:07 am |
|
|
You have not given me enough to work on.
1) How are you controlling the 'OFF' period?
2) Do you HAVE to use an array?
Mike |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 26, 2014 9:32 am |
|
|
a reminder:
the largest value that can fit into a CCS unsigned int is ?????? |
|
|
erhane
Joined: 01 Jul 2014 Posts: 41
|
|
Posted: Tue Aug 26, 2014 9:42 am |
|
|
mike,
1_i am planing to create pulse via timer interrupt. 1us duration pulse is enough. i think 2us period timer will be ok.
2_i don't have to use array but the problem is i am driving my stepper motor in 256 microstepping mode and i need high speeds. My desired speed is 4us period(250khz) pulse. I have 32 MHz oscillator and this is not enough to make calculations on-fly i think? Do you have any suggestions?.
ASMBOY,
length of my array is around approximately 32000 values. Each value is between 1300-0. Do you think ROM will be problematic with this kind of huge array (int16)? |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 26, 2014 9:55 am |
|
|
lets try again:
your array is UNSIGNED INT
SO.....
when reading the MANUAL for CCS C ,
what is the largest integer value that can
fit into a CCS unsigned int i?????? |
|
|
erhane
Joined: 01 Jul 2014 Posts: 41
|
|
Posted: Tue Aug 26, 2014 12:04 pm |
|
|
Bro as you can see , i wrote int16 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Tue Aug 26, 2014 12:42 pm |
|
|
from the OP...
unsigned int const periods[117]={2449,1015,779,656,578,523,481,447,420,397
that ain't 16 bits !!!
jay |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Aug 26, 2014 2:58 pm |
|
|
This is like pulling teeth.
You're working on a need to know basis and only giving us a fraction of what we need.
In the OP you describe a conventional(ish) DC motor drive, then later declare it's a stepper.
Like I said before I don't know where to start trying to help you.
So. lets have a complete picture.
Mike |
|
|
erhane
Joined: 01 Jul 2014 Posts: 41
|
|
Posted: Mon Sep 01, 2014 4:28 am |
|
|
temtronic, 16bit can save up to 32767. as you can see my largest value is 2449!? so where is the problem.
thank you
temtronic wrote: | from the OP...
unsigned int const periods[117]={2449,1015,779,656,578,523,481,447,420,397
that ain't 16 bits !!!
jay |
|
|
|
erhane
Joined: 01 Jul 2014 Posts: 41
|
|
Posted: Mon Sep 01, 2014 4:31 am |
|
|
Hello Mike,
I am just trying to generate a indexer pulse to my stepper motor driver IC. I had need to code a ramp function which will calculate frequency on the fly. i found something and made some coding. i will share my results and final code here after testings.
Mike Walne wrote: | This is like pulling teeth.
You're working on a need to know basis and only giving us a fraction of what we need.
In the OP you describe a conventional(ish) DC motor drive, then later declare it's a stepper.
Like I said before I don't know where to start trying to help you.
So. lets have a complete picture.
Mike |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Sep 01, 2014 5:23 am |
|
|
your problem is this...
"unsigned int "
For some reason you think an unsigned integer is 16 bits, which it is NOT.
Please consult the CCS C Help files (press F11 in an open project), read the 'data definitions' section.
You'll see that unsigned int is defined as an 8 bit data NOT 16.
I'm assuming that the other version of C you've worked with had defaulted to 16 bit unsigned integers. Me, I always think of micro data as 0 to 255, 8 bits as data busses I started with were all 8 bits wide, except the Moto 1 bit wide micro.
jay |
|
|
erhane
Joined: 01 Jul 2014 Posts: 41
|
|
Posted: Mon Sep 01, 2014 6:16 am |
|
|
Oh you are right, i corrected it. Thank you =)
temtronic wrote: | your problem is this...
"unsigned int "
For some reason you think an unsigned integer is 16 bits, which it is NOT.
Please consult the CCS C Help files (press F11 in an open project), read the 'data definitions' section.
You'll see that unsigned int is defined as an 8 bit data NOT 16.
I'm assuming that the other version of C you've worked with had defaulted to 16 bit unsigned integers. Me, I always think of micro data as 0 to 255, 8 bits as data busses I started with were all 8 bits wide, except the Moto 1 bit wide micro.
jay |
|
|
|
|
|
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
|