PDA

View Full Version : Count RB0... on RB7



Leonardo
- 10th September 2005, 14:01
Hello to all,

I have a pic16f628 and I want to count 10 pulses in RB0 for when ends RB7 on led, they can give me some example.

Thank you

mister_e
- 10th September 2005, 16:09
here's one method using interrupt


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG=0 ' Enable internal pull-up on PORTB
' Interrupt on falling edge of RB0

INTCON = %10010000 ' Enable global interrupt
' Enable RB0 interrupt

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

INTF var INTCON.1 ' RB0 Interrupt flag
Apulse VAR BYTE ' store the amount of pulse

on interrupt goto CountPulses

led=0
apulse=0

start:
if apulse<10 then start
'
' Here we got the 10 pulses
'
INTCON = 0 ' disable all interrupt
led=1 ' enable the LED
'
Z: goto z ' stay here 'till next system reboot


disable
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
CountPulses:
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
' Here is where the program jump every time the push-buton on
' RB0 is press.
'
apulse=apulse+1 ' add a count
while clkin=0 : wend ' wait untill the push button is release
pause 50 ' debounce time
intf=0 ' reset interupt flag
resume ' Get out of here
enable ' re-enable interrupt


without interupts but a loop.


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse

led=0
apulse=0

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
endif
until apulse=10
led=1

Here:
goto here


Using internal counter(TMR0) and polling TMR0 overflow flag and RA.4 as input instead of RB0


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=0 ' Set output to all i/o
TRISA=255 ' set input to all

OPTION_REG=%11111000 ' TMR0 clock source = RA4
' increment counter on high to low transistion
' prescaller assign to WDT
' prescaller rate 1:1

CMCON=7 ' disable analog comparator

INTCON = %00100000 ' enable TMR0 overflow interrupt

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
T0IF var INTCON.2 ' TMR0 Interrupt flag

TMR0=246 ' pre-load TMR0 to have an Interrupt after 10 pulses
' TMR0 is a 8 byte Register so 246+10=256=interrupt
led=0

WHILE T0IF=0 : WEND
LED=1
Z: GOTO Z


Almost the same as above but polling only the TMR0 register


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=0 ' Set output to all i/o
TRISA=255 ' set input to all

OPTION_REG=%11111000 ' TMR0 clock source = RA4
' increment counter on high to low transistion
' prescaller assign to WDT
' prescaller rate 1:1

CMCON=7 ' disable analog comparator

INTCON = %00100000 ' enable TMR0 overflow interrupt

LED VAR PORTB.7 ' connected between RB7 and GND via resistor

TMR0=0
led=0

WHILE TMR0<10 : WEND
LED=1
Z: GOTO Z


I prefer the last one, produce really tight code and easy to understand BUT if the pulse come from a PUSH-Button it can glow the LED before 10 human press as it don't provide any debounce solution. BUT if you add a 0.1-1uF in parrallel, it seems to be enough to do the job. Don't forget the pull-up resistor on the RA.4 pin. Let's say 10K as a standard value

That should be more than enough to start ;)

Leonardo
- 10th September 2005, 22:13
Thank you for your orientation







here's one method using interrupt


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG=0 ' Enable internal pull-up on PORTB
' Interrupt on falling edge of RB0

INTCON = %10010000 ' Enable global interrupt
' Enable RB0 interrupt

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

INTF var INTCON.1 ' RB0 Interrupt flag
Apulse VAR BYTE ' store the amount of pulse

on interrupt goto CountPulses

led=0
apulse=0

start:
if apulse<10 then start
'
' Here we got the 10 pulses
'
INTCON = 0 ' disable all interrupt
led=1 ' enable the LED
'
Z: goto z ' stay here 'till next system reboot


disable
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
CountPulses:
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
' Here is where the program jump every time the push-buton on
' RB0 is press.
'
apulse=apulse+1 ' add a count
while clkin=0 : wend ' wait untill the push button is release
pause 50 ' debounce time
intf=0 ' reset interupt flag
resume ' Get out of here
enable ' re-enable interrupt


without interupts but a loop.


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse

led=0
apulse=0

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
endif
until apulse=10
led=1

