Time to consider using interrupts for this. Increment within the interrupt. Keep it small and fast!! I don't recall if the 88 has interrupts on portB.3
Time to consider using interrupts for this. Increment within the interrupt. Keep it small and fast!! I don't recall if the 88 has interrupts on portB.3
I would suspect the "light-to-voltage sensor". Most of these have response times in the millisecond range, maybe too slow.
I am not sure how interrupt can help in this case.
At slow speed the counter works, but at higher speeds it does not pick half the time or more.
I reduced the pause time to 20 after the LCDout, that did not help.
K
Hi lerameur,
I would use a photo transistor and not a photocell, a Crystal or resonator running at 20 mhz rather than intosc @ 4mhz. those things might speed things up a bit. You might use interrupts to capture counts and display on an as time permits basis instead of watching every count.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Hi,
I am using this little baby for a sensor
http://www.taosinc.com/productdetail.aspx?product=63
I think i will user TMR0 in my program
K
I was thinking . . . make a subroutine called display and do this:
if OldOutput_Pot == Output_Pot then
gosub display
then do your lcd routines in there, it would display any time the counter stops incrementing.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Well, the reason for suggesting an interrupt is simple. When you poll, you spend a finite time in checking the state of the input. If you miss this(fast revolutions), you will miss counts. However, if you use interrupts, you can be sure to catch a significantly higher number of pulses than you could using the poll technique. example - you may be able to read upto 20pulses per second using the poll techniqe, but upto 200 pulses per second or even more using interrupts.
Simple analogy to understand the difference between interrupts and polling.
Think of yourself seated at the PC doing some work. The time you take to respond to a person at the door is your 'poll time' and depends on what you are doing at the moment and how soon it will finish. This would be similar to checking every now and then to see if there is someone at the door.
On the contrary, if the person rings a doorbell (interrupts). You know that the door needs to be opened because of this signal. The way the processor handles it is to finish the current 'instruction' that it is executing and respond to the bell. This is much much faster than the earlier technique of checking the door now and then.
Please don't mind the over-simplification. It might help someone else understand.
I also second the idea that the opto interrupter may not be fast enough. But, from my experience, they work well into the KHz range.
I suggest your Main loop should just display the counts and the interrupt routine should just count.
Bookmarks