20X2 4 digit 7 seqment VoltMeter

marks

Senior Member
Just a simple voltage meter at the moment
will display upto about (40.9V) lol ,seems acurate to about 0.1v. upto 20v
the highest voltage is the most inaccurate (42.0v)displayed is actually 42.2 volts.

Will look at improving accuracy later maybe in software
or add a adjustable reistor but voltages upto 20 v are quite accurate.
might look for a 10k resistor thats slightly different in value lol.

Code:
	'             -- --   -- --   -- --   
	' B0-A             | |     | |     | |     |
	' B1-B	                                        Picake  20x2  ver C.0
	' B2-C             | |     | |     | |     |
	' B3-D        -- --           -- --   -- --         MarkS
	' B4-E       |       |     | |     | 
	' B5-F
	' B6-G       |       |     | |     | 
	' B7-dp       -- --   -- -- o -- --     
	'
	'Display        1       2       3       4
	'Common anode  C.3     C.2     C.1     c.0
	
 SETFREQ M16
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255)     'Display (0,1,2,3,4,5,6,7,8,9,blank)
 
	
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	
	SYMBOL volts         = W10
	SYMBOL number        = B11
	SYMBOL response      = B12
	
main:
let dirsb = %11111111
let dirsc = %00111111

voltage:
Readadc10 c.7,volts 
volts = volts * 5                                ' Input (5.0v)= 500 and (50.0v)=5000
display:
	
for response =1 to 50
		
	number = 10 :  IF volts < 1000 THEN dig1   'Display1 Zero blanking	
      LET number = volts DIG 3                                       
    Dig1:  READ number,pinsb :                   LOW display1 : PAUSE 1 : HIGH display1 '5      
 
                
	LET number = volts DIG 2 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb-128 : LOW display2 : PAUSE 1 : HIGH display2 '0.	
	
	LET number = volts DIG 1			
    Dig3:  READ number,pinsb :                   LOW display3 : PAUSE 1 : HIGH display3 '0
			                                                              
    Dig4:  pinsb = 157       :                   LOW display4 : PAUSE 1 : HIGH display4 'v
      
 next response
goto voltage
 

Attachments

Last edited:

hippy

Ex-Staff (retired)
Excellent work with a nice and clean 7-segment multiplexing design.

If there's any flicker, or you want to get the refresh rate up, one trick is to pre-calculate what the digit bits will be per digit before the FOR-NEXT loop so only those digit bits need to be moved to pinsB in the FOR-NEXT. That is, move the "LET number=' and READ out of the refresh rate critical loop.
 

marks

Senior Member
Thanks Hippy, there is no flicker even at 8 mhz ,the for to statement there to slow the refresh rate down slightly for when it changes from say 24.9 to 25.0v was to quick too read.
Only noticed this when i conected another meter must load it slightly was hunting between the two now i can read what its doing lol.
 

marks

Senior Member
improved accuracy in code now reads to .1v across the whole range
as accurate as my fluke lol.more accurate than my lcd on my variable supply.
Code:
	'             -- --   -- --   -- --   
	' B0-A             | |     | |     | |     |
	' B1-B	                                        Picake  20x2  ver C.0
	' B2-C             | |     | |     | |     |
	' B3-D        -- --           -- --   -- --         MarkS
	' B4-E       |       |     | |     | 
	' B5-F
	' B6-G       |       |     | |     | 
	' B7-dp       -- --   -- -- o -- --     
	'
	'Display        1       2       3       4
	'Common anode  C.3     C.2     C.1     c.0
	
 SETFREQ M16
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255,157)     'Display (0,1,2,3,4,5,6,7,8,9,blank,v)
 
	
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL adjust        = W11
	SYMBOL volts         = W10
	SYMBOL number        = B11
	SYMBOL response      = B12
	
main:
let dirsb = %11111111
let dirsc = %00111111

voltage:
Readadc10 c.7,volts                      'info  Input (5.0v)= 05000 and (40.0v)=40000
let adjust = volts *25/100                   'step2 adjust high voltage 40.0v  25*8 (+200) ie.40200  
volts = volts * 50                             'step2 will also add to the low range (+25) ie.05075
volts = volts + adjust+50                  'step1 add low voltage offset at 5v input (+50) ie.05050
                             
display:
	
for response =1 to 50
		
	number = 10 :  IF volts < 10000 THEN dig1   'Display1 Zero blanking	
      LET number = volts DIG 4                                       
    Dig1:  READ number,pinsb :                   LOW display1 : PAUSE 1 : HIGH display1 '5      
 
                
	LET number = volts DIG 3 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb-128 : LOW display2 : PAUSE 1 : HIGH display2 '0.	
	
	LET number = volts DIG 2			
    Dig3:  READ number,pinsb :                   LOW display3 : PAUSE 1 : HIGH display3 '0
    
	LET number = 11		                   'volts DIG 1 ' replace 11 to see 05 resolution                                          
    Dig4:  READ number,pinsb :                   LOW display4 : PAUSE 1 : HIGH display4 'v
      
 next response
goto voltage
 
Last edited:
Top