Calculator & MeasurementLCD-LED DisplayMotor Circuit Diagrams

PIC16F628A L297 STEPPER MOTOR DRIVER WITH L298 Schematic Circuit Diagram

I want to share with you the stepper motor driver that I designed at the request of a teacher. It’s actually getting quite a lot. But because of the intensity of the work, I could finish.

The drive I made was designed in general. So it does not serve any particular purpose. In short, I can say that it was done to observe the operation of stepper motors. It can be used with stepper motors with 1.8 or 7.5 step angle. You can drive the engine in Full and Half drive mode. You can also remove one button with the previously set speed. Or you can move the motor step by step.

I’ve added a few features like this 🙂

As the title suggests, I used L297 and L298 in Driver section . Thanks to these two integrated stepper motors

The L297 is a step motor control integral , which generates the phase signals of the step motor at the output via the control and clock signals applied to the input.

The L298 is the H-bridge motor drive integration. There are two H bridges and can be used in many areas. Max can give 2A / phase current.

As the main controller I used the 2X8 LCD inside as usual pic16f628 🙂 and view the operations done. The clock frequency of the L297 is given by the Pic16F628’s RB3 pin, the Hardware PWM module. I also check L297’s Enable, CW-CCW and HALF / FULL pins with 16F628. My hardware in general.

The scheme of the system is as follows.

When I installed the system, I applied the schema on the first page of L297. Despite this, I am not satisfied with the way you drive. In this case, L297 kontrolin working with the current value of the current control although I did not do well. I’ve done quite a bit about this, but I haven’t made any progress.

Since I use Lm2575 in the circuit supply , you can supply up to 40V. I did not exceed 39V in my tests. I did all my tests at this level. However, it is really a problem at high speeds. In motors with 1.8 degree, I can get up to 200 – 250 rpm and 300-400 rpm for 7.5 step motors. After these cycles, the motor resonates and stops. I couldn’t figure it out. This will be one of the biggest problems in my system, which I think is needed to increase the supply voltage more.

As I said, I’ve tried several stepper motors to test the system. These were all bipolar and unipolar engines that I had taken out from the scanners from the printers and purchased for the CNC before. Because I get the clock pulse of L297 with the HPWM hardware of 16F62, I can get a min 250Hz with 4 MHz osc frequency. Maximun frequency is in my hands, but for now I have limited to 3333hz. I thought this frequency was enough.

I’d like to tell you where it is. I did my simulation experiments in an isis environment. I didn’t have 2 × 8 LCD in the office, so I used 2X16. There is no difference between them except the size. Why don’t you ask me if you used half the screen 🙂

The use of the system is as follows.

In normal operation, the screenshot is as shown in the figure.

Here the speed of the motor is shown on the top line. Since we know the frequency of the processor from the PWM hardware, we can calculate the engine speed based on the motoun step angle and driving mode. For example. Let’s say we drive a 7.5-degree engine in full-length, as in the picture. The engine completes a 360-degree cycle in 48 steps. There are several ways to calculate the cycle after these obtained values. For example, if you calculate the number of hours per minute and divide by the number of steps in 1 turn, you get the cycle information. But as the frequency value grows in numbers, I calculated how many turns I would assume, assuming that I would turn 1 turn per minute. If you multiply this coefficient by the frequency value, you get the cycle again. So Cycle = PWM_Freq * (60/1 Number of Steps in Tour)

If we calculate for 250Hz, we have 250 * (60/48) = 312.5 rpm. If we do the same account for 1.8 degrees, it is available as 250 * (60/200) = 75 rpm. If HALF is selected instead of Driving Mode FULL, these values ​​will be reduced by half.

There are 6 buttons in the circuit. These are the Start, Stop, Up, Down, DRC, and Set Buttons respectively.

With the Up Button, the engine speed is increased. 1.8 degree motor max. the value is 1041, in the 7.5 degree motors the max. the value is 4339 RPM.

The Down Button acts as the opposite of the Up button. Min. The RPM value is 75 revolutions and in the 75 degree engines it is 312 rpm.

Start Button Allows you to exit a pre-set speed with a ramp.

