Yesterday 21:49
Forum: The Lounge
Starter: Les
Views: 0
Replies: 5
Yesterday 21:00
Forum: Proton Users File Server
Starter: Les
Views: 0
Replies: 0
Yesterday 18:33
Forum: Absolute Beginners Section
Starter: amod
Views: 0
Replies: 12
Yesterday 17:31
Forum: Proton Users File Server
Starter: Les
Views: 0
Replies: 1
+ Reply to Thread
Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34

Thread: Pulse counter using COUNTER command67 days old

  1. #21
    Senior Member Henk57's Avatar
    Join Date
    Jan 2014
    Posts
    400
    Thumbs Up
    Received: 38
    Given: 35
    Total Downloaded
    192.60 MB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Never used 7seg.Display sorry I can't help you out that much.

    But if you post your example maybe someone can help you out.

    Henk.

  2. #22
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    38
    Thumbs Up
    Received: 26
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    My program
    Code:
    Xtal=4
    
    Dim DG As Byte
    Dim DIGIT As Byte
    Dim n As Word
    Dim NUMB As Word
    Dim countt As Byte
    Dim dg1 As Byte
    Dim dg2 As Byte
    Dim DG3 As Byte 
    Dim dg4 As Byte
    
    Symbol pin =PORTA.2
    
    ADCON1=%10000000
    ADCON0=%01000011 
    TRISA=%01111101 
    TRISB=0 
    TRISC=%00010000 
    ANSELH=%00000001
    ANSEL=%00000001
    CM1CON0=0
    CM2CON0=0
    VRCON=0
    
    main:
    
    NUMB=Counter pin,1000
    n=NUMB
    
    GoSub DISPLAY
    GoSub DIGITCALC
    
    GoTo main
    
    DISPLAY: ;breaking digits into 4 display
    
    For countt=0 To 99
    
    PORTB=dg1
    PORTC.3=0
    DelayUS 100
    PORTC.3=1
    
    PORTB=dg2
    PORTC.2=0
    DelayUS 100
    PORTC.2=1
    
    PORTB=DG3
    PORTC.1=0
    DelayUS 100 
    PORTC.1=1
    
    PORTB=dg4
    PORTC.0=0
    DelayUS 100 
    PORTC.0=1
    
    Next countt
    
    Return
    
    '_________________________________________________ _________________________
    DIGITCALC: ;data to each display ones,tens,hundred,thousands
    
    DIGIT=0
    LP1:
    If n<1000 Then DS1
    n=N-1000
    DIGIT=DIGIT+1
    GoTo LP1
    DS1:
    GoSub FND
    dg1=DG
    
    DIGIT=0
    LP2:
    If n<100 Then DS2
    n=N-100
    DIGIT=DIGIT+1
    GoTo LP2
    
    DS2:
    GoSub FND
    dg2=DG
    
    DIGIT=0
    LP3:
    If n<10 Then DS3
    n=N-10
    DIGIT=DIGIT+1
    GoTo LP3
    
    DS3:
    GoSub FND
    DG3=DG
    
    DIGIT=n
    GoSub FND
    dg4=DG
    
    Return
    
    '___________________________________________________________________________
    FND: ;data for each segment.
    
    FND0: ;zero
    If DIGIT>0 Then FND1
    DG=%00000011 
    GoTo FNDEND
    
    FND1: ;one
    If DIGIT>1 Then FND2
    DG=%10011111 
    GoTo FNDEND
    
    FND2: ;two
    If DIGIT>2 Then FND3
    DG=%00100101 
    GoTo FNDEND
     
    FND3: ;three
    If DIGIT>3 Then FND4
    DG=%00001101 
    GoTo FNDEND
    
    FND4: ;four
    If DIGIT>4 Then FND5
    DG=%10011001 
    GoTo FNDEND
     
    FND5: ;five
    If DIGIT>5 Then FND6
    DG=%01001001 
    GoTo FNDEND
     
    FND6: ;six
    If DIGIT>6 Then FND7
    DG=%01000001 
    GoTo FNDEND
     
    FND7:
    If DIGIT>7 Then FND8 ;seven
    DG=%00011111 
    GoTo FNDEND
      
    FND8: ;eight
    If DIGIT>8 Then FND9
    DG=%00000001 
    GoTo FNDEND
     
    FND9:
    DG=%00011001 ;nine 
     
    FNDEND:
    Return
    Last edited by joesaliba; 23rd August 2018 at 15:37.

  3. #23
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    401
    Thumbs Up
    Received: 28
    Given: 4
    Total Downloaded
    1.86 GB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Just a few suggestions..

    1) Have you tried just setting your all DG values to %1111111 and commenting out all you main code except for Gosub DISPLAY just to check that you are actually displaying something?

    2) I think you have the timing for you display wrong, 4 digits @ 100uS x 1000 = 2.5Hz...
    For persistence of vision you need to refresh the display at a rate of 50Hz or greater so all 4 digits need updating every 20mS (max) therefore each digit should be displayed for 5mS (max), however the shorter the duration the segments are on for the dimmer the display gets, consequently when strobing 7 segment displays you tend to over driver the displays current wise to compensate.
    i.e. instead of using a typical LED current of 10mA you use say 30mA (or peek current for the display, typically 80mA), because the switching means the higher peak current is equal to or less than the average constant current, consequently at the switching speed you currently have the average light output from the displays may be too dim for you to see them so if you cannot see any display as a result of item 1 alone try increasing delay 100uS to 4mS and see if that make a difference.

    3) You may want to consider rewriting the FDN section using the Select Case commands, it is just a little more compact and readable.

  4. #24
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    38
    Thumbs Up
    Received: 26
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Thanks Stephen.
    I succeeded in 7 segment display.I need to implement a decimal point also ,how can I do this.

  5. #25
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    401
    Thumbs Up
    Received: 28
    Given: 4
    Total Downloaded
    1.86 GB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    There are several different types of 7 segment display, those with just the seven number segments (a-g) and those with an additional DP or Colon (":" for clocks). If your displays are the type with the decimal point then setting the port bit connect to the dp pin of the approporate digit will display the decimal point just as it would with any other segment.

    If I am reading your code correctly then it looks like the easiest way (assuming the dp position is fixed and always illuminated) to incorporate it into your existing code would be either in...
    DIGITCALC subroutine by placing a DG = DG & %xxxxxxxx (set bit corresponding to DP to 0, all other bits to 1) immediately before your dgx (where x = 1 to 4) = dg command or
    DISPLAY subroutine with the same code as above positioned immediately before the relevant PORTB = dgx (where x = 1 to 4) command.

    If your displays do not have a decimal point then you will have to change one or more of them for one with a decimal point.

  6. #26
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    38
    Thumbs Up
    Received: 26
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    When I write DG3=%10000000 in digitcalc then third display goes blank and decimal point glows.

  7. #27
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    38
    Thumbs Up
    Received: 26
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Can I get 12 bit adc result by 10 bit adc like in picbasic pro

  8. #28
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    401
    Thumbs Up
    Received: 28
    Given: 4
    Total Downloaded
    1.86 GB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Quote Originally Posted by amod View Post
    When I write DG3=%10000000 in digitcalc then third display goes blank and decimal point glows.
    I am a little confused here as from the DG values in the FDN section I would have thought that 0 = on and 1 = off (Common Anode display), but here you appear to be stating the opposite as with only the dp on it looks like 1 = on (Common Cathode Display). Is your display common Cathode (1= on) or common Anode (0=on)?

    If Common Cathode then logically ORing () %10000000 with the DG value set in the FND section for the current digit will illuminate the dp and number for that digit.
    If Common Anode then as I previously stated logically ANDing (&) %01111111 with the DG value set in the FND section for the current digit will illuminate the dp and number for that digit.

    Quote Originally Posted by amod View Post
    Can I get 12 bit adc result by 10 bit adc like in picbasic pro
    Not that I know of, if your ADC is only 10 bit then you can only get a 10 bit result (0-1024). If you want the maximum ADC result to equal 4096 instead of 1024 then simply multiple the ADC result by 4 but as the result is relative why bother.
    If you are looking to scale the ADC result to create some maximum display value higher then 1024, i.e. 2000 then create a float variable to store the result of 2000 divided by 1024 and multiply the ADC result by that value.

  9. #29
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,770
    Thumbs Up
    Received: 151
    Given: 152
    Total Downloaded
    2.96 GB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Can I get 12 bit adc result by 10 bit adc like in picbasic pro
    Yes, I beleive you can, it's not a function on PicBasic. The code should be readily translated. Theres a Wiki page if you're interested in the math behind it. Look for "Oversampling". I thought it was flim flam but appearently not.
    George

  10. #30
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    38
    Thumbs Up
    Received: 26
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Pulse counter using COUNTER command

    Hi Stephen,
    I have attached a snap for your kind consideration that what problem iam facing.IMG_20180824_221711.jpg

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. pulse counter with single LED to display total
    By Automods in forum Proton Plus Compiler v3
    Replies: 17
    Last Post: 14th July 2011, 16:05
  2. Counter pulse width/rise time?
    By GregZ in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 22nd July 2009, 16:20
  3. Counter command
    By amateurtje in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 22nd August 2008, 06:00
  4. Pulse counter using capture interrupts
    By HelpMe! in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 30th November 2007, 15:37
  5. Counter command option
    By AlanR in forum Wish List / Product Feedback
    Replies: 6
    Last Post: 2nd January 2006, 01:02

Posting Permissions

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