hola a todos :estoy con ganas de hacer un programa que mueva un motor cc con pwm la idea es usar 4 pulsadores 2 para la direccion y minima velocidad , 1 para una velocidad media y otro para velocidad maxima hice esto :
,
define osc 4
buton_ant var porta.0
buton_hor var porta.1
buton_100 var porta.2
buton_50 var porta.3
'-----
trisa = %11111111
trisb = %00000000
'----
loop:
if (buton_hor =1) and (buton_ant=1) and ( buton_100 =1) and (buton_50 =1) then loop
if (buton_hor =0) and (buton_ant=1) and ( buton_100 =1) and (buton_50 =1) then horario
if (buton_hor =0) and (buton_ant=1) and ( buton_100 =1) and (buton_50 =0) then horario50
if (buton_hor =0) and (buton_ant=1) and ( buton_100 =0) and (buton_50 =1) then horario100
if (buton_ant=0) and (buton_hor =1) and( buton_100 =1) and (buton_50 =1) then antihorario
if (buton_ant=0) and (buton_hor =1) and( buton_100 =1) and (buton_50 =0) then antihorario50
if (buton_ant=0) and (buton_hor =1) and( buton_100 =0) and (buton_50 =1) then antihorario100
'__
horario:
pwm portb.1,65,1
goto loop
'_----
horario50:
pwm portb.1,127,1
goto loop
'______
horario100:
pwm portb.1,255,1
gotoloop
'____
antihorario:
pwm portb.0,65,1
goto loop
'_____
antihorario50:
pwm portb.0,127,1
goto loop
'____
antihorario100:
pwm portb.0,255,1
goto loop
'________
'
lo monte en el protoboard y no funca por alguna razon se inicia directamente con el motor andando a media velocidad antihorario
no se porque...
como se habran dado cuenta apenas me acerco al titulo de principiante ja ja me podrian ayudar con esto?
y tengo mas preguntas:
bajar la velocidad con pwm del modo que lo hago disminuyo mucho el torque? (porque a mi me parece que si) hay otra manera?
hay otr forma de de hacer este programa con menos " if" usando otra instruccion o algo asi ?
muchas gracias por todo y espero su respuesta .