08M Anemometer with 2x 7 segment displays

Janne

Senior Member
Hi!

I've been playing with the idea of making an anemometer for my homebrewn wind turbine for a while now. For the anemometer i was planning to use a normal 3 cup rotor, and i'd measure the speed of the anemometer with an optoslot inside, giving 1 pulse / revolution.

For windspeed indication i planned to use 2 seven segment displays, driven by 2x 74ls164 shift register ic's. The 2 displays would show the windspeed in m/s.

The program would consist of measuring the pulses for 5 seconds, and then converting the recorded value directly to windspeed. After that the speed would be displayed with the 2 7 segment displays.

I haven't yet built anything to this project, I just wrote up the code and designed the circuit. Comments and improving ideas are very welcome at this point.

Code:
'anemometer. shows the windspeed in m/s in with 2 seven segment displays.
'displays are driven with 2x 74ls164 shift registers
'this assumes anemometer tip speed is 1 : 1 with the windspeed.


symbol clk 	 = 0 'clock for the 74ls164 shift registers
symbol out   = outpin1 'data out to shift register
symbol en1   = 2 'enable register 1
symbol en2   = 4 'register 2
symbol pulse = 3 'input from the anemometer

symbol r = 94 'circumference of the anemometer rotor is set in cm's here
symbol counter1 =w6
symbol display1 =b1 'tens
symbol display2 =b2 'units
symbol number   =b3
symbol temp     =b0
symbol i        =b5



let dirs = %00010111 'set 0-2 as outputs, 3 as input and 4 as output

start:

count 3, 5000, counter1 'count pulses from anemometer for 5 secs.
let counter1 = counter1 * r
let counter1 = counter1 / 500 'divide by 5 * 100, 100 because of the cm's (to get m/s speed)
' and 5 because of 5 second measuring time.
let display1 = counter1 / 10  'divide the couter's value by 10 to get the tens
let display2 = counter1 // 10 ' return the modulus of the divide to display 2 


let number = display1
gosub assign
let display1 = temp

let number = display2
gosub assign
let display2 = temp

'display ones
high en2	'enable shift register 2
gosub display
low en2

'display tens
let temp = display1
high en1	'enable shift register 1
gosub display
low en1

goto start 

display:

for i = 0 to 7
let out = bit0 'use the lsb of temp variable as output 
pulsout clk,1
let temp = temp / 2
next i

return

'	   1	
'	 ----
'	|    |
'   2 |   3|
'	| 4  |
'	|----|
'	|    |
'    5|   6|
'	| 7  |
'	 ----



assign: 		'assign pinout to a number here, for correct display in 7 segment.

	if number=0 then
	temp = %01110111 
	endif
	
	if number=1 then
	temp = %00100100 
	endif
	
	if number=2 then
	temp = %01011101 
	endif
	
	if number=3 then
	temp = %01101101 
	endif
	
	if number=4 then
	temp = %00101110 
	endif
	
	if number=5 then
	temp = %01101011 
	endif
	
	if number=6 then
	temp = %01111011 
	endif
	
	if number=7 then
	temp = %00100101
	endif
	
	if number=8 then
	temp = %01111111
	endif
	
	if number=9 then
	temp = %01101111
	endif
	
return
 

Attachments

Top