thanks
RPM COUNTER
RPM COUNTER
i need to create a RPM counter for the bike, anybody has any example in flowcode?
thanks
thanks
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
The best way to do this is to start the timer0 interrupt with a fairly low interrupt frequency.
Then use an int variable to count the interrupts. Using the interrupt frequency you can calculate how many timer0 interrupts occur in a minute.
While the timer0 is counting you can count pulses in your main program to detect the revolutions on the wheel. Each time that a minute has occured you will need to display the revs and then reset the rev counter.
To get refresh rates of less then 1 minute you can count say a second of timer0 interrupts and then times that value by 60.
Then use an int variable to count the interrupts. Using the interrupt frequency you can calculate how many timer0 interrupts occur in a minute.
While the timer0 is counting you can count pulses in your main program to detect the revolutions on the wheel. Each time that a minute has occured you will need to display the revs and then reset the rev counter.
To get refresh rates of less then 1 minute you can count say a second of timer0 interrupts and then times that value by 60.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Thanks Benj, but the algoritm is simple
RPM = RPS * 60
but i have 3 problems when de program run in the Pic 16F648A
1 Problem
Im determine the clk Freq TMR0 inf 76hz (1sec = 76) but in the pic the run too fast ..!!

2 Problem
when TMR0 interrupt im disabled while calc the RPS and RPM. and enabled when finish, this is correct?

3 Problem
Im conected a reed switch to RB0/INT and i have a problem with the edge, im use a Flag to not count until the edge change to 0 to 1 and not count when the RB0 mainteined a 1, but in simulate run ok , but in the micro no.!

Thanks
RPM = RPS * 60
but i have 3 problems when de program run in the Pic 16F648A
1 Problem
Im determine the clk Freq TMR0 inf 76hz (1sec = 76) but in the pic the run too fast ..!!

2 Problem
when TMR0 interrupt im disabled while calc the RPS and RPM. and enabled when finish, this is correct?

3 Problem
Im conected a reed switch to RB0/INT and i have a problem with the edge, im use a Flag to not count until the edge change to 0 to 1 and not count when the RB0 mainteined a 1, but in simulate run ok , but in the micro no.!

Thanks
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello
1) Do your clock settings in Flowcode match your hardware crystal speed.
2) You should not have to disable the timer interrupt. Every time you disable and re-enable the interrupt you will gain time as the timer0 is reset every time it is enabled.
3) Are you sure that your hardware is working as expected. Remember that you need either a pull up or pull down resistor so that the I/O pin is not floating when the switch is not active.
1) Do your clock settings in Flowcode match your hardware crystal speed.
2) You should not have to disable the timer interrupt. Every time you disable and re-enable the interrupt you will gain time as the timer0 is reset every time it is enabled.
3) Are you sure that your hardware is working as expected. Remember that you need either a pull up or pull down resistor so that the I/O pin is not floating when the switch is not active.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello
I have posted an example here.
http://www.matrixmultimedia.com/softwar ... _1_Sec.fcf
You cannot acheive an exact devision into a second when using the 10MHz crystal.
current second delay = 1.147 seconds
If you need an exact second measurement then you will have to use a timing crystal such as 32KHz or 19.6608MHz to allow the interrupt to devide exactly into a multiple of 1Hz.
I have posted an example here.
http://www.matrixmultimedia.com/softwar ... _1_Sec.fcf
You cannot acheive an exact devision into a second when using the 10MHz crystal.
current second delay = 1.147 seconds
If you need an exact second measurement then you will have to use a timing crystal such as 32KHz or 19.6608MHz to allow the interrupt to devide exactly into a multiple of 1Hz.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Rotlen
Both the RS232 and the TMR0 should run when the watchdog is disabled. If you are haiving problems then please send me your program and I will take a look for you.
Both the RS232 and the TMR0 should run when the watchdog is disabled. If you are haiving problems then please send me your program and I will take a look for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Ah brilliant so it is.
Glad you have it sorted now.
Glad you have it sorted now.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Kirstom14
Have you had a look at the above flowcode example program.
Have you had a look at the above flowcode example program.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
quote="Benj"]Hello Kirstom14
Hi Benj,
I try to write in good english. But sorry for difficulties to read me.
I made a little prog with timer0 overflow , i can to generate the C program. But when i want to try my prog in picmicro V3, it doesn't work ....
i don't know why and i don't see why too.
Could you help me, please.
I would like to send you my flowcode prog but how?
Thanks
arnaud
Return code = 1 Have you had a look at the above flowcode example program.[/quote]
Hi Benj,
I try to write in good english. But sorry for difficulties to read me.
I made a little prog with timer0 overflow , i can to generate the C program. But when i want to try my prog in picmicro V3, it doesn't work ....
i don't know why and i don't see why too.
Could you help me, please.
I would like to send you my flowcode prog but how?
Thanks
arnaud
Return code = 1 Have you had a look at the above flowcode example program.[/quote]
my project
Hello Steve,
My file is converted but when I transfer it, it doesn't work on the picmicro V3;
Could I send you my file or printscreans of my program?
Thanks
Arnaud
My file is converted but when I transfer it, it doesn't work on the picmicro V3;
Could I send you my file or printscreans of my program?
Thanks
Arnaud