The Stop Button slows down the engine with a ramp.

DRC Button Used to change the direction of the motor rotation. Gently removes the engine and changes the direction of rotation and then smoothly removes the old speed.

Set Button is entered to enter the menu related to the motor-related parameters.

Now let’s look at the parameters.

The first menu is the Step_Ang menu. Currently there are 2 options, 1.8 and 7.5. Navigating the menus is only possible with the set button.

The next step is the Driv_Mod parameter. His job is clear. If the engine does not have a Full step, you will determine whether to drive in Half-step mode.

Then Soft_Strt RPM Menu Revenue. In this menu, in the Main Operation mode, the Start button is the menu in which you set the motor to which the motor is going to start.

In the Next Step, you come to the Soft_Strt Acc Menu. When you press the start button, the motor cannot be disengaged. It must climb up a certain ramp. Here in this menu you determine the rate of climb to the ramp. You must give a value between 1 and 10. When you give the value of 1, the engine is fast, and when you give 10, the motor slowly moves to the desired speed.

Settings These are all. To exit this menu, simply press the set button. Settings are saved and returned to the main operation.

I’il tell you where it is. PWM resolution reduces PWM resolution at high frequencies. It also deteriorates in the linearity of the frequency increase. The higher the frequency, the faster the motor starts to accelerate. This imbalance can be smoothed, but I’m not bothered because the processor is out of memory.

Finally, there is a Step_Mod menu in the Main operating mode. Step Mode feature came to mind at the last moment. I said we could do the engine step by step while we did. 🙂 In this menu, you can move the motor step by step with the Up and Down Buttons. You can change the driving behavior of the engine by pressing the DRC button. To exit the menu, you need to press the Set button again. In general, this is the settings. You can see more clearly in the video at the end of the post.

The printed circuit board is as follows.

As you can see I used Lm2575 in Feed. So you can feed up to 40V. L298 max. If you use the LM2575HV series you can give up to 46V. There is an input capacitor under the printed circuit board LM2575. This is min. It’s supposed to be 50V. I forgot to write.

I’ve been through a bit of PCB. I took a lot of time to complete the drawing, especially the L297 and L298 Circles. In many places I had to pass 1-2 paths between the pads. This makes the PCB printing a bit difficult. I think you need to be a little experienced in this.

L298 e Must be connected to the cooler. I’ve broken 1 in my experiments because of an overcurrent. Because it is a very perishable object, it needs to be well cooled. The cooler I use is the same as I did on the PCB. Normally I had a motherboard removed. I told you not to waste a lot here. That’s what happened. I put a fan place on the PCB. But I made a little design mistake here. Fans work with 12V. If you feed the device with 12V, but you do not have trouble with the 30-40V feed on the fan must be set up again by installing a circuit LM2575 voltage must be fixed.

As you can see, the chiller has a very large structure. : D It is unlikely that you will find it on the market.

It was a lot of work on the software. Actually, the software has nothing to do with it. Everything is clear. The problem is that the memory 16F628 has little memory. : D They have very nice brothers, but I would like to take advantage of it because I have a lot of hands. I’m bringing 40 kinds of water to fit the processes in memory 🙂 But there is a good part in this business. When I had to make an account of 1byte space in memory, I have improved myself in code optimization 🙂

I took a video. The motor in the video is a 1.8-degree and 2.2nm stepper motor. I was ripped off from an old device. I have a lot of engines like this. I’ve done a lot of tests.

You can see all the features of the system in the attached video.

The engine in the video was a 6-end unipolar engine. But when I gave energy to the common ends of the engine, I started the motor as bipolar because it attracted a lot of current at low revs. So the drive is only connected to the phase ends of the motor

PIC16F628A L297 Stepper Motor Driver with L298
PIC16F628A L297 L298 İLE STEP MOTOR SÜRÜCÜ
Yazar: Mucit23 07.11.2012 tarihinde yayımlanan 26.04.2017 tarihinde güncellenen PIC16F628A L297 L298 ile Step Motor Sürücü ile 25 yazısı var. Arşivi; Mucit23

