Shop OBEX P1 Docs P2 Docs Learn Events
Need help in writing program to do a Hex translation — Parallax Forums

Need help in writing program to do a Hex translation

DennisDennis Posts: 4
edited 2008-09-04 17:14 in BASIC Stamp
Help please and thanks!
·
I understand electronics but not programming.
·
·I am using a Basic Stamp 2 and I need a program to a Hex translation. I need to enter any four bit Hex number between 0001 and 1100 at four input pins, the number would then be translated to a corresponding, but different, four digit Hex number that would be available at four output pins.· It is preferred but not a requirement, that an “0” correspond to a low on both the input and out put.· It would be great if the program could be stored in the EEPROM so that it would not be lost when power is lost to the circuit.· After a power outage and the power is restored the circuit would again operate without any intervention on my part.
·
Thanks again!
·
Dennis
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
····

Post Edited (Dennis) : 9/4/2008 4:34:36 AM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-09-04 00:34
    All programs are stored to EEPROM so that isn't a problem. You could always just wire the inputs to the coresponding outputs eliminating the stamp and save yourself time and money.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • stamptrolstamptrol Posts: 1,731
    edited 2008-09-04 12:20
    You'll probably be able to do this without too much trouble.

    To give us better information to work with:
    - where does the input number come from? switches, serial data, manually input?
    - when you say "translated", what operation are you performing on the the input number? adding a fixed number, adding the input number to some other variable input number, shifting bits left or right?
    - as mentioned, the program is automatically saved to eeprom, so that's no problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • DennisDennis Posts: 4
    edited 2008-09-04 16:57
    Sorry, I didn’t think about how little information I had provided.·
    ·
    The input would be serial and the output would be parallel.· I am coming out of a DTMF receiver which is serial and into the parallel input of a 4 X 4 matrix switch.· The BS2 would store the bits until the complete four bit address was received and then send the translated address as output to the matrix switch for 10 milliseconds ( time not critical) then the address would be cleared from the BS2· and it would be ready to receive a new address.· I need to do the translation to get the correct X - Y output that I need from the matrix switch.······
    ·
    I believe it would be a Look Down, Look Up design as follows:
    ·
    IN ·················· ··········· OUT
    ·
    0001··············· ··········· 0000
    0010··············· ··········· 0010
    0011··············· ··········· 0001
    0100··············· ··········· 1000
    0101··············· ··········· 1010······· ·
    0110··············· ··········· 1001
    0111··············· ··········· 0100
    1000··············· ··········· 0110
    1001··············· ··········· 0101
    1010··············· ··········· 1110
    1011··············· ··········· 1100
    1100··············· ··········· 1101
    ·
    If you are kind enough to help me you only need to enter the first several addresses so that I will understand how and I can enter the remaining addresses.

    If you do not have time to help me please let me know and I·will make a new posting with the additional information.·

    Thanks for the reply letting me know how little information·I had provided,· when providing the additional information I now realize the·program·will require several more lines of code than I had initially·thought.

    I had attempted to do a simple parallel in parallel out Look Down, Look Up design as my first design; however, I have not been able to get even that to work.· I have only had my STAMP for about a week and decided to incorporate in into·some of my electronic designs.

    Thanks again!

    Dennis
    ·
    ·
  • stamptrolstamptrol Posts: 1,731
    edited 2008-09-04 17:14
    Ah, makes much more sense.

    Consider the numbers in the input column in their decimal form ( 0 - 15). Let that be the index of the LOOKUP command. See the Help file under LOOKUP.

    The "values" in the LOOKUP command will be the translated values you show in the OUT column.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
Sign In or Register to comment.