Here:
goto here


Using internal counter(TMR0) and polling TMR0 overflow flag and RA.4 as input instead of RB0


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=0 ' Set output to all i/o
TRISA=255 ' set input to all

OPTION_REG=%11111000 ' TMR0 clock source = RA4
' increment counter on high to low transistion
' prescaller assign to WDT
' prescaller rate 1:1

CMCON=7 ' disable analog comparator

INTCON = %00100000 ' enable TMR0 overflow interrupt

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
T0IF var INTCON.2 ' TMR0 Interrupt flag

TMR0=246 ' pre-load TMR0 to have an Interrupt after 10 pulses
' TMR0 is a 8 byte Register so 246+10=256=interrupt
led=0

WHILE T0IF=0 : WEND
LED=1
Z: GOTO Z


Almost the same as above but polling only the TMR0 register


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=0 ' Set output to all i/o
TRISA=255 ' set input to all

OPTION_REG=%11111000 ' TMR0 clock source = RA4
' increment counter on high to low transistion
' prescaller assign to WDT
' prescaller rate 1:1

CMCON=7 ' disable analog comparator

INTCON = %00100000 ' enable TMR0 overflow interrupt

LED VAR PORTB.7 ' connected between RB7 and GND via resistor

TMR0=0
led=0

WHILE TMR0<10 : WEND
LED=1
Z: GOTO Z


I prefer the last one, produce really tight code and easy to understand BUT if the pulse come from a PUSH-Button it can glow the LED before 10 human press as it don't provide any debounce solution. BUT if you add a 0.1-1uF in parrallel, it seems to be enough to do the job. Don't forget the pull-up resistor on the RA.4 pin. Let's say 10K as a standard value

That should be more than enough to start ;)

Leonardo
- 10th September 2005, 23:08
Hello mister e

As you it can store the I number of pulses in the eeprom to continue the count if the pic is off?.




Thank you for your orientation

mister_e
- 10th September 2005, 23:38
to prevent adding any additional hardware to save count result when you remove the power, use the following


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time

led=0
Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here


this should work

Leonardo
- 11th September 2005, 02:51
Hello mister e,

Excellent the code but like you reset the eeprom from some pin?.

Thanks



to prevent adding any additional hardware to save count result when you remove the power, use the following


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time

led=0
Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here


this should work

mister_e
- 11th September 2005, 08:43
One of the various method to do it


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000011 ' Set RB0,RB1 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND
ClrEEP var PORTB.1 ' connected between RB1 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time
led=0 ' LED=OFF

' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' To Reset the value in the EEPROM, press on ClrEEP button while
' applying power. When the command is accepted, the LED will
' stay ON for 1 second
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '

Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here

Leonardo
- 11th September 2005, 16:26
Hello mister e,

Thank you for their help and I hope to be able to have their support in future occasions.

Leonardo




One of the various method to do it


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000011 ' Set RB0,RB1 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND
ClrEEP var PORTB.1 ' connected between RB1 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time
led=0 ' LED=OFF

' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' To Reset the value in the EEPROM, press on ClrEEP button while
' applying power. When the command is accepted, the LED will
' stay ON for 1 second
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '

Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here

Leonardo
- 11th September 2005, 16:29
Hello mister e,

Because uses, Here
goto here..... I don't understand it.




Hello mister e,

Thank you for their help and I hope to be able to have their support in future occasions.

Leonardo

Leonardo
- 11th September 2005, 16:31
Hello mister e,

As I avoid the rebounds of the pulsador?.







Hello mister e,

Because uses, Here
goto here..... I don't understand it.

Leonardo
- 11th September 2005, 18:17
Hello mister e,

In the following code it does add an entrance and an exit but, in RB1 and out RB6, but don't I achieve that each exit works in independent way that can happen?, like I can store the two values in the eeprom?.


TRISB=%00001111 ' Set RB0 to input, others to output


OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

LED1 VAR PORTB.6
BOT VAR PORTB.1



Apulse VAR BYTE ' store the amount of pulse
Apulse1 var byte

led=0
apulse=0

led1=0
Apulse1=0


main:



