newbie question


Closed Thread
Results 1 to 9 of 9

Thread: newbie question

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    This is the subroutine for 2 digit 7 segment display that I used to make a similar thing:

    DIGIT:
    B11 = B10 / 10
    B12 = B10 // 10
    LookUp B11, ( 119, 36, 107, 109, 60, 93, 95, 100, 127, 124 ), B13
    LookUp B12, ( 119, 36, 107, 109, 60, 93, 95, 100, 127, 124 ), B14
    Poke PORTC, B13
    Poke PORTB, B14
    Return

    The idea is that the number you want to display is in variable B10 when you call DIGIT. It's then split in two and sent to port c and port b. This means that 7 pins from both port b and port c are used up but it's very simple to wire up and leaves you with RB7 to run the POT command on your thermistor.

    I put this in comments:
    ' ---6
    ' ¦4 ¦5
    ' ---3
    ' ¦1 ¦2
    ' ---0
    to remind me which pin goes to which segment. The numbers in the lookup command are calculated according to which pin is connected to which segment. If you change a pin - segment connection, you will have to calculate new values for the LOOKUP command.

  2. #2
    Join Date
    Nov 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Alektric View Post
    This is the subroutine for 2 digit 7 segment display that I used to make a similar thing:

    DIGIT:
    B11 = B10 / 10
    B12 = B10 // 10
    LookUp B11, ( 119, 36, 107, 109, 60, 93, 95, 100, 127, 124 ), B13
    LookUp B12, ( 119, 36, 107, 109, 60, 93, 95, 100, 127, 124 ), B14
    Poke PORTC, B13
    Poke PORTB, B14
    Return

    The idea is that the number you want to display is in variable B10 when you call DIGIT. It's then split in two and sent to port c and port b. This means that 7 pins from both port b and port c are used up but it's very simple to wire up and leaves you with RB7 to run the POT command on your thermistor.

    I put this in comments:
    ' ---6
    ' ¦4 ¦5
    ' ---3
    ' ¦1 ¦2
    ' ---0
    to remind me which pin goes to which segment. The numbers in the lookup command are calculated according to which pin is connected to which segment. If you change a pin - segment connection, you will have to calculate new values for the LOOKUP command.
    Thanks for ur idea.i would like to ask u some question.Can i know what is the meaning of Poke command?Can u show me the example how to calculate the numbers in lookup command?What is the meaning of B12 = B10 // 10?

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Lcj100 View Post
    Can u show me the example how to calculate the numbers in lookup command?What is the meaning of B12 = B10 // 10?
    You have to think binary to figure out the numbers in the lookup table, so here goes . . . take a port to drive displays, I pick PortB
    connect the segments to the port, to make it easy on myself, I will select ports in numerical/alphabetical order, so PortB.0 is segment A, PortB.1 is segment b, PortB.2 is segment C . . . . Now to make zero you must illuminate the following segments: abcdef, which means portsB 012345 which translates to %00111111 or decimal 63 or hex 3F. The number 1 would be binary %00000110 or Dec. 6 or Hex 06 and so on and so forth.
    Last edited by Archangel; - 2nd February 2009 at 05:02.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Can i know what is the meaning of Poke command?
    Poke is a PBC statement (still usable in PBP) who write to a specific register.

    POKE PORTB, 10

    will write 10 to PORTB

    In PBP, you may reduce it to
    PORTB=0
    add a semicolon at the end of the line and it's in C

    // is the modulus.
    PBP performs 16x16 division. The '/' operator returns the 16-bit result. The '//' operator returns the remainder. This is sometimes referred to as the modulus of the number.

    Example

    W1 = W0 / 1000 ‘ Divide value in W0 by 1000 and place the result in W1
    W2 = W0 // 1000 ‘ Divide value in W0 by 1000 and place the remainder in W2
    Last edited by mister_e; - 2nd February 2009 at 05:07.
    Steve

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

Similar Threads

  1. Newbie 74hc595 question
    By manjero in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 22nd January 2008, 22:22
  2. newbie with serial com question...
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th December 2006, 05:34
  3. Newbie Question - Info Please
    By ehoskins in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd October 2006, 14:50
  4. Greetings from Newbie and a question
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th July 2006, 15:52
  5. Newbie question
    By senojlr in forum General
    Replies: 7
    Last Post: - 11th April 2006, 21:23

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