Merhabalar arkadaşlar.

Bir hocamın isteği üzerine tasarlamış olduğum step motor sürücüsünü sizlerle paylaşmak istiyorum. Sistemi yapmaya başlayalı aslında epeyce oluyor. Fakat işlerin yoğunluğundan dolayı anca bitirebildim.

Yaptığım sürücü genel olarak tasarlandı. Yani herhangi özel bir amaca hizmet etmiyor. Kısacası Step motorların çalışmasını gözlemlemek amacıyla yapıldı diyebilirim. Yapmış olduğum sürücü ile 1.8 veya 7.5 adım açısına sahip step motorlarda kullanılabilir. Motoru Tam ve Yarım sürüş modunda sürebilirsiniz. Ayrıca daha önce set edilen devire tek tuşla çıkartabilirsiniz. Veya motoru adım adım hareket ettirebilirsiniz.

Buna benzer birkaç özellik ekledim 🙂

Başlıktan da anlaşılacağı üzere Sürücü kısmında L297 ve L298 ikilisini kullandım. Bu iki entegre sayesinde step motor üzerinde birçok işlem yapabiliyoruz/

L297 adım motor kontrol entegresidir, Girişine uygulanan kontrol ve clock sinyalleri ile çıkışında adım motorun faz sinyallerini üretmektedir.

L298 ise H-bridge motor sürücü entegresidir. içerisinde iki adet H köprüsü bulunup birçok alanda kullanılabilir. Max 2A/phase akım verebilir.

Ana kontrolcü olarak her zamanki gibi pic16f628 🙂 ve yapılan işlemleri görüntülemek içinde 2X8 LCD kullandım. L297 nin clock frekansını pic16F628 ‘in RB3 pini yani Donanımsal PWM modülünden veriyorum. Ayrıca L297’nin Enable, CW-CCW ve HALF/FULL pinlerinide 16F628 ile kontrol ediyorum. Donanımım genel olarak böyle.

Sistemin Şeması aşağıdaki gibidir.

l297-L298-stepper-motor-driver-circuit

Sistemi kurarken L297′ nin ilk sayfasında verilen şemayı birebir uyguladım. Buna Rağmen sürüş şeklinden pek memnun kaldığım söylenemez. Bu durumda L298 ile birlikte çalışırken L297′ nin akım değerini düşürmeme rağmen akım kontrolünü iyi yapamadı. Düşük devirlerde motoru titretiyor.Bu konu üzerinde epeyce ugraştim ama pek bir gelişme kaydedemedim.

Devrenin beslemesinde Lm2575 kullandığım için 40V a kadar besleme gelirimi verebilirsiniz. Ben testlerimde 39V’ un üzerine çıkmadım. Tüm testlerim de bu seviyede yaptım. Buna rağmen yüksek devirlerde gerçekten problem oluyor. 1.8 dereceli motorlarda 200 – 250 rpm e kadar, 7.5 adım açılı motorlarda ise 300-400 rpm’ye kadar problemsiz çıkabiliyorum. Bu devirlerden sonra motor rezonansa giriyor ve duruyor. Bunu bir türlü aşamadım. Yaptığım sistemdeki en büyük sorunlardan biride bu olacak ki sanırım besleme voltajını dahada arttırmak gerekiyor.

Dediğim gibi Sistemin testlerini yaparken çeşitli step motorlarda denedim. Bunların hepsi 1.8 ve 7.5 adım açısına sahip, yazıcılardan tarayıcılardan söktüğüm ve daha önce CNC için satın almış olduğum bipolar ve unipolar motorlardı. L297 nin Clock palsini 16F62’in HPWM donanımı ile elde ettiğim için 4 Mhz osc frekansı ile min 250Hz alabiliyorum. Maximun frekans ise benim elimde olmasına rağmen şimdilik ben 3333hz ile sınırladım. Bu frekansın yeterli olduğunu düşündüm.

Yeri Gelmişken söylemek isterim. Simülasyon denemelerimi isis ortamında yaptım. İsiste 2×8 LCD bulunmadığı için 2X16 kullandım. Boyut dışında aralarında hiçbir fark yoktur. Niye ekranın yarısını kullandın diye sormayın sakın 🙂

