Counting with a Pic 16f88 <--NOOBIE

Status
Not open for further replies.

KeepAndBearArms

New Member
Hello All,
I'm new to the pic family of controllers. I've done a lot with Basic Stamps and I'm trying to make this 16f88 Count the speed of my mini-lathe via a hall-effect sensor. With Pbasic there is a simple count command but the compiler I'm using "Oshon basic" There is no count command. Any help would be greatly appreciated.

TIA
Jesse
 
Being the control freak that I am, I don't use basic, I use assembler, that way you know exactly what's what, where etc.

My daft example here uses a timer and interrupt on change, and assuming the lathe isn't going faster than 65535 rpm you'll be fine.

clear 4 regs, call em something like count_low, count_high, rpm_low, rpm_high
set your timer interrupt for a 1 sec period
each time your interrupt occurs check to see whether it was an interrupt on change, or a timer overflow.
If it was an interrupt on change
then add 1 to count_low
check to see if count_low has overflowed
if it has add 1 to count_high
check to see if count_high has overflowed
if it has, set an led on to indicate lathe is outta control
if it was a timer overflow interrupt then
multiply your counter value in both count_low and count_high by 60
to give you rpm and store it somewhere like rpm_low and rpm_high
reset your timer for a 1 sec period
clear your counters again
display your rpm
back to main code loop till next interrupt

I hope this gives you some ideas...
 
Thanks for the info but my knolwdge of Assemble language is verry minimal at best. Could you give me an example of the code that I could experement with. Thanks again



Jesse
 
Unfortunately I'm kind of tied up with work just now, if I get a chance I'll write up something for you, perhaps I'll get one of the free basic lite type progs and use that, perhaps you'll understand it a little better.
 
Just a quick note...

The free MikroBasic package has example code for a Rev Counter, maybe you can adapt it for your needs...
 
Thanks for the feedback - figured it out

I just had to learn about Timers and interupt. After that all I needed to do is use Rb0/int as my input and count the number of interupts in a given timer

Thanks again.

Jesse
 
this might be of help....

"Procedure for correlating main rotor and tail rotor RPM on the Rotorway 162F helicopter with the ATOM micro-controller"

at

https://www.electro-tech-online.com/custompdfs/2006/11/RRPM.pdf

the atom is basically a pic 16f876 and any program for the atom should work for the pic as well.... hope that this helps you.

P.S. the atom and Mbasic are very good, they have an excellent book also in the online shop. !!!!BUT!!! the tech support would need a boost and a ladder to be in the gutter....

my 2 cents
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…