Hello Mister_e,
Mister_e>>What i suggest is to take more than 1 reading (why not 10) and do the average of them. Send your result to Lcd and see what happen and how different they are. <<
this may be the way to go. Take about 10 readings, or enough readings to where a "WORD" would not be overloaded.
for x=1 to 10;
Pulsein pin1, 1,Reading;
Accu=Accu+Reading;
next x;
Accu=Accu/10;
if(abs(Accu-22.5)>4) then NoTone
if(Abs(Accu-21.5)<=1) then LowTone
if(Abs(Accu-23.5)<=1) then HighTone
Or possibly leaving it as a larger number with bigger spreads:
for x=1 to 10;
Pulsein pin1, 1,Reading;
Accu=Accu+Reading;
next x;
if(abs(Accu-225)>40) then NoTone
if(Abs(Accu-215)<=10) then LowTone
if(Abs(Accu-235)<=10) then HighTone
Mister_e>>Now for the amplitude problem... in fact it will be a problem if your signal amplitude vary due to the threshold of the PIC input. a voltage comparator or OP AMP to clip the signal will not solve the problem. for the reasons that Melanie already said. But experiment this and let me know.<<
I will try your capacitor thing and see what happens.
the next thing I must find out, is how the PBP handles the switch/case statements. After it finds the case statement that workds, does it jump to the end switch? Or does it continue processing the rest of the case statments to see if another case statement is going to be used. I am goin to have a rather large switch case statement, and "timing" is goin to be critical. I guess Idon't want the compiler to jump to the end switch after the first case statement, and go through a million others before the next case statement is found. <g>. That can throw timing off... Maybe I am being too picky <g>.
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Bookmarks