Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
podria medir la temperatura interior del auto con un lm35???
Si, si puedes... bueno el lm35 si puede...
Mira todo lo que necesite para aprende a usar el USB esta aqui
necesitas el microcodestudio y el Easy HID (tambien en el microcode aparece)...
si tienes dudas comenta...
lo necesito muy urgente
hay manera de controlar los dos puertos a la vez?
Queres que suba lo que estoy haciendo?
@ DEVICE MCLR_ON, hs_osc, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF
define osc20
CMCON=7
TRISB.3 = 0 ' RB.3=PWM output
PR2 = 25 ' Set PWM for approximately 38KHz
CCPR1L = 1 ' Set PWM Duty-Cycle to 50%
CCP1CON = %00001100 ' Mode select = PWM
T2CON = %00000100 ' Timer2 ON + 1:1 prescale
pote var byte
inicio:
pot porta.0,255,pote
hpwm 2,pote,38000
goto inicio
end
¿se puede sacar PWM por tres pines de un pic16f628A utilizando el comando HPWM?
Some devices, such as the PIC18C452, have alternate pins that may be used for HPWM. The following DEFINEs allow using these pins:
Algunos Dispositivos, como el 18c452, tienen pines alternos que podrian ser usados para el HPWM.. las siguientes sentencias permiten el uso en esos pines:
DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
DEFINE CCP1_BIT 2 'Hpwm 1 pin bit
DEFINE CCP2_REG PORTC 'Hpwm 2 pin port
DEFINE CCP2_BIT 1 'Hpwm 2 pin bit
The following DEFINEs specify which timer, 1 or 2, to use with PWM channel 2 and PWM channel 3 for the PIC17C7xx devices. The default is timer 1 if no DEFINE is specified.
Las siguinetes sentencias especifican cual temporizador, 1 o 2, sera usado con el canal 2 y 3 del pwm para los dispositivos pic 17c7xx.El valor predeterminado es el temporizador 1 si no es especificado.
DEFINE HPWM2_TIMER 1 'Hpwm 2 timer select
DEFINE HPWM3_TIMER 1 'Hpwm 3 timer select
Example
Ejemplo
HPWM 1,127,1000 ' Send a 50% duty cycle PWM signal at 1kHz
HPWM 1,64,200 ' Send a 25% duty cycle PWM signal at 2kHz
@ DEVICE MCLR_OFF, hs_osc, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF
define osc20
CMCON=7 'desactivo los comparadores del puerto A
TRISA=%11111111 'todo el puerto A como salidas
porta=%11111111 'el puerto A a nivel 0
trisb=%00000000 'RB0 a RB2 salidas y RB3 a RB6 como entradas
portb=%00000000
uno: '1
pwm portb.0,100,1
high portb.1
high portb.2
low portb.3
low portb.4
high portb.5
low portb.6
low portb.7
pause 1
'2
pwm portb.0,100,1
high portb.1
high portb.2
low portb.3
low portb.4
low portb.5
high portb.6
low portb.7
pause 1
'3
high portb.0
pwm portb.1,100,1
high portb.2
low portb.3
low portb.4
low portb.5
high portb.6
low portb.7
pause 1
'4
high portb.0
pwm portb.1,100,1
high portb.2
low portb.3
high portb.4
low portb.5
low portb.6
low portb.7
pause 1
'5
high portb.0
high portb.1
pwm portb.2,100,1
low portb.3
high portb.4
low portb.5
low portb.6
low portb.7
pause 1
'6
high portb.0
high portb.1
pwm portb.2,100,1
low portb.3
low portb.4
high portb.5
low portb.6
low portb.7
pause 1
goto uno
Pue si estaria bien para que aprendamos todos...
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [prof.martintorres@educ.ar] *
'* Notice : Copyright (c) 2011 [® MT&F ©2011-12 ] *
'* : All Rights Reserved *
'* Date : 08/07/2011 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
;****************************************************************
@ device HS_OSC
DEFINE OSC 20
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 50
DEFINE LCD_DREG PORTD
DEFINE LCD_BITS 4
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 2
LCDOut $fe, $48, $00, $00, $00, $00, $00, $00, $1F, $1F 'Figura 1.
LCDOut $fe, $50, $00, $00, $00, $00, $1F, $1F, $1F, $1F 'Figura 2.
LCDOut $fe, $58, $00, $00, $1F, $1F, $1F, $1F, $1F, $1F 'Figura 3.
LCDOut $fe, $60, $1F, $1F, $1F, $1F, $1F, $1F, $1F, $1F 'Figura 4.
TRISA = 1
ADCON1 = 0
ADCON0 = %11000001
TRISB = %11111111
TRISC = %00000000
TRISD = %00000000
boton_ctrlRPM var PORTB.0
botonSUBIR var PORTB.2
botonBAJAR var PORTB.3
botonMODO var PORTB.1
botonLUZ var PORTB.5
ent_RPM var PORTB.4
relay1 var PORTC.4
relay2 var PORTC.5
led1 var PORTC.6
led2 var PORTC.7
Res Var Word
Res1 var word
Volts1 Var Word
Volts2 Var Word
Volts3 Var Word
Volts4 Var Word
nivel var byte
c var byte
temp VAR byte
Cnt VAR word
RPMalta var word
RPMbaja var word
RPMaviso var word
x var byte
x1 var byte
revo var word
revo1 var word
revo2 var word
revoalta var word
revobaja var word
disparo var byte
Conv1 Con 19
Conv2 Con 53
linea1 con $80
linea2 con $C0
eeprom 0, [22,26]
;***********************************************************************
;*************************** INICIO - MENU *****************************
;***********************************************************************
Inicio: ; inicia apagado, si no hay accion a los 5 seg, pasa a espejo
LCDOUT $FE, 1
LCDOUT "MT&F TeamRacing"
LCDOut $fe,$C0, "Picadas Comodoro"
pause 1000
Inicio3:
pause 100
LCDOUT $FE, 1
LCDOUT " CLMT v3.0 "
LCDOut $fe,$C0, "Sistema APAGADO"
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,inicio2
temp = 0
;if botonmodo = 0 then inicio2
low led1 : low relay2
goto inicio3
Inicio2:
pause 100
LCDOUT $FE, 1
LCDOUT " Seleccione MODO"
LCDOut $fe,$C0
LCDOUT "y pres ENTER"
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,menu1
temp = 0
BUTTON botonbajar, 0, 255, 0, temp, 1,menu2
temp = 0
goto inicio2
menu1:
toggle led1
pause 100
LCDOUT $FE, 1
LCDOUT " Entrar en MODO"
LCDOut $fe,$C0
LCDOUT "HALL METRE?"
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,menu2
temp = 0
BUTTON botonbajar, 0, 255, 0, temp, 1,menu3
temp = 0
IF botonMODO = 0 THEN Hall_metre
goto menu1
menu2:
toggle led1
pause 100
LCDOUT $FE, 1
LCDOUT " Entrar en MODO"
LCDOut $fe,$C0
LCDOUT "MAPEO MANUAL?"
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,menu3
temp = 0
BUTTON botonbajar, 0, 255, 0, temp, 1,menu1
temp = 0
IF botonMODO = 0 THEN manual
goto menu2
menu3:
toggle led1
pause 100
LCDOUT $FE, 1
LCDOUT " Entrar en MODO"
LCDOut $fe,$C0
LCDOUT "Control de RPM?"
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,menu1
temp = 0
BUTTON botonbajar, 0, 255, 0, temp, 1,menu2
temp = 0
IF botonMODO = 0 THEN LOOP1
goto menu3
;*************************************************************************
;**************** rutina para visualizar valor real en la ****************
;************* sonda lambda, con mensajes de estado de mezcla ************
;*************************************************************************
Hall_metre:
low led1
LCDOUT $FE, 1
lcdout " MODO VISOR"
LCDOUT $fe,$C0,"HALL METRES"
pause 1500
Hall_metre1:
if botonMODO = 0 then Inicio
ADCIN 1, Res1
Volts3 = Res1 * Conv1
Volts4 = Res1 * Conv2
Volts4 = Volts4 / 100
Volts3 = Volts3 + Volts4
if volts3 > 800 then nivel5E
if volts3 > 600 then nivel4E
if volts3 > 400 then nivel3E
if volts3 > 200 then nivel2E
if volts3 < 200 then nivel1E
goto Hall_metre1
;*************************************************************************
;**************** rutina para poner en salida valor deseado **************
;************* mas lectura de valor verdadero leido por lambda ***********
;*************************************************************************
Manual:
low led1
LCDOUT $FE, 1
lcdout " Atencion MODO!!"
LCDOUT $fe,$C0,"MAPEO MANUAL"
pause 1500
LCDOUT $FE, 1
nivel = 0
high relay2
Manual1:
pause 100
if botonSUBIR = 0 then gosub subir
if botonbajar = 0 then gosub bajar
if botonMODO = 0 then Inicio
LCDOUT $fe, 1
ADCIN 0, Res
ADCIN 1, Res1
Volts1 = Res * Conv1
Volts2 = Res * Conv2
Volts2 = Volts2 / 100
Volts1 = Volts1 + Volts2
LCDOUT $fe, 2 ,"VS= ",DEC4 Volts1 , "mV"
Volts3 = Res1 * Conv1
Volts4 = Res1* Conv2
Volts4 = Volts4 / 100
Volts3 = Volts3 + Volts4
LCDOUT $fe, $C0,"VE= ",DEC4 Volts3 , "mV"
gosub graficonivel
HPWM 1,nivel,1000
;PWM PORTC.2,nivel,100
goto manual1
subir:
IF Volts1 > 1000 THEN aviso
nivel = nivel +1
return
bajar:
if Volts1 < 50 then aviso
nivel = nivel -1
return
aviso:
HIGH LED1
pause 800
low led1
goto manual1
;***************************************************************
;*********** rutina para ver valor de entrada LAMBDA ***********
;*************** mas lectura de salida generada ****************
;***************************************************************
LOOP1:
low led1
LCDOUT $FE, 1
lcdout " Atencion - Modo"
LCDOUT $fe,$C0,"Control RPM"
pause 1500
nivel= 1
LCDOUT $FE, 1
LOOP:
pause 100
LCDOUT $FE,1," MOD=menu 1=CRPM"
LCDOUT $FE,linea2,"(+)=Vis (-)=Prog"
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,visor
temp = 0
BUTTON botonbajar, 0, 255, 0, temp, 1,PM_Prog
temp = 0
BUTTON botonmodo, 0, 255, 0, temp, 1,Inicio2
temp = 0
GOTO LOOP
;**---------------------------------------------------------**
;**---------------------------------------------------------**
;**---------------------------------------------------------**
visor:
low led1
LCDout $FE,1," Modo Visor"
pause 1500
nivel= 1
LCDOUT $FE, 1
visor1:
count portb.4, 125, revo
revo= (revo / 4)/2 * 240
LCDOUT $FE,1," RPM=",dec revo
lcdout $FE,$c0,"C=",dec RPMalta," CL=",DEC RPMbaja
pause 100
temp = 0
BUTTON botonsubir, 0, 255, 0, temp, 1,loop
temp = 0
BUTTON botonbajar, 0, 255, 0, temp, 1,loop
temp = 0
BUTTON botonmodo, 0, 255, 0, temp, 1,Inicio2
temp = 0
if boton_ctrlRPM = 0 then control_rpm
IF revo2 > RPMalta then corte1
IF revo2 > revoalta then corte1
GOTO visor1
control_rpm:
count portb.4, 125, revo
revo1= (revo / 4)
revo2= (revo1/2)* 240
LCDout $FE,1,"CONTROL LARGADA"
pause 100
if botonMODO = 0 then Inicio
if boton_ctrlRPM = 1 then visor1
if revo2 > RPMbaja then
high relay1
pause 250
low relay1
endif
if revobaja > RPMbaja then
high relay1
pause 250
low relay1
endif
goto control_rpm
;**---------------------------------------------------------**
;**---------------------------------------------------------**
;**---------------------------------------------------------**
corte1:
LCDout $FE,1,"CORTE"
For disparo= 1 to 3
high relay1
pause 500
low relay1
next
goto visor1
;****************************************************************
;********************** Seccion de Prog RPM *********************
;****************************************************************
PM_Prog:
RPMalta = 8000
RPMbaja = 3000
gosub soltar
;**---------------------------------------------------------**
;**---------------------------------------------------------**
;**---------------------------------------------------------**
grabar1:
lcdout $FE,1,"Prog Corte RPM"
lcdout $FE,$c0,"Corte=",dec RPMalta,"RPM"
pause 100
if botonbajar = 0 then restar2
if botonsubir = 0 then sumar2
if botonmodo = 0 then grabarB
goto grabar1
restar2:
RPMalta = RPMalta - 5
goto grabar1
sumar2:
RPMalta = RPMalta + 5
goto grabar1
grabarB:
gosub soltar
write 0, RPMalta
revoalta = RPMalta
;**---------------------------------------------------------**
;**---------------------------------------------------------**
;**---------------------------------------------------------**
grabar3:
lcdout $FE,1,"Prog Ctrl larg"
lcdout $FE,$c0,"Corte=",dec RPMbaja,"RPM"
pause 100
if botonbajar = 0 then restar3
if botonsubir = 0 then sumar3
if botonmodo = 0 then grabarC
goto grabar3
restar3:
RPMbaja = RPMbaja - 5
goto grabar3
sumar3:
RPMbaja = RPMbaja + 5
goto grabar3
grabarC:
gosub soltar
write 3, RPMbaja
revobaja = RPMbaja
goto LOOP
soltar:
high led1
pause 150
low led1
soltar2:
If botonbajar = 0 then soltar2
If botonsubir = 0 then soltar2
If botonmodo = 0 then soltar2
pause 100
return
;***************************************************************
;********************** Barra grafica *************************
;***************************************************************
graficonivel:
if volts3 > 800 then gosub nivel5
if volts3 > 600 then gosub nivel4
if volts3 > 400 then gosub nivel3
if volts3 > 200 then gosub nivel2
if volts3 < 200 then gosub nivel1
return
nivel1:
LCDOut $fe,$CB, 1
return
nivel2:
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
return
nivel3:
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
return
nivel4:
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
LCDOut $fe,$CE, 4
return
nivel5:
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
LCDOut $fe,$CE, 4
LCDOut $fe,$CF, 4
return
nivel1E:
pause 100
LCDOUT $FE, 1
LCDOUT $fe, $C0,"VE= ",DEC4 Volts3 , "mV"
LCDOut $fe,2,"Mezcla muy POBRE"
LCDOut $fe,$CB, 1
goto Hall_metre1
nivel2E:
pause 100
LCDOUT $FE, 1
LCDOUT $fe, $C0,"VE= ",DEC4 Volts3 , "mV"
LCDOut $fe,2,"Mezcla POBRE"
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
goto Hall_metre1
nivel3E:
pause 100
LCDOUT $FE, 1
LCDOUT $fe, $C0,"VE= ",DEC4 Volts3 , "mV"
LCDOut $fe,2,"Mezcla BUENA"
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
goto Hall_metre1
nivel4E:
pause 100
LCDOUT $FE, 1
LCDOUT $fe, $C0,"VE= ",DEC4 Volts3 , "mV"
LCDOut $fe,2,"Mezcla RICA"
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
LCDOut $fe,$CE, 4
goto Hall_metre1
nivel5E:
pause 100
LCDOUT $FE, 1
LCDOUT $fe, $C0,"VE= ",DEC4 Volts3 , "mV"
LCDOut $fe,2,"Mezcla muy RICA"
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
LCDOut $fe,$CE, 4
LCDOut $fe,$CF, 4
goto Hall_metre1
LUZ:
Toggle led2
Pause 500
return
end