paso1:
repeat
if clkin=0 then
while clkin=0 : wend
pause 100
apulse=apulse+1
endif
until apulse=7
led=1




paso2:
repeat
if BOT=0 then
while BOT=0 : wend
pause 100
apulse1=apulse1+1
endif
until apulse1=5
led1=1

goto main

Here:
goto here





One of the various method to do it


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000011 ' Set RB0,RB1 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND
ClrEEP var PORTB.1 ' connected between RB1 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time
led=0 ' LED=OFF

' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' To Reset the value in the EEPROM, press on ClrEEP button while
' applying power. When the command is accepted, the LED will
' stay ON for 1 second
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '

Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here

mister_e
- 11th September 2005, 20:13
In the following code it does add an entrance and an exit but, in RB1 and out RB6, but don't I achieve that each exit works in independent way that can happen?, like I can store the two values in the eeprom?.
I tried to understand but and i'm still not sure of the question. BTW i did the following, let me know if it do what you're looking for. Case not, let me know in more details or with a drawing. Sometimes it help my single brain cell to figure out the question ;)


TRISB=%00001111 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
LED1 VAR PORTB.6
BOT VAR PORTB.1
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse
Apulse1 var byte

data @0,0,0
read 0,apulse
read 1,apulse1

led = 0
led1= 0

paso1:
repeat
if clkin=0 then
while clkin=0 : wend
pause 100
apulse=apulse+1
write 0,apulse
endif

if BOT=0 then
while BOT=0 : wend
pause 100
apulse1=apulse1+1
write 1,apulse1
endif

until (apulse=7) or (Apulse1=5)

if apulse=7 then
led=1
else
led1=1
endif

goto paso1

Leonardo
- 11th September 2005, 20:38
Hello mister e,

I sit down it it mistakes, the following code works OK, what I want is to put another entrance RB1 to count the pulses and another exit RB6 and that it stores them in the eeprom.

Thank you

the code :

TRISB=%00000011 ' Set RB0,RB1 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND
ClrEEP var PORTB.1 ' connected between RB1 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time
led=0 ' LED=OFF

' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' To Reset the value in the EEPROM, press on ClrEEP button while
' applying power. When the command is accepted, the LED will
' stay ON for 1 second
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '

Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here





I tried to understand but and i'm still not sure of the question. BTW i did the following, let me know if it do what you're looking for. Case not, let me know in more details or with a drawing. Sometimes it help my single brain cell to figure out the question ;)


TRISB=%00001111 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
LED1 VAR PORTB.6
BOT VAR PORTB.1
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse
Apulse1 var byte

data @0,0,0
read 0,apulse
read 1,apulse1

led = 0
led1= 0

paso1:
repeat
if clkin=0 then
while clkin=0 : wend
pause 100
apulse=apulse+1
write 0,apulse
endif

if BOT=0 then
while BOT=0 : wend
pause 100
apulse1=apulse1+1
write 1,apulse1
endif

until (apulse=7) or (Apulse1=5)

if apulse=7 then
led=1
else
led1=1
endif

goto paso1

Leonardo
- 11th September 2005, 22:09
Hello mister e,

The code to count and to store the I finish pulse in the eeprom this very well, what I want is to add the same thing in RB1 and RB6 and it also stores it in the eeprom.

Thank you




@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON

TRISB=%00000001 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time

led=0
Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here






Hello mister e,

I sit down it it mistakes, the following code works OK, what I want is to put another entrance RB1 to count the pulses and another exit RB6 and that it stores them in the eeprom.

Thank you

the code :

TRISB=%00000011 ' Set RB0,RB1 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND
ClrEEP var PORTB.1 ' connected between RB1 and GND

Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time
led=0 ' LED=OFF

' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' To Reset the value in the EEPROM, press on ClrEEP button while
' applying power. When the command is accepted, the LED will
' stay ON for 1 second
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '

Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1

Here:
goto here

Leonardo
- 16th September 2005, 01:38
Hello to all,

Somebody can help me with this please.

Thank you

BobK
- 16th September 2005, 02:08
Hi Leonardo,

