Trouble working a 4026B 7seg setup.

melon

New Member
Hey

I am using the AXE092 experimenter board with the 08M chip and have it linked to a breadboard with a thermistor and a 4026B 7segment display set up.

I want the 7 segment display to count from 0-9 or 9-0 (preferably 9-0), then read the thermistor, display the temperature as a number and light up the red LED when that temperature isn’t in a safe limit.

I am new to this and don’t really understand it fully. I’ve managed to mash together a bit of code but when I download it to the board, rather than the 7seg counting down the Red LED flashes 9 times!

Could you point out where I’m going wrong, if I’m even going right at all. Thanks.


Code:
'I/O lines:
	'0 - reset 7 seg display output
	'1 - count 7 seg display output
	'2 - red LED output
	'3 - input unused
	'4 - input from thermistor (ADC)
	
'variable used:
	'b0 - ADC value (0 to 255) from thermistor (input 3)
	'b1 - number of clock pulses to be sent to output 1
	'b2 - loop counter for number of clock pulses

main: 				'procedure for initial countdown
	for b1 = 0 to 9		
	let pins=b1			
	pause 1000			'Pause 1 second
	next b1			'Next
	goto temp			'Measure temperature


temp: 				'procedure for temperature reading 
	readadc 4, b0		'take reading from thermistor
	if b0<80 then level0
	if b0<120 then level1
	if b0<140 then level2
	if b0<160 then level3
	if b0<190 then level4
	if b0<205 then level5
	if b0<220 then level6
	if b0<225 then level7
	if b0<235 then level8
	goto level9
	
	
level0:				'procedure for temp <10C
	let b1 = 0			'set variable b1 to 0
	gosub clock			'go to "clock" sub-procedure
high 0
	
	
level1:				'procedure for temp 11-20C
	let b1 = 1
	gosub clock
	high 0
	
level2:				'procedure for temp 21-30C
	let b1 = 2
	gosub clock


&#8230;etc etc&#8230;


clock:				'procedure to send output to display
	pulsout 1,10		'reset display to zero
	if b1 = 0 then endclk 	
	for b2 = 1 to b1 		
	pulsout 0,10 		
	next b2 			
	
	
endclk: 				'procedure to end clock
	return 			'return from sub-procedure
 

eclectic

Moderator
One step at a time.

Melon.
First, if this is for coursework, then please record all help received,
in your coursework notes.

I've taken one very important part of your code, and made some changes.
I've tested it, and it does work, using 08M /4026 / 7 segment display.

I've marked the changes using ******.
Check it, and work out HOW it's different and WHY it now works.

Code:
main: 				
	for b1 = 9 to 0 step -1 '***********		
	gosub clock 'let pins=b1 ************			
	pause 1000			
	next b1
				
goto main '************

clock:				
	pulsout 0,10		'**************
	if b1 = 0 then endclk 	
	for b2 = 1 to b1 		
	pulsout 1,10 	      '**************	
	next b2 			
	
	
endclk: 				
	return
Then, for stage two, people will help with the rest of your code.

And an important question. You said “thermistor”. Was this correct?

e.
 

MPep

Senior Member
Instead of a thermistor, I would use a DS18B20. All commands are already dealt with in PICAXE BASIC commands.
 

melon

New Member
Then, for stage two, people will help with the rest of your code.

And an important question. You said “thermistor”. Was this correct?

e.
Yeah a thermistor

Thanks for your help, although it's still not working, i think i'm gonna have to go back and check everythings in the right place and nothings faulty.
 

Rickharris

Senior Member
Let me just revise how the 4026 works just in case you got it wrong.

Every time you pulse the clock input the 4026 will send out the next set of segments for the display - This is automatic. So to get it to read from 9 to 0 you need to send -
initially a rest output to set the 4026 to zero.
Then send 9 pulsed to get it to read 9
The set to zero and send 8 pulses to read
then set to zero and send 7 pulses etc.

Although this sounds difficult you can set up a for ... next loop to do most of the work for you.

If your still getting funny results check your connections to the display from the 4026 it is easy to miss one or get them mixed up.

Remember you need the Display enable pin 3 high and the clock inhibit pin 2 low the reset pin goes high to reset - personally I put a pull down resistor - 10k to ground on the reset pin to make sure it is off unless I wanted to reset.
 
Last edited:

MurrayJ

Senior Member
Probably not your problem, but the picaxe manual 3 that contains the info on how to hook the 4026 chip to a picaxe used to contain an error in the wiring.

I beleve a new manual fixed this a while ago.
 
Top