+ Reply to Thread
Results 1 to 8 of 8

Thread: Counting with a Pic 16f88 <--NOOBIE

  1. #1
    KeepAndBearArms Newbie
    Join Date
    Nov 2006
    Posts
    7

    Default Counting with a Pic 16f88 <--NOOBIE

    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


  2. #2
    tunedwolf Newbie
    Join Date
    Aug 2006
    Location
    UK
    Posts
    422

    Default

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

  3. #3
    KeepAndBearArms Newbie
    Join Date
    Nov 2006
    Posts
    7

    Default

    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

  4. #4
    tunedwolf Newbie
    Join Date
    Aug 2006
    Location
    UK
    Posts
    422

    Default

    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.

  5. #5
    KeepAndBearArms Newbie
    Join Date
    Nov 2006
    Posts
    7

    Default

    Thats cool
    Could you recomend a good book pic assemble language.

    Jesse

  6. #6
    tunedwolf Newbie
    Join Date
    Aug 2006
    Location
    UK
    Posts
    422

    Default

    Just a quick note...

    The free MikroBasic package has example code for a Rev Counter, maybe you can adapt it for your needs...

  7. #7
    KeepAndBearArms Newbie
    Join Date
    Nov 2006
    Posts
    7

    Default 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

  8. #8
    VBguru Newbie
    Join Date
    Nov 2006
    Posts
    21

    Default

    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

    http://www.basicmicro.com/downloads/docs/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

+ Reply to Thread

Similar Threads

  1. 16F88 Code protected question
    By RonnyBone in forum Micro Controllers
    Replies: 6
    Latest: 30th October 2006, 08:30 AM
  2. Simple Counting Circuit
    By jbchrist in forum Electronic Projects Design/Ideas/Reviews
    Replies: 5
    Latest: 9th September 2004, 09:55 PM
  3. 6V to 16F88 to much?
    By brodin in forum Micro Controllers
    Replies: 3
    Latest: 12th March 2004, 04:08 PM
  4. 16F88 internal oscillator problems
    By Jimbob's Ma in forum Micro Controllers
    Replies: 1
    Latest: 1st March 2004, 09:28 PM
  5. Need Help for counting a circuit's value, need ASAP thx..
    By 23401040 in forum General Electronics Chat
    Replies: 5
    Latest: 18th December 2003, 02:18 AM

Tags for this Thread