Posted: Thu Jul 27, 2006 2:39 am Post subject: DC Motor control
am trying to control the speed of 2 dc motors on my robot. I am using an Atmega 168 and 2 L9110 h-bridges to drive them. I know that I can use timer1 for PWM but the problem is the pins that control the motors are connected to pd4 pin, pd5 pin, pd6 pin, pd7 pin. So how do I get PWM to work on pd5 pin and pd6 pin. I know that those pins can be changed to timer0. But I don’t know how to do that in Bascom nor do I know how to set timer0 to PWM.
Joined: 24 Jun 2004 Posts: 190 Location: 127.0.0.1
Posted: Tue Nov 07, 2006 1:03 pm Post subject:
Well you could use something like this:
Code:
ConfigTimer1=Timer , Prescale =64 OnTimer1 Myisr 'Op interrupt ga naar myisr EnableTimer1 startTimer1
..
..
..
Myisr: setportd.x
Waitms10 resetportd.x
Return
It's pretty dirty.. But it could give you a head start.. You have to look in the help files for further help to get this to fit you application..
This is a bit of code in a huge programm that generated a 0.5 seconds interrupt. By using a counter it counted till a few minutes and then released a relay. But in the meanwhile it had to check constant if there where no IR instructions.. So working on interupts helped me out.. _________________ Bascom AVR 1.11.8.8 full version
STK500 Programmer
ISP Programmer
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 You cannot attach files in this forum You cannot download files in this forum