hello all its been a while since i have posted here but i am once again working on a new project. im using an 18m2 to measure and output wind speed so that i can tell how fast i am going whilst on my longboard. i have the 18m2 hooked up to two 7 segment displays and i have the code written so that it will display the value of the variable b0 from 0 to 69(after 69 it shows "--"), i figured that i wouldnt be going any faster than 69mph or kph on my longboard so i just cut it off. npw if have the 18m2 read the voltage output by the fan it gives me a value, but i would rather use the existing tachometric signal(yellow wire) coming off of the fan to tell me what rpm it is running at, as presume that would be more accurate. another advantage is that there is no chance of the fan generating too much voltage and going out of readable range or damaging my circuit.
anyways my problem is that when i spin the fan by blowing on it it doesnt register to the chip and it just displays 00(i tested the display it works and it can display all the way from 00 to 69. i also tested the fan it is outputting the correct tachometric signal.)
heres my code and i apprediate any help(for the record it works correctly when reading from the adc on b.7, i just swap the code "count b.7,100,w0" out for "readadc b.7,w0)
another question: the count command can be used on any input pin correct?
i will post a schematic soon .
anyways my problem is that when i spin the fan by blowing on it it doesnt register to the chip and it just displays 00(i tested the display it works and it can display all the way from 00 to 69. i also tested the fan it is outputting the correct tachometric signal.)
heres my code and i apprediate any help(for the record it works correctly when reading from the adc on b.7, i just swap the code "count b.7,100,w0" out for "readadc b.7,w0)
Code:
disconnect
measure:
count b.7,100,w0
pause 1000
w0 = w1/10
gosub tens
gosub digits
goto measure
tens:
if w0=0 then gosub oh
if w0=1 then gosub ten
if w0=2 then gosub twenty
if w0=3 then gosub thirty
if w0=4 then gosub forty
if w0=5 then gosub fifty
if w0=6 then gosub sixty
if w0>6 then goto error1
return
digits:
w3=w0*10
w2=w1-w3
if w2=0 then gosub zero
if w2=1 then gosub one
if w2=2 then gosub two
if w2=3 then gosub three
if w2=4 then gosub four
if w2=5 then gosub five
if w2=6 then gosub six
if w2=7 then gosub seven
if w2=8 then gosub eight
if w2=9 then gosub nine
return
error1:
let pinsb = %00000000
let dirsb = %00001000
let pinsc = %00000000
let dirsc = %00111100
high c.3
goto measure
zero:
let pinsb = %00000000
let dirsb = %01110111
return
one:
let pinsb = %00000000
let dirsb = %01000100
return
two:
let pinsb = %00000000
let dirsb = %00111110
return
three:
let pinsb = %00000000
let dirsb = %01101110
return
four:
let pinsb = %00000000
let dirsb = %01001101
return
five:
let pinsb = %00000000
let dirsb = %01101011
return
six:
let pinsb = %00000000
let dirsb = %11111011
return
seven:
let pinsb = %00000000
let dirsb = %01000110
return
eight:
let pinsb = %00000000
let dirsb = %01111111
return
nine:
let pinsb = %00000000
let dirsb = %01101111
return
oh:
let pinsc = %00000000
let dirsc = %11100011
low c.3
return
ten:
let pinsc = %00000000
let dirsc = %10000010
high c.3
return
twenty:
let pinsc = %00000000
let dirsc = %11000101
high c.3
return
thirty:
let pinsc = %00000000
let dirsc = %10000111
high c.3
return
forty:
let pinsc = %00000000
let dirsc = %10100110
low c.3
return
fifty:
let pinsc = %00000000
let dirsc = %00100111
low c.3
return
sixty:
let pinsc = %00000000
let dirsc = %01100111
low c.3
return
i will post a schematic soon .