View previous topic :: View next topic |
Author |
Message |
mastermindjp
Joined: 18 Dec 2012 Posts: 51 Location: INDIA
|
Posted: Sat Oct 20, 2018 12:31 pm Post subject: Problem while using 3 ch PWM |
|
|
Hello friends,
i am doing a project, which requires to control three DC motors, for which i am using three PWM ch of ATMEGA32 out of 4, PWM0, PWM1A and PWM1B. Control of DC motor through PWM0 working fine, but PWM1A and PWM1B are not working at all kindly help and guide.
Here is the code:
Code: | $crystal = 16000000
$hwstack = 32
$regfile = "m32def.dat"
$swstack = 10
$framesize = 40
Config Timer0 = Pwm , Compare Pwm = Clear Down , Prescale = 1024
Config Timer1 = Pwm , Pwm = 10 , Compare B Pwm = Clear Down , Compare A Pwm = Clear Down , Prescale = 1024
Config Adc = Single , Prescaler = Auto
Stop Adc
Config Portd.0 = Output
Config Portd.1 = Output
Config Portd.2 = Output
Config Portd.3 = Output
Config Portd.4 = Output
Config Portd.5 = Output
Config Portb.2 = Output
Config Portb.3 = Output
Config Portb.4 = Output
Dim P1 As Word , P2 As Word , P3 As Word , P4 As Word
Dim P5 As Word , P6 As Word , P7 As Word , P8 As Word
Start Adc
Do
P1 = Getadc(0)
P2 = Getadc(1)
P3 = Getadc(2)
If P1 < 580 And P1 > 480 Then
Portb.2 = 0
Portb.4 = 0
End If
If P2 < 520 And P2 > 380 Then
Portd.0 = 0
Portd.1 = 0
End If
If P3 < 510 And P1 > 480 Then
Portd.2 = 0
Portd.3 = 0
End If
P4 = Getadc(3)
If P4 < 790 Then P4 = 790
P5 = Getadc(4)
'If P5 < 790 Then P5 = 790
P6 = Getadc(5)
'If P6 < 790 Then P6 = 790
P7 = Getadc(6)
P8 = Getadc(7)
If P1 > 580 Then
Portb.2 = 1
Portb.4 = 0
Ocr0 = P4
End If
If P1 < 480 Then
Portb.2 = 0
Portb.4 = 1
Ocr0 = P4
End If
If P2 < 380 Then
Portd.0 = 1
Portd.1 = 0
Pwm1a = P5
End If
If P2 > 520 Then
Portd.0 = 0
Portd.1 = 1
Pwm1a = P5
End If
If P3 < 480 Then
Portd.2 = 1
Portd.3 = 0
Pwm1b = P6
End If
If P3 > 580 Then
Portd.2 = 0
Portd.3 = 1
Pwm1b = P6
End If
Loop
|
Thank you
(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.8.1 ) _________________ We are not innovating, we are just manipulating innovations done by Mother Nature....... |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
|
Back to top |
|
|
mastermindjp
Joined: 18 Dec 2012 Posts: 51 Location: INDIA
|
Posted: Fri Oct 26, 2018 2:04 pm Post subject: |
|
|
Hello friends,
Thanks for the reply and suggestions, yes it was a Hardware issue, solved it and working flawlessly..
Thanks once again _________________ We are not innovating, we are just manipulating innovations done by Mother Nature....... |
|
Back to top |
|
|
|
|
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
|
|