Re: Slow speed tachometer
Immediately I see that you have not put a "%" before your binary values - this is required. Check at each register assignment.
1 Attachment(s)
Re: Slow speed tachometer
Interesting!
But i have, it seems that if i copy/paste they disapear.
By the way i use PBP 2.60 and microcode studio 4, and the schema goes like this:
Attachment 7308
Re: Slow speed tachometer
a few thoughts :-
1, INTCON.7 "GIE" and INTCON.6 "PEIE" probably need to be set
2, this piece of code can never execute because its orphaned
RESUME ' Return to main program
ENABLE ' Enable interrupts
TMPlowbyte = 0 ' Variable reset
PIR1.0=0 ' Reset TMR1's Interupt Flag
TMR1Overflow = 0 ' Reset TMR1 Overflow counter
END ' End of program
3, the " on interrupt " latency is variable and unpredictable and is unlikey to give accurate results.
dt interrupts is vastly better.
4, for your purposes rpm measurement using "pulsin" is far simpler to do and a lot easier to get working.
Re: Slow speed tachometer
My goal is to use timer0 to refresh the 7 segment displays, and use timer1 free running so i can count the pulses from portb.7 so i think setting interrupts for timer1 won't be nedded. The part that captures TMR1L and calculates RPM, is the one that is giving me problems.
with your t1con setting the max period for TMR1 is 524.295 mSec : not enough
tmr1 is 16 bits just reading TMR1L will not work.
if you leave tmr1 free running you need to read ITS 16 bit value at "say the leading edge " of the timing pulse
then read the timer again at the next "leading edge" and calculate the difference (maybe check and clear the overflow also).or start the timer on "say the leading edge " and stop it on the next . either way you need to sync up with the timing pulse
the other way is to count the timing pulses over a fixed timebase , in this case you would need some tens of seconds to get meaningfull results.
Can you explain me better the part of tho orphaned code?
the isr returns to the main loop after the RESUME /ENABLE
any code after that will never run ever
From what i have read, and correct me if i'm wrong, since i'm trying to aquire a signal near 0.625hz, those command won't serve my purposes.
correct , can you modify the machine to get 2 pulses per rev ?
Re: Slow speed tachometer
Perhaps I do not wholly understand your purpose, but why is it necessary to use a timer for the display? It seems (from what I understand of your intent) that something like the pseudo-code below would suffice:
Code:
Set up interrupt on complete rotation
Set up interrupt on Timer1 overflow
RPM = 0
Main:
If (button pushed) and (Flag = 0) enable interrupts and Flag = 1
if (button pushed) and (Flag = 1) disable interrupts and Flag = 0
For Digit = 1 to 3 'multiplex display
PORTA.Digit = 1
Lookup
.
.
.
PortA.Digit = 0
Next Digit
XXXXXXX 'No pause here, it slows interrupts
Goto Main
On Timer1 Overflow:
Timer1Overflows = Timer1Overflows + 1 'Timer0 may be used here, but will result in a higher multiplier
Resume
On rotation interrupt:
RPM = Timer1Overflows * [Time to Overflow] + [Timer1 current value in mSecs]... 'Calculate new RPM
Timer1Overflows reset : Timer1 reset
Resume
I would not question, but it seems at the very slow RPM you are measuring, the frequency of updating the display will happen many times and is not nearly so critical... It will take relatively many iterations before there is new information to display and there is no benefit (as I see it) to worry so long as the loop executes fast enough to avoid flicker. It seems, if I understand you correctly, that each rotation interrupt is a full rotation and yields new RPM data or am I mistaken?
Re: Slow speed tachometer
I think you need to increase the resolution to increase the accuracy of the pulse read before 1 minute is up.
Why deal with 36 pulses per minute ? I don't know how you are breaking the IR beam but maybe you could add extra pulses using extra beam breaks.
1 pulse per revolution of conveyer "drum" wheel could be multiplied up to 10 pulses per revolution or whatever using more beam breaks on the "drum" ? Easier to read a RPM during the one minute period.
Just thoughts. :)
Re: Slow speed tachometer
Thank for all the help, i'll try to see if can manage myself.
Good programming
Re: Slow speed tachometer
Hello, tanks for all the suggestions.
Quote:
Originally Posted by
Amoque
Perhaps I do not wholly understand your purpose, but why is it necessary to use a timer for the display?
I saw one example that is based on that principle, and i tought it would to the job, but it was just an ideia.
Quote:
Originally Posted by
Amoque
I would not question, but it seems at the very slow RPM you are measuring, the frequency of updating the display will happen many times and is not nearly so critical...
I tought that too, and i increased the time to refresh to help on the task of timer1, but didn't gave any result.
First, each time i pressed the button, to simulate a rotation, it gave me completly different numbers, then nothing happend.
Quote:
Originally Posted by
Amoque
It will take relatively many iterations before there is new information to display and there is no benefit (as I see it) to worry so long as the loop executes fast enough to avoid flicker. It seems, if I understand you correctly, that each rotation interrupt is a full rotation and yields new RPM data or am I mistaken?
You are right. On booth.
The pseudo code you gave me looks simple, i'll try to build it.
Quote:
Originally Posted by
tasmod
I think you need to increase the resolution to increase the accuracy of the pulse read before 1 minute is up.
Why deal with 36 pulses per minute ? I don't know how you are breaking the IR beam but maybe you could add extra pulses using extra beam breaks.
1 pulse per revolution of conveyer "drum" wheel could be multiplied up to 10 pulses per revolution or whatever using more beam breaks on the "drum" ? Easier to read a RPM during the one minute period.
Just thoughts. :)
You are absolutly right tasmod, the problem is that i have 7 conveyours in 1 line, and 39 lines, 273 conveyours plus 193 conveyours in another zone. The conveyours are different in diameter, there are 4 types, and the shaft is visible only in the center, so i plan to break the beam with plain white paper, since the optoelectronics i'm usig where taken from a printer, the detection of paper.
With this, i'm not saing you are wrong, but to be fast enough to check the rotation of the shafts, i must not take too much time or be too complicated, althoug i only have to do it once every year