Mr E. has done a great job (As usual!) of providing code for you. But if you wired your project as shown in the drawing then this is where you are having the difficulty.

In your .bmp image you show using pull down resistors. This means your inputs are at 0vdc until the button is pressed and when you press the push button you are applying +5vdc. Your code is looking for 0v to create the activity to occur.

"if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '

Read 0, Apulse ' Read count from internal eeprom

repeat
if clkin=0 then
while clkin=0 : wend
pause 50"

Turn on the internal weak pull ups and tie the other end of your push buttons to ground. To protect the PIC's inputs put 100 ohm resistors in line with the swtich and also tie MCLR to +5vdc through a 1k resistor.

This should solve your problem.

BobK

Leonardo
- 6th October 2005, 23:29
Hello mister_e

As I can modify the value of the count using the eeprom and a lcd?.

Thank you




I tried to understand but and i'm still not sure of the question. BTW i did the following, let me know if it do what you're looking for. Case not, let me know in more details or with a drawing. Sometimes it help my single brain cell to figure out the question ;)


TRISB=%00001111 ' Set RB0 to input, others to output

OPTION_REG.7=0 ' Enable internal pull-up on PORTB

LED VAR PORTB.7 ' connected between RB7 and GND via resistor
LED1 VAR PORTB.6
BOT VAR PORTB.1
ClkIn var PORTB.0 ' connected between RB0 and GND

Apulse VAR BYTE ' store the amount of pulse
Apulse1 var byte

data @0,0,0
read 0,apulse
read 1,apulse1

led = 0
led1= 0

paso1:
repeat
if clkin=0 then
while clkin=0 : wend
pause 100
apulse=apulse+1
write 0,apulse
endif

if BOT=0 then
while BOT=0 : wend
pause 100
apulse1=apulse1+1
write 1,apulse1
endif

until (apulse=7) or (Apulse1=5)

if apulse=7 then
led=1
else
led1=1
endif

goto paso1

Leonardo
- 7th October 2005, 16:11
Some suggestion


As I can modify the value of the count using the eeprom and a lcd?.

mister_e
- 8th October 2005, 10:36
Leonardo,

i know it's really hard for you to write in english but can you provide much details. I try to understand what you say but i'm really lost.

If you want, post your question in your language, probably someone else here can give us a hand and translate to english.

I just know english(a few) and French. i'm really sorry Leonardo :(

Leonardo
- 8th October 2005, 22:14
I understand, what I want is to be able to modify the value to count by means of a keyboard 4x4 and a lcd for not having to reprogram every time that the wants to modify the I number from maximum pulses to count.

For example: to show in a lcd

Push buttom RB0 to increase the value to count
Push buttom RB1 to diminish the value to count
Push buttom RB3 enter to record the value

Thanks

Leonardo
- 9th October 2005, 14:56
I understand, what I want is to be able to modify the value to count by means of a keyboard 4x4 and a lcd for not having to reprogram every time that the wants to modify the I number from maximum pulses to count.

For example: to show in a lcd

Push buttom RB0 to increase the value to count
Push buttom RB1 to diminish the value to count
Push buttom RB3 enter to record the value

Thanks

Leonardo
- 10th October 2005, 04:14
I understand, what I want is to be able to modify the value to count by means of a keyboard 4x4 and a lcd for not having to reprogram every time that the wants to modify the I number from maximum pulses to count.

For example: to show in a lcd

Push buttom RB0 to increase the value to count
Push buttom RB1 to diminish the value to count
Push buttom RB3 enter to record the value

Thanks

Leonardo
- 10th October 2005, 04:16
I understand, what I want is to be able to modify the value to count by means of a keyboard 4x4 and a lcd for not having to reprogram every time that the wants to modify the I number from maximum pulses to count.

For example: to show in a lcd

Push buttom RB0 to increase the value to count
Push buttom RB1 to diminish the value to count
Push buttom RB3 enter to record the value

Thanks






Leonardo,

i know it's really hard for you to write in english but can you provide much details. I try to understand what you say but i'm really lost.

If you want, post your question in your language, probably someone else here can give us a hand and translate to english.

I just know english(a few) and French. i'm really sorry Leonardo :(