Académique Documents
Professionnel Documents
Culture Documents
Prepa
Prepa
a
a
sinusoi triang
dal
ular
0
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
tiemp
o en
ms
voltaje
triang
ular
pwm
triang
ular %
pwm
0-255
triang
ular
amplit
ud
voltaj
e
senoi
dal
pwm
senoi
dal %
pwm
0-255
senoi
dal
0,0
2,3
2,50
50,00
128
0,4
20
2,3
2,6
53
135
0,8
16
41
2,3
2,8
56
142
1,2
24
61
2,3
2,9
59
149
1,6
32
82
2,3
3,1
61
157
2,0
40
102
2,3
3,2
64
164
2,4
48
122
2,3
3,3
67
171
2,8
56
143
2,3
3,5
70
177
3,2
64
163
2,3
3,6
72
184
3,6
72
184
2,3
3,7
75
190
4,0
80
204
2,3
3,9
77
196
4,4
88
224
2,3
4,0
79
202
4,8
96
245
2,3
4,1
81
208
4,8
96
245
2,3
4,2
84
213
4,4
88
224
2,3
4,3
85
218
4,0
80
204
2,3
4,4
87
222
3,6
72
184
2,3
4,4
89
227
3,2
64
163
2,3
4,5
90
230
2,8
56
143
2,3
4,6
92
234
2,4
48
122
2,3
4,6
93
237
2,0
40
102
2,3
4,7
94
239
1,6
32
82
2,3
4,7
95
241
1,2
24
61
2,3
4,8
95
243
0,8
16
41
2,3
4,8
96
244
0,4
20
2,3
4,8
96
245
0,0
2,3
4,8
96
245
0,4
20
2,3
4,8
96
245
0,8
16
41
2,3
4,8
96
244
1,2
24
61
2,3
4,8
95
243
1,6
32
82
2,3
4,7
95
241
2,0
40
102
2,3
4,7
94
239
2,4
48
122
2,3
4,6
93
237
2,8
56
143
2,3
4,6
92
234
3,2
64
163
2,3
4,5
90
230
3,6
72
184
2,3
4,4
89
227
4,0
80
204
2,3
4,4
87
222
4,4
88
224
2,3
4,3
85
218
4,8
96
245
2,3
4,2
84
213
4,8
96
245
2,3
4,1
81
208
4,4
88
224
2,3
4,0
79
202
0,1666
6
0,3333
2
0,4999
8
0,6666
4
0,8333
0,9999
6
1,1666
2
1,3332
8
1,4999
4
1,6666
1,8332
6
1,9999
2
2,1665
8
2,3332
4
2,4999
2,6665
6
2,8332
2
2,9998
8
3,1665
4
3,3332
3,4998
6
3,6665
2
3,8331
8
3,9998
4
4,1665
4,3331
6
4,4998
2
4,6664
8
4,8331
4
4,9998
5,1664
6
5,3331
2
5,4997
8
5,6664
4
5,8331
5,9997
6
6,1664
2
6,3330
8
6,4997
4
ej
e
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
2,
5
pwm
salida
compara
cion
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
2,5
2,5
2,5
2,5
2,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
3,5
2,5
2,5
2,5
2,5
Programa en bascom
$regfile = "m164pdef.dat"
$crystal = 8000000
Dim Pwm_s As Byte
Dim Con_s As Byte
Dim Pwm_t As Byte
Dim Con_t As Byte
Ancho = 88
Tcnt0 = 173
Tcnt2 = Ancho
Con_s = 0
Pwm_s = 0
Con_t = 0
Pwm_t = 0
Pwm1b = Pwm_t
Do
On Int0 Aumenta
On Int1 Disminuye
Enable Timer0
Enable Timer2
Enable Int0
Enable Int1
Enable Interrupts
Tiempo_s:
Tcnt0 = 173
Con_s = Con_s + 1
If Con_s >= 25 Then
Con_s = 0
End If
'*********************************
Config Timer1 = Pwm , Pwm = 8 , Compare
A Pwm = Clear Down , Compare B Pwm =
Clear Down , Prescale = 1
Return
Tiempo_t:
Disminuye:
Tcnt2 = Ancho
Con_t = Con_t + 1
Return
Pwm_t = Lookup(con_t , T_triangular)
Pwm1b = Pwm_t
Return
Aumenta:
If Ancho >= 244 Then
Ancho = 255
Else
Ancho = Ancho + 5
End If
T_senoidal:
Data 128 , 157 , 184 , 208 , 227 , 239 , 245 ,
243 , 234 , 218 , 196 , 171 , 142 , 113 , 84 ,
59 , 37 , 21 , 12 , 10 , 16 , 28 , 47 , 71 , 98 ,
127
T_triangular:
Data 0 , 20 , 41 , 61 , 82 , 102 , 122 , 143 ,
163 , 184 , 204 , 224 , 245 , 245 , 224 , 204 ,
184 , 163 , 143 , 122 , 102 , 82 , 61 , 41 , 20
Diseo de filtros
Para la seal triangular
Circuito a implementar
A
B
C
D
R5
4k7
aumenta
R6
4k7
disminuye
U1
C5
C6
1nF
1nF
1
2
3
4
5
6
7
8
C1
0.022uF
aumenta
disminuye
U3
OP1P
R1
R2
15k
8.2k
14
15
16
17
18
19
20
21
32
30
9
PB0/XCK0/T0/PCINT8
PB1/T1/CLKO/PCINT9
PB2/AIN0/INT2/PCINT10
PB3/AIN1/OC0A/PCINT11
PB4/SS/OC0B/PCINT12
PB5/MOSI/PCINT13
PB6/MISO/PCINT14
PB7/SCK/PCINT15
PD0/RXD0/PCINT24
PD1/TXD0/PCINT25
PD2/INT0/RXD1/PCINT26
PD3/INT1/TXD1/PCINT27
PD4/OC1B/XCK1/PCINT28
PD5/OC1A/PCINT29
PD6/ICP/OC2B/PCINT30
PD7/OC2A/PCINT31
AREF
AVCC
RESET
0.01uF
C3
B
C
0.47uF
U2
OP1P
R3
R4
12k
6.8k
C4
0.22uF
PC0/SCL/PCINT16
PC1/SDA/PCINT17
PC2/TCK/PCINT18
PC3/TMS/PCINT19
PC4/TDO/PCINT20
PC5/TDI/PCINT21
PC6/TOSC1/PCINT22
PC7/TOSC2/PCINT23
XTAL1
XTAL2
ATMEGA164P
C2
PA0/ADC0/PCINT0
PA1/ADC1/PCINT1
PA2/ADC2/PCINT2
PA3/ADC3/PCINT3
PA4/ADC4/PCINT4
PA5/ADC5/PCINT5
PA6/ADC6/PCINT6
PA7/ADC7/PCINT7
40
39
38
37
36
35
34
33
22
23
24
25
26
27
28
29
13
12