So, lets assume you have a pair of suitable stepper motors for your micromouse. I have used the RS 440-420 steppers. these are a Nema17 size motors rated at 5V, 500mA drive.
The data sheet shows a winding resistance of 10 Ohm, inductance 6 mH and a holding torque of 70 mNm.
These will directly drive a wheel of outside diameter 50mm. Since the motor is a 200 step design, a single step will be 3.14*D/200 = 0.785 mm. However, I will drive it with a half stepping sequence giving me 400 steps per revolution with each step being about 0.39mm. the half-stepping sequence gives a smoother response and better performance at speed. The exact distance on the ground is not worth calculating up front. It is better to calibrate with your mouse by running, say, 5000 step (about 2m), measure the distance actually travelled and divide by 5000. For the micromouse, all distances are based on cells and steps. For the calculations below, I will assume a single cells is 450 steps long.
You can check the data sheet here SLA7024. One annoyance of this chip is that the designers seem to have taken delight in making it hard to physically wire up. The lead spacings are inconvenient and the pin arrangements do not lend themselves to a neat circuit layout. however, it does its job very well and is popular for this application.
If you don't want the expense or complication of the specialist chip, you could use the simpler and cheaper UCN5804B stepper driver. This takes step and direction pulses and is much more convenient to use. However, if you are to run from a high battery voltage you will need a resistor in series with the windings to limit the motor current. Say you have a 14 Volt supply for these motors. The current limiting resistor can be placed in the common power supply and would need to be about 15 Ohm. With a current of 500 mA, the power dissipated in this resistor would be 3.75 Watts so you want at least a 5W rated resistor. This should, ideally, not be a wound type (the common one) at the inductance of the resistor may limit the start-up current in the motor. Now, not only is a suitable resistor a little hard to find, bulky and hot to the touch, you are wasting nearly two thirds of the energy in your batteries keeping the room warm. Compromises ever compromises.
Check out the data sheet to see just how easy the 5804 is to use UCN5804B.
If you would rather not do this, you can use a sequencing chip like the L297. It takes step, direction and full/half signals and does all the sequencing for you. This is very convenient as your motor driver routine only has to worry about generating a single pulse on a single pin. The L297 works at normal logic levels and lives in a 20 pin DIL package.
There are other functions in this chip which are not used in this application.
You can have a look at the data sheet L297.
The 5804 driver also needs step and direction signals and is very easy to use.
Because the motor is used in an open-loop configuration, you must, at all costs, avoid the motor stalling or missing a step. The key is a suitable acceleration and velocity profile.
At low speeds with the drive electronics shown, the motor might provide a torque of only about 50 mNm. That is about 2 N at the wheel rim, per motor. This is enough to accelerate a 1 kg mouse at about 4m/s/s or 0.4g. Now, 1m/s/s for our mouse is around 2500 steps/s/s.
The available torque will decrease quite rapidly with speed and so will our ability to accelerate and decelerate. Consequently, we are unlikely to see accelerations of 4 m/s/s in practice.
For calculations, work in steps. All the events in the control of a stepper occur at intervals of one step of the motor. As the motor changed speed, the time between steps changes. This is quite different from the way you would drive a DC motor where fixed time intervals are used.
To drive the motor, you need to emit pulses at decreasing intervals until you have reached some maximum rate and then increase the intervals again until you come to a halt. The intervals can be calculated from the acceleration and the step number by rearranging a bit of the common equations of motion.
s is the distance travelled, here in steps, a is the acceleration, in steps/s/s and t is the elapsed time, in seconds.
Rearrange this to give
Now we use a program or your favourite spreadsheet to generate a table of values. The elapsed time is not much use to us so we calculate the time difference between successive steps to get a table that will look something like this:
The column that you would use in your code is the fourth one which shows the time between pulses needed to control the processor's timer. This example assumes that you have a 1MHz clock for the timer. The actual table may have as many entries as you like although beyond about 500, the numbers are beginning to differ only by a couple each time and so the granularity of your timer makes it not worth getting too carried away. With the figures shown above, your motor will be stepping at about 1500 steps per second. Each motor will be doing this so your processor will be handling 3000 interrupts per second. Be sure to keep the code for the interrupt routines small and efficient. You should also try to be sure that there are no interrupts with a higher priority than the stepper driver. Once they are up to speed, a missed pulse or two will send them out of synchronisation and the motor will stall. The usual result is the mouse doing a rapid, unexpected turn into a wall. Guess how I know that? At 1500 steps per second, our example mouse will be doing about 580 mm/s or a little more than 3 cells per second.
Single timer, single interrupt
The trick here is to use a phase accumulator. This is a 16 bit value to which is added a constant at each interrupt. The result is allowed to overflow but we detect the presence of the overflow and use it to trigger our secondary event. For example, we start out with the phase accumulator at zero and add the value 5466 to it at each interrupt. After 12 interrupts, the accumulator overflows while changing from 60126 to 56 and we can send a pulse to the motor. After a further 12 interrupts, the accumulator once again overflows and we send another pulse. In this way, we get a motor pulse at 1/12 of the interrupt rate - about 417 pulses per second in this case.
The value for the constant, P, is readily calculated. Let FT be the timer interrupt frequency and FE be the desired event frequency, the accumulator is 16 bit so we have a further constant of 65536 to give:
This is quite easy to calculate, especially if you do the multiplication first (as you should). There will always be some jitter in this arrangement. The higher your event frequency, the worse it will be. Increasing the interrupt rate may mean that you take up all your time processing interrupts. To drive two motors, use two phase accumulators and two event handlers. The data for the acceleration tables will need a little more care in generation than that shown above but is not impossible. Alternatively, you could have a third accumulator generating events at a lower rate of, say, 100 Hz and implement a more traditional motor control loop that operates in fixed time intervals. New motor velocities and steering corrections can be calculated at those rates rather than at each motor step. Now you can have very tight, fast events to put steps out to the motors. Remember to be sure that any changes to the values of the motor constants are atomic in as much as you must ensure that a value can not be used half way through a change made elsewhere. Remember also that you will have only 1/5000 second to do all this unless you implement a system of flags that allows the low frequency event handler to run asynchronously. You should not let the motor step event handler run asynchronously as it is important that the timing of the pulses is accurate.
One timer with output compare
Each channel will have a register which can take a 16 bit value. as the timer counts through this value an interrupt is generated. Your code then steps the motor and fetches a new value for the compare register. The cunning part of this is that the new value is added to the old value because we are dealing in time intervals rather than absolute times. Thus, the next interval must occur after so many counts. You don't have to worry about overflow because both the timer and the compare register will be affected in the same way.
To accelerate the motor, just get the next value up from the acceleration table. Deceleration is a matter of getting the next value down. Be sure not to pass the bounds of the table and pick up rubbish. The table itself is conveniently held in flash/program memory.
Now we can describe the speed of the mouse in a particularly convenient way. We don't really care what the actual speed, in m/s, is. Instead, speed tells us how far up the table we are. A very useful benefit being that we always know exactly how many steps are needed to come to a halt.
Here is some sample code from a stepper application. It is written in C for the AVR processor:
Each motor has a target distance to cover. You will see that there is no special need to see if we are past half way - only that we have room to stop.
The motors can be controlled independently or as a locked pair. Steering corrections can be fed in as changes in the speed of each wheel. Special movements like integrated turns can have their own acceleration tables.
A summary of this page is available as a powerpoint presentation
A simple spreadsheet for calculating the timer values is also available here .
+ نوشته شده در جمعه 9 بهمن1388ساعت 21:2 توسط Ali Shokouhi Rostami |
این وب سایت کاملا جنبه شخصی داشته و جزء وب سایت رسمی دانشگاه ها محسوب نمی گردد.
پروفایل مدیر وبلاگ
عناوین مطالب وبلاگ
گروه رباتیک دانشگاه آزاد اسلامی - بهشهر
فروش لپ تاپ
شهر الکترونیک همدان
شهر الکترونیک سیرجان
شهر الکترونیک یزد
شهر الکترونیک مشهد
مرکز اطلاعات تخصصی مدیریت شهری
خدمات الکترونیکی ایران
باشگاه پژوهشگران جوان
باشگاه دانش پژوهان جوان
آرشیو پیوندهای روزانه
|نوشته های پیشین|
اطلاعیه های درسی
دروس دانشگاه علم و صنعت
اموزش رباتیک و کتب رباتیک
دروس و آزمایشگاه ها دانشگاه آزاد
مقالات ارایه شده در کنفرانس - فارسی
دروس دانشگاه پیام نور
دروس دانشگاه تمیشان
کتب ترجمه شده
دروس دانشگاه امام خمینی
دانشگاه جامع علمی کاربردی
کنفرانس های برق
وب سایت خانم اشرف السادات میرکمالی
وب سایت مهندس مهدی محمدزاده رستمی
وب سایت دکتر صالحی زاده
وب سایت دکتر جلالی
وب سایت مرجع ابزار دقیق
وب سایت بسیار جالب نرم افزار
وب سایت دانشگاه آزاد واحد بهشهر
گروه ICT تميشان
سایت دانشگاه پیام نور
اطلاعات جامع آزمون کارشناسی ارشد مهندسی برق دانشگاه آزاد اسلامی
سایت دانشگاه تميشان
لیست و آدرس سایتهای علمی کشور
سایت بسیار خوب برای نرم افزارهای عمومی و تخصصی
سایت بسیار خوب برای پی ال سی
دانلود مقالات برق الکترونیک و کامپیوتر
وب سایت IT
وبلاگ اپتیک و لیزر ایران