Count RB0... on RB7


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Smile

    Hello mister e,

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

    Thanks


    Quote Originally Posted by mister_e
    to prevent adding any additional hardware to save count result when you remove the power, use the following
    Code:
    @ __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

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    One of the various method to do it
    Code:
    @ __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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Smile Thanks

    Hello mister e,

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

    Leonardo



    Quote Originally Posted by mister_e
    One of the various method to do it
    Code:
    @ __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

  4. #4


    Did you find this post helpful? Yes | No

    Smile

    Hello mister e,

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



    Quote Originally Posted by Leonardo
    Hello mister e,

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

    Leonardo

  5. #5


    Did you find this post helpful? Yes | No

    Smile

    Hello mister e,

    As I avoid the rebounds of the pulsador?.






    Quote Originally Posted by Leonardo
    Hello mister e,

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

  6. #6


    Did you find this post helpful? Yes | No

    Smile

    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




    Quote Originally Posted by mister_e
    One of the various method to do it
    Code:
    @ __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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default ???????`

    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
    Code:
        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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8


    Did you find this post helpful? Yes | No

    Smile

    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




    Quote Originally Posted by mister_e
    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
    Code:
        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

  9. #9


    Did you find this post helpful? Yes | No

    Smile

    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





    Quote Originally Posted by Leonardo
    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
    Attached Images Attached Images  

  10. #10


    Did you find this post helpful? Yes | No

    Smile

    Hello to all,

    Somebody can help me with this please.

    Thank you

  11. #11


    Did you find this post helpful? Yes | No

    Smile

    Hello mister_e

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

    Thank you



    Quote Originally Posted by mister_e
    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
    Code:
        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

  12. #12


    Did you find this post helpful? Yes | No

    Smile

    Some suggestion


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

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 05:52
  2. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th March 2009, 00:14
  3. Timer RB0...RB7 on RA1
    By Leonardo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th September 2005, 01:38
  4. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 20:04
  5. Count RB0... on RB7
    By Leonardo in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 26th August 2005, 00:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts