Tachometer code problems.


Closed Thread
Results 1 to 7 of 7
  1. #1
    PICy's Avatar
    PICy Guest

    Default Tachometer code problems.

    Hello.

    My ebay purchase came through the door this morning - A PIC programmer & PICBasic Compiler v1.44 :-)

    After a lot of confusion i managed to get PBC working with CodeDesigner Lite, but i havent managed to get much further!

    I have done a lot of programming in the past, and the samples i have read shouldnt be too hard to get my head around.

    My first project (after the blinking light etc) is to make a tachometer. I have been reading up and think that 'pulsin' will be the best way to go, but im not sure. I am a little confused as half of the resources i have found for 'PICBasic' have either returned PBP, or other types of PICBasic. e.g. i spent a while reading up on variables, 'Dim myvar as Byte' and 'myvar VAR BYTE' didnt work, it took a while for me to realise that it probably wasnt my fault! Also, many people making tachometers have used a 'Count' command, but i dont think that exists in PBC either!

    My questions are basically;

    *Would pulsin be the best thing to use?
    *Are variables just refered to as B0, W1 etc? (using 'Symbol' to name them)
    *What happens if a number is too big to fit into a variable? Will the number overflow into the next var, or will only the left hand side be stored?


    Thank you for your time!
    PICy



    P.S. Is it just me, or can nobody post in the mel PIC BASIC board?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > My questions are basically;

    > *Would pulsin be the best thing to use?

    Not really although you could. Pulsin returns the PERIOD of the pulse (ie it's duration), it does not tell you how many Pulses you're going receive in any given time period. If you're going to measure a High Pulse and a Low Pulse, sum them together, you can then 'guesstimate' that your running at 'x' Hertz, but really it will be no better than a guess.

    It would be better to COUNT, but since PBC hasn't got that feature (at least it hasn't in my manual), it would be more sensible to start a Clock (ie TMR1) and Count the number of pulses that are received in say 100mS.

    > *Are variables just refered to as B0, W1 etc? (using 'Symbol' to name them)

    Not having PBC, then again according to the manual it looks like you've only got variable B0-Bx (as Bytes), and W0-Wx (as Words). You can rename them to whatever is convenient, and I would certainly recommend you do so... example...

    Symbol TachoCount = B0

    See 2.8.2 in the PBC manual.

    > *What happens if a number is too big to fit into a variable? Will the number overflow into the next var, or will only the left hand side be stored?

    It'll roll thrugh zero and start counting all over again (ie only the relevant significant digits - be they eight or sixteen - are stored)...

    eg (for a Byte)..

    $FD, $FE, $FF, $00, $01, $02 etc..

    or if it's a Word...

    $FFFD, $FFFE, $FFFF, $0000, $0001, $0002 etc

    There is no flag or other indication to say it's done so... but a bit of math will tell you if you've blown the limit...

    B2=B0+B1
    If B2 < B0 then goto Overflow

    If you're adding two numbers together, the the sum must be 'equal to' or 'more than' that what you started with... if it's 'less than', then you've overflowed.

    Melanie

    PS. eBay purchases are a little tricky as I don't think you've got a supported upgrade path according to MeLabs unless the seller is an authorised Distributor.

  3. #3
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    1,033


    Did you find this post helpful? Yes | No

    Default

    The mel PICBASIC forum is active for new posts now.

    sorry, I did not know it was inactive untill PICy mentioned it. I thought there was no interest!

  4. #4
    PICy's Avatar
    PICy Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you for your help! You have cleared up a number of issues that would have had me confused for hours :-)

    On the ebay note, i plan to buy PIC Basic Pro when i get the money. It seems much better than PBC

    Thanks again for your help!
    Last edited by PICy; - 30th October 2004 at 20:53.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    PICy,
    i really don't suggest you to buy any at EBAY. chances are 99.9% that you'll not be able to update it after if, of course, the disk you'll receive is working.

    Too many people use this crapy site to buy for cheap.... that's o.k to save money i agree. but for a program like PIcBasic Pro... see this

    http://www.melabs.com/support/upgrade.htm

    i think that EBAY is agood place if you want to spend money on already used stuff (sale for new one for ¼ regulare price) As i say often, it's a good junk yard
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    PICy's Avatar
    PICy Guest


    Did you find this post helpful? Yes | No

    Default

    I didnt buy from ebay for the software, i got it for the programmer ;-)

    At the time i intended to use ASM, but i thought as i had it, i may as well try it.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    >I didnt buy from ebay for the software, i got it for the programmer ;-)

    OUF ... smart move. Wich programmer you get ?

    >At the time i intended to use ASM, but i thought as i had it, i may as well try it.

    you can have a free limited version of PBP there.
    http://compilespot.com/startdemo.htm

    May i suggest you MicroCode Studio (free version) as shell to put your code instead of CodeDesigner??

    http://www.mecanique.co.uk/code-studio/index.html

    regards
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Line following robot... problems with some code
    By nepstar in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th March 2005, 01:10
  4. Code dsigner lite problems
    By toalan in forum Off Topic
    Replies: 2
    Last Post: - 23rd February 2005, 20:08
  5. Tachometer code problems.
    By PICy in forum mel PIC BASIC
    Replies: 3
    Last Post: - 28th January 2005, 15:29

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts