![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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... | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| Thats cool Could you recomend a good book pic assemble language. Jesse | |
| |
| | (permalink) |
| Just a quick note... The free MikroBasic package has example code for a Rev Counter, maybe you can adapt it for your needs... | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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
__________________ Sex is like math You add the bed Subtract the clothes Divide the Legs And Pray you don’t multiply | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| 16F88 Code protected question | RonnyBone | Micro Controllers | 6 | 30th October 2006 09:30 AM |
| Simple Counting Circuit | jbchrist | Electronic Projects Design/Ideas/Reviews | 5 | 9th September 2004 10:55 PM |
| 6V to 16F88 to much? | brodin | Micro Controllers | 3 | 12th March 2004 05:08 PM |
| 16F88 internal oscillator problems | Jimbob's Ma | Micro Controllers | 1 | 1st March 2004 10:28 PM |
| Need Help for counting a circuit's value, need ASAP thx.. | 23401040 | General Electronics Chat | 5 | 18th December 2003 03:18 AM |