Page 1 of 1

RPM COUNTER

Posted: Sun Oct 14, 2007 1:06 am
by rotlen
i need to create a RPM counter for the bike, anybody has any example in flowcode?

thanks :D

Posted: Mon Oct 15, 2007 9:24 am
by Benj
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.

Posted: Mon Oct 15, 2007 12:47 pm
by rotlen
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 ..!!

Image

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

Image

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.!

Image


Thanks :D

Posted: Wed Oct 17, 2007 9:20 am
by Benj
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.

Posted: Wed Oct 17, 2007 8:48 pm
by rotlen
Benj thank you.

Could you post a simple demo with TMR0 INT
Clock 10Mhz HS
Time Int 1 sec

Thank you

Posted: Fri Oct 19, 2007 10:09 am
by Benj
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.

Posted: Sat Oct 20, 2007 1:26 am
by rotlen
Thank you benj, the problem was the Watch Dog... :D

but now i have a new problem, i need to use TMR0 and RS232 Tx, and if WDTE is enabled dont run the rs232 and if WDTE is disabled dont run TMR0.

what can i do? :shock:

Posted: Tue Oct 23, 2007 10:00 am
by Benj
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.

Posted: Tue Oct 23, 2007 10:33 pm
by rotlen
Benj the problem is in TMR0.clock source select .!!

sorry :(

Posted: Wed Oct 24, 2007 9:30 am
by Benj
Ah brilliant so it is.

Glad you have it sorted now.

Posted: Thu Nov 15, 2007 12:49 pm
by kirstom14
Hi,
I want to create a rpm counter for an anemometer, and then i must convert the rpm to m/s. I am using a 16F877A microprocessor. Can you tell how how I can do it using Flowcode? Thanks

Posted: Thu Nov 15, 2007 1:49 pm
by Benj
Hello Kirstom14

Have you had a look at the above flowcode example program.

Posted: Wed Dec 05, 2007 11:44 pm
by arnaud
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?

:roll:

Thanks

arnaud
Return code = 1 Have you had a look at the above flowcode example program.[/quote]

    Posted: Thu Dec 06, 2007 11:34 am
    by Steve
    Hello Arnaud,

    Please paste the "compiler messages" error text in a message on this forum and we'll have a look.

    my project

    Posted: Thu Dec 06, 2007 3:39 pm
    by arnaud
    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

    Posted: Thu Dec 06, 2007 4:44 pm
    by Steve
    We can't really offer support for your own programs. Have you been able to send a very simple program to your chip?

    Common errors when programs don't run on the chip are:
    * inappropriate configuration options, especially the clock setting and WDT
    * wrong timing calculations