Oshonsoft

Páginas: 10 (2497 palabras) Publicado: 3 de diciembre de 2010
Define CONF_WORD = 0x3f72
Define CLOCK_FREQUENCY = 12

Symbol t_right = PORTD.7
Symbol t_down = PORTD.6
Symbol t_up = PORTD.5
Symbol t_left = PORTD.4
Symbol ledcharge = PORTD.2
Symbol leddischarge = PORTD.3
Symbol charge = PORTC.2
Symbol discharge = PORTC.1
Symbol i2cclock = PORTC.3
Symbol i2cdata = PORTC.4

Symbol ltc_clk = PORTE.0
Symbol ltc_dout = PORTE.1
Symbol ltc_cs =PORTE.2

Define GLCD_DREG = PORTB
Define GLCD_RSREG = PORTA
Define GLCD_RSBIT = 1
Define GLCD_EREG = PORTC
Define GLCD_EBIT = 5
Define GLCD_RWREG = PORTA
Define GLCD_RWBIT = 5
Define GLCD_CS1REG = PORTD
Define GLCD_CS1BIT = 0
Define GLCD_CS2REG = PORTC
Define GLCD_CS2BIT = 0

Const c_right = 1
Const c_up = 2
Const c_down = 3
Const c_left = 4

Dim vin As Word
Dim i As Byte
Dim j AsByte
Dim k As Byte
Dim x As Byte
Dim an0 As Word
Dim vmod As Word
Dim vfinal As Word

Dim v(13) As Word
Dim vmax As Word
Dim vmaxdelay As Byte
Dim vmaxnum As Byte

Dim finish As Bit
Dim address As Word
Dim seconds As Byte
Dim minutes As Word
Dim hours As Byte

Dim voltage As Word
Dim voltage1 As Word
Dim voltage2 As Word
Dim cnt As Word
Dim sample As Word

Dim program AsByte
Dim phase As Byte
Dim key As Byte

Dim dischargelimit As Word
Dim signalfiltertype As Byte
Dim peakgap As Byte
Dim peakdetect As Byte
Dim mintime As Byte
Dim minvalue As Word
Dim maxtime As Word

Dim yy1(48) As Word
Dim yy2(48) As Word
Dim yymin As Word
Dim yymax As Word
Dim yy As Word

Dim samplesnum As Word
Dim yyymin As Word
Dim yyymax As Word
Dim yyy As Word
Dim xxx AsWord
Dim xxxstep As Byte
Dim templong As Long

PORTA = 0
PORTB = 0
PORTC = 0
PORTD = 0
PORTE = 0
TRISD.2 = 0
TRISD.3 = 0
TRISC.2 = 0
TRISC.1 = 0
TRISE.0 = 0
TRISE.2 = 0
ltc_cs = 1
AllDigital
ADCON1 = 0x0f
Hseropen 19200
GLcdinit
WaitMs 1000

Gosub loadparameters

newprogram:
Gosub welcome
Gosub selectprogram
If program = 1 Then Gosub prog_charge
If program = 2 ThenGosub prog_discharge
If program = 3 Then Goto prog_cycle
If program = 4 Then Goto prog_setup
If program = 5 Then Gosub prog_setupdefaults
If program = 6 Then Goto prog_memory
Goto newprogram
End

welcome:
GLcdclear
GLcdposition 0, 4
GLcdwrite "OshonSoft."
GLcdposition 8, 0
GLcdwrite "com"
GLcdposition 1, 4
GLcdwrite "NiCd/NiMH "
GLcdposition 9, 0
GLcdwrite "Cycler"
GLcdposition 2, 4GLcdwrite "Initializi"
GLcdposition 10, 0
GLcdwrite "ng..."
WaitMs 3000
Return

selectprogram:
phase = 1
GLcdclear
GLcdposition 0, 4
GLcdwrite "Select pro"
GLcdposition 8, 0
GLcdwrite "gram:"
loop1:
GLcdclean 1
GLcdclean 9
GLcdposition 1, 4
If phase = 1 Then GLcdwrite "1 - Charge"
If phase = 2 Then
GLcdwrite "2 - Discha"
GLcdposition 9, 0
GLcdwrite "rge"
Endif
If phase =3 Then GLcdwrite "3 - Cycle"
If phase = 4 Then GLcdwrite "4 - Setup"
If phase = 5 Then
GLcdwrite "5 - Setup "
GLcdposition 9, 0
GLcdwrite "defaults"
Endif
If phase = 6 Then GLcdwrite "6 - Memory"
Gosub waitkey
If key = c_down Then
phase = phase + 1
If phase = 7 Then phase = 1
Goto loop1
Endif
If key = c_up Then
phase = phase - 1
If phase = 0 Then phase = 6
Goto loop1Endif
If key = c_right Then program = phase
If key = c_left Then program = 0
Return

waitkey:
key = 0
If t_right = 1 Then key = c_right
If t_up = 1 Then key = c_up
If t_down = 1 Then key = c_down
If t_left = 1 Then key = c_left
If key = 0 Then Goto waitkey
Gosub debounce
Return

getkey:
key = 0
If t_right = 1 Then key = c_right
If t_up = 1 Then key = c_up
If t_down = 1 Then key =c_down
If t_left = 1 Then key = c_left
If key > 0 Then Gosub debounce
Return

debounce:
If t_right = 1 Then i = 0
If t_up = 1 Then i = 0
If t_down = 1 Then i = 0
If t_left = 1 Then i = 0
i = i + 1
WaitMs 10
If i < 10 Then Goto debounce
Return

scankey:
If t_right = 1 Then key = c_right
If t_up = 1 Then key = c_up
If t_down = 1 Then key = c_down
If t_left = 1 Then key = c_left...
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS