tag:blogger.com,1999:blog-6100511197805579796.post7571848129746913247..comments2024-02-14T18:43:36.096+01:00Comments on Davide Gironi blog: Controlling DC Motor speed and direction with AVR AtmegaDavide Gironihttp://www.blogger.com/profile/16366076989473118278noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-6100511197805579796.post-19725876822485156472016-10-08T11:10:42.327+02:002016-10-08T11:10:42.327+02:00Again it's not clear to me why it will be usef...Again it's not clear to me why it will be usefull. Consider the the "standard" PWM frequancy for a motor is 20Mhz, Anyway, what you can do, is set the PWM at 250Hz. In order to change the PWM, set the ICR1 according to this. With a 4Mhz crystal you have got an ICR1 a little low to me. I will set it to 8Mhz at least, and use ICR1 = 400, with a prescaler of 1 for 20Mhz, ICR1 = 500 with a prescaler of 64 for 250Hz. Consider that 250Hz is not a good PWM for a motor.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-41142559299936822232016-10-08T04:14:15.583+02:002016-10-08T04:14:15.583+02:00Hello Davide..
Let me explain in detail:
Issue: A...Hello Davide..<br />Let me explain in detail:<br /><br />Issue: At Atmega8(Clk: 4MHz), Using timer1, generate two PWM signals (OC1A(Fw)/OC1B(Rv)) of 20KHz(50us).<br />Later, external interrupt is generating while motor is running in parallel. Need to change the PWM signals of 4ms while changing its duty.<br /><br />So, I defined timer in this way...<br /><br />(calculated using prescalar = 1, Fast PWM mode14)<br />TCCR1A=(1<<COM1A1) | (1<<COM1A0) | (1<<COM1B1) | (1<<COM1B0) | (1<<WGM11) | (0<<WGM10);<br /> <br />TCCR1B=(1<<WGM13) | (1<<WGM12) | (1<<CS10);<br /><br />ICR1 = 199; <br />OCR1A = 0;<br />OCR1B = 0;<br /><br />TIMSK = 0;<br />TIFR = 0;<br /><br />Please suggest me, how can i set the condition to increase/decrease the duty to set the pulse of 4ms.<br /><br />Thanks. Ashhttps://www.blogger.com/profile/16096909457683803266noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-70631734268872062212016-10-07T20:17:14.218+02:002016-10-07T20:17:14.218+02:00Hello, frequency is setted up by the timer definit...Hello, frequency is setted up by the timer definitions definitions DCMOTORPWM_ICR1 DCMOTORPWM_PRESCALER.<br />Look at the dcmotorpwm.h file comments on that macro. I can't understand if you have to change the duty period of the PWM frequency. Anyway, you can perform a precise frequancy and duty cycle rewriting the set speed function (dcmotorpwm_backward and dcmotorpwm_forward). You will have to set OCR1B or OCR1A to a calculated number.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-81304286579264335932016-10-07T12:29:52.100+02:002016-10-07T12:29:52.100+02:00Hello Davide,
Thanks for your reply. I configured ...Hello Davide,<br />Thanks for your reply. I configured the timer registers. My requirement is to control the bidirectional DC motor connected at Atmega8.<br /><br />The initial pwm pulse is of 20KHz (50us) and later I have to set it to 4ms pulse. I can change the duty and check the pulse period (its close to 4ms) but not accurate. How can I set the condition to get the pulse of exact 4ms.<br />plz suggest. Thanks.Ashhttps://www.blogger.com/profile/16096909457683803266noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-15155907842497455302016-10-06T14:35:02.160+02:002016-10-06T14:35:02.160+02:00Hello, thank you for your feedback. About the duty...Hello, thank you for your feedback. About the duty cicle question, it depends on which driver are you using, for the PWM (non bitbang version) you have to setup the timer registers, you can find settings explanation in the header file. You have to consider the duty part and the pwm frequency.<br />The ocrtop settings formula is a mapping. You are basically mapping orc from min to max, given a speed from 1 to 100. Take a look here for furhter info: https://www.arduino.cc/en/Reference/MapDavide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-43227236605435633642016-10-06T11:04:55.074+02:002016-10-06T11:04:55.074+02:00Hello Davide,
Good to see your post. Its quite he...Hello Davide,<br /><br />Good to see your post. Its quite helpful. I have some doubt, please help me to get clear this..<br /><br />In the case of Forward/Reverse motion of motor, how can I set the duty to achieve 4ms pulse.<br /><br />Also I didnt understand this formula: <br />orctop = ((ICR1 - top_min) * (speed - 1)) / ((100 - 1) + top_min);<br />Is the speed means"duty" ?<br /><br />Please suggest. Thanks.Ashhttps://www.blogger.com/profile/16096909457683803266noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-33359921089227101782015-05-11T13:34:30.796+02:002015-05-11T13:34:30.796+02:00This comment has been removed by a blog administrator.Anonymoushttps://www.blogger.com/profile/00534156518596562727noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-45259955813095777812015-04-16T00:25:22.622+02:002015-04-16T00:25:22.622+02:00You can use the ICP of avr, or the external interr...You can use the ICP of avr, or the external interrupt input. There are a few posts on avrfreaks forum about reading PPM.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-21946799780781420062015-04-15T22:48:15.464+02:002015-04-15T22:48:15.464+02:00i have got 6 channel 2.4ghz flight controller of f...i have got 6 channel 2.4ghz flight controller of flysky which sends PPM signal..and i think L298 is a PWM based ic...how to control now??Anonymoushttps://www.blogger.com/profile/07422612913060037503noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-46605305275332866762015-04-15T22:44:37.081+02:002015-04-15T22:44:37.081+02:00i have got 6 channel 2.4ghz flight controller of f...i have got 6 channel 2.4ghz flight controller of flysky which sends PPM signal..how can i control speed and direction of 2 dc motor?Anonymoushttps://www.blogger.com/profile/07422612913060037503noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-38904344801471836152015-04-15T21:08:01.931+02:002015-04-15T21:08:01.931+02:00Hello have to write your own protocol, that reads ...Hello have to write your own protocol, that reads byte from UART, then interpreter those byte and use a DC motor library like this http://davidegironi.blogspot.it/2013/11/driving-dc-motor-using-software-pwm.html to drive the motors.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-38997701416385357872015-04-14T21:34:09.282+02:002015-04-14T21:34:09.282+02:00how can i control speed and direction of 2 DC Moto...how can i control speed and direction of 2 DC Motors using atmega328 and L298N Driver by Tx and Rx??Anonymoushttps://www.blogger.com/profile/07422612913060037503noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-56380403422030926912014-08-14T17:54:41.569+02:002014-08-14T17:54:41.569+02:00You have got an email with a schematics i've j...You have got an email with a schematics i've just found googling. It may be what you are looking for.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-83691798047870015222014-08-14T17:48:54.899+02:002014-08-14T17:48:54.899+02:00your comment dosen't helping me in making the ...your comment dosen't helping me in making the circuit....:(Anonymoushttps://www.blogger.com/profile/07316276205501859295noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-46773522782881903982014-08-14T11:55:13.797+02:002014-08-14T11:55:13.797+02:00Hello, you just have to select two free port of yo...Hello, you just have to select two free port of your microcontroller, for each motor, setup that ports in the header file of the library. Then connect the two port stright in your motor driver (note: check your motor driver to be shure you can connect that type of input, as example: sn754410 support this type of input). You may also search online for that type of connection.<br />Additional note: please do not remove your comment with my reply, or my reply to comments are useless for other users.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-33622424493195119992014-08-14T11:51:23.180+02:002014-08-14T11:51:23.180+02:00in this diagram i can't understand the connect...in this diagram i can't understand the connections,,,,,please upload the protious diagramAnonymoushttps://www.blogger.com/profile/07316276205501859295noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-40682389357214813742014-08-14T11:48:16.091+02:002014-08-14T11:48:16.091+02:00i done compiling.....now sir i want to use atmega ...i done compiling.....now sir i want to use atmega 16,,,,the diagrm is not clear...will u please upload the circuit with proper connections<br />Anonymoushttps://www.blogger.com/profile/07316276205501859295noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-74800903026444551802014-08-14T09:59:20.830+02:002014-08-14T09:59:20.830+02:00To me, the most simple way to compile, is Eclipse,...To me, the most simple way to compile, is Eclipse, with AVR plugin installed, and avrgcc as compiler.<br />Search for a tutorial, you can find a lot.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-75973338743662397262014-08-14T09:53:43.987+02:002014-08-14T09:53:43.987+02:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/07316276205501859295noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-60477680084884640502014-03-05T15:35:35.771+01:002014-03-05T15:35:35.771+01:00your are welcome.
you can find a more advanced sol...your are welcome.<br />you can find a more advanced solution (with slow start / stop for example) here: http://davidegironi.blogspot.it/2013/11/driving-dc-motor-using-software-pwm.htmlDavide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-62076526292678228502014-03-05T03:04:04.669+01:002014-03-05T03:04:04.669+01:00Thank you, i really appreciate your help.
May God ...Thank you, i really appreciate your help.<br />May God bless you.Anonymoushttps://www.blogger.com/profile/17449688481373093764noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-26503196424711825422014-03-03T10:02:43.036+01:002014-03-03T10:02:43.036+01:00hello and thank you,
use the schematics as above, ...hello and thank you,<br />use the schematics as above, but connect RA2 and RA3 from L293D to two port of your ATmega, then you have to change ports in the config file (.h) or the library you are using.Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-70285606159909213172014-03-03T02:34:01.800+01:002014-03-03T02:34:01.800+01:00Your Tutorial is very instructive. It helps me a l...Your Tutorial is very instructive. It helps me a lot. Can you please post the wiring connection of the Atmega16 interfacing with the L293D?Anonymoushttps://www.blogger.com/profile/17449688481373093764noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-70109379129048801912014-02-25T16:38:50.909+01:002014-02-25T16:38:50.909+01:00happy to ear this :)
tks!happy to ear this :)<br />tks!Davide Gironihttps://www.blogger.com/profile/16366076989473118278noreply@blogger.comtag:blogger.com,1999:blog-6100511197805579796.post-21000412531976050702014-02-25T16:10:45.267+01:002014-02-25T16:10:45.267+01:00great article..thank you very much :))
- Flexible...great article..thank you very much :))<br /><br />- <a href="http://www.electricmotorsolutions.com" rel="nofollow">Flexible Shaft Couple</a>Anonymoushttps://www.blogger.com/profile/09203813696371637254noreply@blogger.com