Sistemin kullanımı şöyledir.

Normal çalışmada ekran görüntüsü yan şekildeki gibidirResim1

Burada üst satırda Motorun devri gösterilir. işlemcinin PWM donanımından çıkan frekansı bildiğimiz için Motoru devrini motoun adım açısını ve sürüş modunu baz alarak hesaplayabiliyoruz. Örneğin. resimdeki gibi 7.5 derecelik bir motoru tam adımda sürdüğümüzü düşünelim. Motor 360 derecelik bir turunu 48 adımda tamamlar. Bu elde edilen değerlerden sonra devri hesaplamanın birkaç yolu var. Örneğin dakikadaki clock sayısını hesaplayıp 1 turdaki adım sayısına bölerseniz devir bilgisini elde etmiş olursunuz. Fakat frekans değeri büyüdükçe sayılarda büyüyeceği için ben dakikada 1 tur döndüğünü varsayarak sn kaç tur döneceğini hesapladım. Bu elde ettiğim katsayıyı frekans değeriyle çarparsanız yine devri elde etmiş olursunuz. Yani Devir=PWM_Freq*(60/1 Turdaki Adım sayısı)

250hz için hesaplarsak 250*(60/48)=312.5 dev/dak olarak bulunur. Aynı hesabı 1.8 derece için yaparsak 250*(60/200)=75 dev/dak olarak bulunur. Eğer Sürüş Modu FULL yerine HALF seçilirse bu değerler yarı yarıya düşer.

Devrede 6 adet buton var. Bunlar Sırasıyla Start, Stop, Up, Down, DRC, ve Set Butonlarıdır.

Up Butonu ile motor devri arttırılır. 1.8 derecelik motorlarda max. değer 1041, 7.5 derecelik motorlarda ise max. değer 4339 RPM dir.

Down Butonu ise Up butonunun tam tersi iş görür. 1.8 derecede min. RPM değeri 75 devir, 75 Derecelik motorlarda ise 312 devir/dakikadır.

Start Butonu Önceden set edilmiş bir devire rampalı bir şekilde çıkılmasını sağlar.

Stop Butonu ise Motoru rampalı bir şekilde yavaşlatıp durdurur.

DRC Butonu Motor devir yönünü değiştirmeye yarar. Motoru yumuşak bir şekilde durdurup devir yönünü değiştirdikten sonra eski devrine yumuşak bir şekilde çıkartır.

Set Butonu ise Motorla ilgili parametrelerin girileceği menüye girilmesi sağlanır.

Şimdi Parametrelere bakalım.

İlk Menü Step_Ang Menüsüdür Buradan Motorun Step açısı seçilir. Şimdilik 1.8 ve 7.5 olmak üzere 2 seçenek var. Menüler arası gezme sadece set butonu ile olur.

Bir Sonraki adım Driv_Mod parametresidir. Görevi belli zaten. Motorun Tam adımdamı yoksa Yarım adım modundamı sürüleceğini belirliyorsunuz.

Daha Sonra Soft_Strt RPM Menüsü Gelir. Bu menüde Ana Çalışma modunda Start butonunabastığınızda motorun hangi devire çıkacağını belirlediğiniz menüdür.

Bir Sonraki Adımda ise Soft_Strt Acc Menüsüne gelirsiniz. Start butonuna bastığınızda motor istenilen devire birden çıkamaz. Belli bir rampayı tırmanarak çıkması gerekir. İşte bu menüde rampaya tırmanış hızını belirlersiniz. 1 ile 10 arasında bir değer vermeniz gerekir. 1 değerini verdiğinizde motor hızlı, 10 değerini verdiğinizde ise motor yavaş bir şekilde istenilen devire çıkar.

Ayarlar Bunlardan ibaret. Bu menüden sonra çıkmak için set butonuna basmanız yeterlidir. Ayarlar kaydedilip ana çalışmaya dönülür.

