Displaying numbers


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425

    Default Displaying numbers

    Hi,

    In part of my code I am using variables b1, b2 and b3. What I am trying to do is this:

    b1=1
    b2=3
    b3=5

    tach=b1,b2,b3

    When I go to complile it, it keeps giving me an error.

    Can anyone help me with this?

    Thanks,

    Chris

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    I'm guessing that in this example you want 'tach' to end up being 135?

    So you'd want b1 to be the 100's place of tach, b2 to be the 10's place, and b3 to be the 1's place, is that correct?

  3. #3
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    Yes, that is correct. When I display it to a LCD display, this works correctly when I use the DEC command. I have tried everything and still can't get it.

  4. #4
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    How about

    tach = (b1*100)+(b2*10)+b3


    Why are you speciying the digits individually ?

    Whats wrong with....

    tach = 135 'or whatever

    LCDout DEC tach ' which would suppress leading zeros eg 135 or 79 or 4

    LCDout DEC3 tach ' which would always display 3 digits. eg 135 or 079 or 004
    Keith

    www.diyha.co.uk
    www.kat5.tv

  5. #5
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply. I never thought of doing tach = (b1*100)+(b2*10)+b3 and this will work perfect! The problem is that the numbers are coming over a wireless link and I am having trouble sending word variables. I know these are byte variables but it is only an example. Anyhow, the variables are not going to an LCD display. This is a great temporary solution until I can find out how to send word variables over a wireless link.

    Thanks!

  6. #6
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Be sure not to overflow your variable type with the calculation
    tach = (b1*100)+(b2*10)+b3

    Arch

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


    Did you find this post helpful? Yes | No

    Default

    Arch... it would not be possible to overflow a word with that formula...

  8. #8
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie
    Arch... it would not be possible to overflow a word with that formula...
    Guess I should have been more specific about that - I meant if he was using a byte variable. (but now I see that he mentioned a word-sized variable - DUH!)

    Arch

  9. #9
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    "This is a great temporary solution until I can find out how to send word variables over a wireless link."

    If you can send bytes then you can send words.

    When you send just break the words into bytes.

    tach var word

    tach.lowbyte = high byte of word
    tach.highbyte = low byte of word

Similar Threads

  1. Joining variables and displaying on an LCD
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th April 2009, 04:12
  2. Replies: 4
    Last Post: - 15th April 2009, 01:54
  3. Working with 3 byte numbers
    By Josuetas in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th July 2007, 22:59
  4. Splitting numbers and recombining them(EEPROM Error)
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd June 2007, 06:40
  5. Returning whole numbers for DS1820?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th February 2007, 12:15

Members who have read this thread : 0

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