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
Closed Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Problem in pulse per second meter177 days old

  1. #11
    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: Problem in pulse per second meter


    • Iam Not able To Understand This Part Of Program$define Segment_A 1$define segment_B 2$Define Segment_3 4




  2. #12
    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: Problem in pulse per second meter

    I don't know if this helps but another way to view those defines is

    Code:
    $define Segment_A 000001   ' The value to send to illuminate segment A on the Common Cathode 7 segment display
    $define Segment_B 000010   ' The value to send to illuminate segment B on the Common Cathode 7 segment display
    $define Segment_C 000100   ' The value to send to illuminate segment C on the Common Cathode 7 segment display
    $define Segment_D 001000   ' The value to send to illuminate segment D on the Common Cathode 7 segment display
    $define Segment_E 010000   ' The value to send to illuminate segment E on the Common Cathode 7 segment display
    $define Segment_F 100000   ' The value to send to illuminate segment F on the Common Cathode 7 segment display
    $define Segment_G 000000   ' The value to send to illuminate segment G on the Common Cathode 7 segment display
    rather than try to set and reset individual bits the value is written to the appropriate port
    Last edited by towlerg; 2nd April 2018 at 15:59.
    George

  3. #13
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    2,997
    Thumbs Up
    Received: 299
    Given: 109
    Total Downloaded
    1.50 GB

    1 Not allowed!

    Default Re: Problem in pulse per second meter

    I couldn't resist, because I need to keep my brain active while I can, so here's the same program for a Common Anode display. Notice the inversions?

    Code:
    '
    ' A simple pulse counter on the LEDs segments.0 and displayed on a 7 segment display
    ' For use with a Common Anode display
    '
    ' Written by Les Johnson for the Proton BASIC Compiler
    '
    Declare Hints= Off
    
        Device = 16F886                             ' Use a standard 14-bit core device
        Declare Xtal = 20                           ' Use a 20MHz crystal
        Declare Optimiser_Level = 1                 ' Increase optimisation
    
        On_Hardware_Interrupt GoTo ISR_Handler      ' Point to the interrupt handler
    
        Dim bOnes       As Byte                     ' The value for the 1st right LED display
        Dim bTens       As Byte                     ' The value for the 2nd right LED display
        Dim bHundreds   As Byte                     ' The value for the 3rd right LED display
        Dim bThousands  As Byte                     ' The value for the 4th right LED display
        Dim bTimeShare  As Byte                     ' Used by the interrupt for time sharing
        Dim wPulseCount As Word                     ' The amount of pulses detected    
    '
    ' Setup the pins used
    '
    $define Segment_Pins PORTC                      ' Sets the segments of each display
    $define Display1_Pin PORTB.1                    ' Enables or disables display 1
    $define Display2_Pin PORTB.2                    ' Enables or disables display 2
    $define Display3_Pin PORTB.3                    ' Enables or disables display 3
    $define Display4_Pin PORTB.4                    ' Enables or disables display 4
    $define Signal_Pin   PORTB.0                    ' The pulse is placed onto the INT pin
    '
    ' Individual segment values for a Common Anode 7 segment display (inverted compared to Common Cathode values)
    '
    $define Segment_A $FE                           ' The value (bin 11111110) to send to illuminate segment A on the Common Anode display
    $define Segment_B $FD                           ' The value (bin 11111101) to send to illuminate segment B on the Common Anode display
    $define Segment_C $FB                           ' The value (bin 11111011) to send to illuminate segment C on the Common Anode display
    $define Segment_D $F7                           ' The value (bin 11110111) to send to illuminate segment D on the Common Anode display
    $define Segment_E $EF                           ' The value (bin 11101111) to send to illuminate segment E on the Common Anode display
    $define Segment_F $DF                           ' The value (bin 11011111) to send to illuminate segment F on the Common Anode display
    $define Segment_G $BF                           ' The value (bin 10111111) to send to illuminate segment G on the Common Anode display
    '
    ' An LED's display segments are formatted like this:
    '     A
    '   ------
    '   |    |
    '  F|    |B
    '   | G  |
    '   ------
    '   |    |
    '  E|    |C
    '   | D  |
    '   ------
    '
    ' So each segment has a letter associated with it, that is controlled by one of its pins. Hence the above $defines giving the value required to illuminate a certain segment
    '
    ' Seven Segment data Anded together to give values for the Common Anode digits. Because of the inversion required for Common Anode, Ands are used instead of Ors
    '
        Dim SevenSeg_Data As Code = Segment_A & Segment_B & Segment_C & Segment_D & Segment_E & Segment_F,_     ' The segments to illuminate a digit 0
                                    Segment_B & Segment_C,_                                                     ' The segments to illuminate a digit 1
                                    Segment_A & Segment_B & Segment_D & Segment_E & Segment_G,_                 ' The segments to illuminate a digit 2
                                    Segment_A & Segment_B & Segment_C & Segment_D & Segment_G,_                 ' The segments to illuminate a digit 3
                                    Segment_B & Segment_C & Segment_F & Segment_G,_                             ' The segments to illuminate a digit 4
                                    Segment_A & Segment_C & Segment_D & Segment_F & Segment_G,_                 ' The segments to illuminate a digit 5
                                    Segment_C & Segment_D & Segment_E & Segment_F & Segment_G,_                 ' The segments to illuminate a digit 6
                                    Segment_A & Segment_B & Segment_C,_                                         ' The segments to illuminate a digit 7
                                    Segment_A & Segment_B & Segment_C & Segment_D & Segment_E & Segment_F & Segment_G,_ ' The segments to illuminate a digit 8
                                    Segment_A & Segment_B & Segment_C & Segment_D & Segment_F & Segment_G       ' The segments to illuminate a digit 9
    '
    ' Timer 0 prescaler values
    '                         
    $define Prescaler_2   0
    $define Prescaler_4   1
    $define Prescaler_8   2
    $define Prescaler_16  3
    $define Prescaler_32  4
    $define Prescaler_64  5
    $define Prescaler_128 6
    $define Prescaler_256 7
              
    '---------------------------------------------------------------------------------------
        GoTo Main                                       ' Jump to the main program
    
    '---------------------------------------------------------------------------------------
    ' Adjust the prescaler for Timer0
    ' Input     : pValue holds the prescaler rate
    '           :   000 = 1:2
    '           :   001 = 1:4
    '           :   010 = 1:8
    '           :   011 = 1:16
    '           :   100 = 1:32
    '           :   101 = 1:64
    '           :   110 = 1:128
    '           :   111 = 1:256
    ' Output    : None
    ' Notes     : None
    '    
    $define OPTION_REGbits_PS(pValue) ' 
        OPTION_REG = OPTION_REG & $F8 '
        OPTION_REG = OPTION_REG | pValue      
                                                                           
    '---------------------------------------------------------------------------------------
    ' Interrupt Handler
    ' Multiplexes the 7-segment displays
    ' Increments wPulseCount when a low to high signal is detected on the INT pin
    '
    ISR_Handler:
        Context Save                                    ' Save any SFRs or compiler system variables used within the interrupt
        
        If INTCONbits_INTF = 1 Then                     ' Is it an INT that has triggered the interrupt?
            Inc wPulseCount                             ' Yes. So increment the wPulseCount variable
            Clear INTCONbits_INTF                       ' Reset the INT interrupt flag
        EndIf
    
        If INTCONbits_T0IF = 1 Then                     ' Is it a Timer0 overflow that has triggered the interrupt?
            If bTimeShare = 0 Then                      ' Yes. So is it Display 1's turn?
                Clear Display4_Pin                      ' Yes. So turn Off the fourth LED
                Segment_Pins = bOnes                    ' Place the digit pattern on the LED's segments
                Set Display1_Pin                        ' Turn on the first LED
            ElseIf bTimeShare = 1 Then                  ' Is it Display 2's turn?
                Clear Display1_Pin                      ' Yes. So turn Off the first LED
                Segment_Pins = bTens                    ' Place the digit pattern on the LED's segments
                Set Display2_Pin                        ' Turn on the second LED
            ElseIf bTimeShare = 2 Then                  ' Is it Display 3's turn?
                Clear Display2_Pin                      ' Yes. So turn Off the second LED
                Segment_Pins = bHundreds                ' Place the digit pattern on the LED's segments
                Set Display3_Pin                        ' Turn on the third LED
            ElseIf bTimeShare = 3 Then                  ' Is it Display 4's turn?
                Clear Display3_Pin                      ' Yes. So turn Off the third LED
                Segment_Pins = bThousands               ' Place the digit pattern on the LED's segments
                Set Display4_Pin                        ' Turn on the fourth LED
            EndIf
    
            Inc bTimeShare                              ' Increment the time share counter
            If bTimeShare = 4 Then Clear bTimeShare     ' If it reaches 4 then clear it
            Clear INTCONbits_T0IF                       ' Clear the Timer0 interrupt flag
        EndIf
    
        Context Restore                                 ' Restore what has been saved, and exit the interrupt
    
    '---------------------------------------------------------------------------------------
    ' Build up the separate digits of variable wPulseCount
    ' Input     : pValue holds the value to display
    ' Output    : None
    ' Notes     : Zero suppression is implemented
    '
    $define Build_Displays(pValue) '
        wPulseCount = pValue       '
        GoSub _Build_Displays
    
    _Build_Displays:
    
        bOnes = CRead SevenSeg_Data + Dig wPulseCount, 0            ' Read the first digit from the value to display
        If wPulseCount < 10 Then                                    ' Is the value to display less than 10?
            bTens = $FF                                             ' Yes. So blank the Tens Display
        Else                                                        ' Otherwise...
            bTens = CRead SevenSeg_Data + Dig wPulseCount, 1        ' Read the second digit from the value to display
        EndIf
        If wPulseCount < 100 Then                                   ' Is the value to display less than 100?
            bHundreds = $FF                                         ' Yes. So blank the Hundreds Display
        Else                                                        ' Otherwise...
            bHundreds = CRead SevenSeg_Data + Dig wPulseCount, 2    ' Read the third digit from the value to display
        EndIf
        If wPulseCount < 1000 Then                                  ' Is the value to display less than 1000?
            bThousands = $FF                                        ' Yes. So blank the Thousands Display
        Else                                                        ' Otherwise...
            bThousands = CRead SevenSeg_Data + Dig wPulseCount, 3   ' Read the fourth digit from the value to display
        EndIf
        Return
        
    '---------------------------------------------------------------------------------------
    ' Setup the variables and peripherals
    ' Input     : None
    ' Output    : None
    ' Notes     : None
    '
    $define Setup() GoSub _Setup
    
    _Setup:
        Low Segment_Pins                    ' Clear all the 7 segment LED's segments
        Low Display1_Pin                    ' Disable the first display
        Low Display2_Pin                    ' Disable the second display
        Low Display3_Pin                    ' Disable the third display
        Low Display4_Pin                    ' Disable the fourth display
        Input Signal_Pin                    ' Make the INT pin an input (PORTB.0)
    
        bOnes = $FF                         ' Clear the bOnes variable (inverted because of Common Anode display)
        bTens = $FF                         ' Clear the bTens variable (inverted because of Common Anode display)
        bHundreds = $FF                     ' Clear the bHundreds variable (inverted because of Common Anode display)
        bThousands = $FF                    ' Clear the bThousands variable (inverted because of Common Anode display)
        
        Clear bTimeShare                     ' Clear the display time share variable
        Clear wPulseCount                   ' Clear the pulse counter variable
    '
    ' Setup Timer0 to interrupt on rollover
    '       
        OPTION_REG = 128                    ' Disable the pullup resistors on the LEDs segments          
        OPTION_REGbits_PS(Prescaler_32)     ' Set the prescaler for Timer0 to give a 625HZ refresh rate (using a 20MHz oscillator)
        Clear TMR0                          ' Clear Timer0
        Set INTCONbits_T0IE                 ' Enable a Timer0 overflow
    '
    ' Setup an INT interrupt
    '                                    
        Set OPTION_REGbits_INTEDG           ' Set for rising edge on pin INT (PORTB.0)       
        Set INTCONbits_INTE                 ' Enable an INT interrupt
        
        Set INTCONbits_GIE                  ' Enable global interrupts
        Return  
                             
    '---------------------------------------------------------------------------------------
    ' The main program loop starts here
    ' Count the pulses per second and display them on a seven segment display
    '
    Main:
           
        Setup()                             ' Setup the variables and the peripherals  
      
        Do                                  ' Create a loop
            Clear wPulseCount               ' Clear the pulse counter before we start the interrupt
            Clear INTCONbits_INTF           ' Clear the INT flag before enabling the interrupt
            Set INTCONbits_INTE             ' Enable the INT interrupt to count the pulses
            DelayMS 992                     ' Create a delay to measure within (Taking into account the interrupt running in the background)
            Clear INTCONbits_INTE           ' Disable the INT interrupt
            Build_Displays(wPulseCount)     ' Create the value to display on the 7 segment LEDs
        Loop                                ' Loop forever
    And here's a screenshot of it working within the Isis simulator:
    CA_Display.jpg
    Last edited by Les; 2nd April 2018 at 17:48.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  4. #14
    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: Problem in pulse per second meter

    Thanks Les .I got my work done.I noticed the changes you made.I am still learning .

    Can you help me for calibration of hx711 load cell module.I managed to get raw values.But couldn't find how to calibrate.Iam stuck in maths.
    Last edited by amod; 16th April 2018 at 16:16.

  5. #15
    Junior Member petemilligan's Avatar
    Join Date
    Jun 2017
    Posts
    20
    Thumbs Up
    Received: 16
    Given: 2
    Total Downloaded
    150.22 MB

    0 Not allowed!

    Default Re: Problem in pulse per second meter

    Hi Amod, It should be linear. Have a look at this; https://github.com/bogde/HX711/issues/70

    Pete

  6. #16
    Administrator John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,524
    Thumbs Up
    Received: 100
    Given: 29
    Total Downloaded
    2.52 GB

    0 Not allowed!

    Default Re: Problem in pulse per second meter

    Hi Amod,
    If you get stuck send me the values as a table and I'll develop a formula if Pete's link doesn't sort your problem.
    John

  7. #17
    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: Problem in pulse per second meter

    My values fluctuates from 8388720 to 8389667 . values are not stable.when I keep 1 kg load on load cell values increases but not stable.

  8. #18
    Administrator John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,524
    Thumbs Up
    Received: 100
    Given: 29
    Total Downloaded
    2.52 GB

    0 Not allowed!

    Default Re: Proton Compiler, Pulse Counter with a multiplexed 7-segment LED display

    It's stable to 4 significant figures. That may be within the sensors capability. What does the datasheet claim?
    You are seeing about 0.01% fluctuation.or about 0.1 gram shift. Not bad accuracy.
    I haven't checked your program (I'm on my phone) but I'm assuming you have some averaging built in.

    John

  9. #19
    Junior Member petemilligan's Avatar
    Join Date
    Jun 2017
    Posts
    20
    Thumbs Up
    Received: 16
    Given: 2
    Total Downloaded
    150.22 MB

    0 Not allowed!

    Default Re: Problem in pulse per second meter

    I'd say that's pretty good for a HX711. If you're looking for greater accuracy, I've found that AD7796/7 to be a little more stable as it employs 50/60Hz rejection & on chip calibration. Even with the AD7796 & as John suggested, I used averaging. Take 5 or 10 values, add them & divide by 5 or 10.

    Furthermore, using a good ground plane design, judicious screening of the load sensor wires and proper separation of analogue and digital circuits on your PCB will see the variation drop significantly.

    Pete

  10. #20
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    2,997
    Thumbs Up
    Received: 299
    Given: 109
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: Problem in pulse per second meter

    Also, use a median filter to iron out some of the fluctuations. A median filter is a simple bubble sort, then choose the middle value from the sort.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. MAX35101 ultrasonic heat meter and flow meter demo board
    By normnet in forum New devices and techniques
    Replies: 5
    Last Post: 3rd February 2015, 07:24
  2. MAX35102 ultrasonic heat meter and flow meter
    By normnet in forum New devices and techniques
    Replies: 0
    Last Post: 2nd February 2015, 11:24
  3. how to use a pulse to make another pulse
    By furqankaimkhani in forum Timer Modules
    Replies: 1
    Last Post: 9th February 2012, 19:24
  4. pulse generator
    By john burke in forum Labcenter Proteus VSM
    Replies: 31
    Last Post: 22nd December 2005, 01:48
  5. Pulse detection
    By Richard in forum The Lounge
    Replies: 4
    Last Post: 17th May 2004, 08:34

Tags for this Thread

Posting Permissions

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