Yeri gelmişken söyliyeyim. PWM donanımının yapısından dolayı Yüksek frekanslarda PWM çözünürlüğü düşüyor. Aynı zamanda frekans artışındaki lineerlikde bozuluyor. Bu durumdan dolayı frekans yükseldikçe motor daha hızlı hızlanmaya başlıyor. Bu dengesizlik düzetilebilir fakat şuanda işlemcinin hafızasında yer kalmadığı için uğraşmadım.

Son olarak birde Step_Mod menüsü vardırki bu menüye girmek için Ana çalışma modunda Set butonuna yaklaşık 2 sn boyunca ekranda Step_Mod Yazısını görünceye kadar basmanız gerekmektedir. Step Mod özelliği aslında son anda aklıma geldi. Dedim bari yapmışken motoru adım adımda sürebilelim. 🙂 Bu menüde Up ve Down Butonlarıyla Motoru adım adım hareket ettirebilirsiniz. DRC butonuna basıp motorun sürüş şeklini değiştirebilirsiniz. Menüden çıkmak için yine Set butonuna basmanız gerekir. Genel olarak ayarlar böyle. Yazı sonundaki videoda daha net görebilirsiniz.

Baskı devre aşağıdaki gibidir.

l297-L298-pcb

Görüldüğü üzere Beslemede Lm2575 kullandım. Bu yüzden en fazla 40V ile besleyebilirsiniz. L298 max. 46V gelirimle çalışır Eğer LM2575HV serisini kullanırsanız 46V a kadar verebilirsiniz. Baskı devrede LM2575 in altında giriş kondansatörü var. Bu min. 50V luk olması gerekiyor. Yazmayı unutmuşum.

PCB konusunda biraz uğraştım gerçekten. Çizimi devam ettirirken özellikle L297 ve L298 Çevresini tamamlamak bayağı vaktimi aldı. Birçok yerde padlar arasından 1-2 yol geçirmem gerekti. Durumun böyle olması tabi PCB basımını birazcık zorlaştırıyor. Bu konuda biraz tecrübeli olmak gerekiyor sanırım.

L298 e Must be connected to the cooler. I’ve broken 1 in my experiments because of an overcurrent. Because it is a very perishable object, it needs to be well cooled. The cooler I use is the same as I did on the PCB. Normally I had a motherboard removed. I told you not to waste a lot here. That’s what happened. I put a fan place on the PCB. But I made a little design mistake here. Fans work with 12V. If you feed the device with 12V, but you do not have trouble with the 30-40V feed on the fan must be set up again by installing a circuit LM2575 voltage must be fixed.

microchip-projects-l297-L298-stepper-motor-driver-1

microchip-projects-l297-L298-stepper-motor-driver-2 microchip-projects-l297-L298-stepper-motor-driver-3 microchip-projects-l297-L298-stepper-motor-driver-4

As you can see, the chiller has a very large structure. : D It is unlikely that you will find it on the market.

It was a lot of work on the software. Actually, the software has nothing to do with it. Everything is clear. The problem is that the memory 16F628 has little memory. : D They have very nice brothers, but I would like to take advantage of it because I have a lot of hands. I’m bringing 40 kinds of water to fit the processes in memory 🙂 But there is a good part in this business. When I had to make an account of 1byte space in memory, I have improved myself in code optimization 🙂

I took a video. The motor in the video is a 1.8-degree and 2.2nm stepper motor. I was ripped off from an old device. I have a lot of engines like this. I’ve done a lot of tests.

You can see all the features of the system in the attached video.

The engine in the video was a 6-end unipolar engine. But when I gave energy to the common ends of the engine, I started the motor as bipolar because it attracted a lot of current at low revs. So the drive is only connected to the phase ends of the motor.

In the video here I increased the engine to 1000 rpm . But it usually doesn’t work at these times. If I rotate the motor shaft slightly after passing the resonance frequency, the synchronization is immediately detected and the motor starts to rotate.
7.5-degree engines with a maximum speed of 4339dev / min I could go up. Of course with the technique I mentioned above. Otherwise, the same applies to them.

Despite the problems I experienced, it was a very good source of experience for me.

Tags

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button
Close
Close