Shop OBEX P1 Docs P2 Docs Learn Events
number to bcd — Parallax Forums

number to bcd

ArchiverArchiver Posts: 46,084
edited 2002-12-21 14:41 in General Discussion
Got to be an easier way. I want to turn a variable number into a BCD number
for seven segment displays. I'm not using the decoder chip. What
suggestions can you guys offer to get a number 0-9999 into a 4 byte string.
Currently I start by dividing by 1000 to get first digit, then divide the
remainder by 100 to get the second digit etc.

I this what the DIG modifier is for?




Original Message
From: Tracy Allen [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=gW3kKVCwN53o_xrbl5YeK09H5GPAgvYzTettC7SXO4fz8KTdEsBEAFxQ8bmK10UsSsdbL7pG4IUpopc]tracy@e...[/url
Sent: Friday, December 20, 2002 1:11 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Noise on data lines...

Hi Chris,

Shield the cable. Near the Stamp, run it through an RFI bead (the
fat thing you often see on cables).

-- Tracy

>Hello all,
>I have a stamp connected to a radio frequency tag system. The serial data
>line between the RF unit and the stamp pcb has a lot of noise on it coming
>from the rf unit. Does anybody have any ideas on an effective way to remove
>the noise from the serial data line ?, or any links to sites with info on
>this ?
>Thanks
>Chris (Western Australia)

To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-12-20 19:12
    Great suggestion but then I would spend all my time at the calculator not
    machining parts.
    Sorry, I'm making an rpm gauge for my lathe and mill.
    It's not rally a stamp question cause I'm gonna make the final design using
    a pic, but Pic Basic Pro is almost Stamp.

    What I want to do it take the RPM counts input and convert that to a BCD
    string to display on 7-segs. SO I need it in bcd byte format. All serial
    output routines convert it for you using the "Dec" modifier but I need to
    use the bytes elsewhere in the program.

    Original Message
    From: Newzed@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=N1Zbf0R30hVMhJnEjqosP_sMrTwg5_hizyhFcMNhDfxueDeF6zF3DvJGqPgx27iL2xTzS8OBzySo]Newzed@a...[/url
    Sent: Friday, December 20, 2002 2:18 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] number to bcd

    In a message dated 12/20/2002 14:06:38 Eastern Standard Time,
    porter.sadler@s... writes:


    > Got to be an easier way. I want to turn a variable number into a BCD
    number
    > for seven segment displays. I'm not using the decoder chip. What
    > suggestions can you guys offer to get a number 0-9999 into a 4 byte
    string.
    > Currently I start by dividing by 1000 to get first digit, then divide the
    > remainder by 100 to get the second digit etc.
    >
    > I this what the DIG modifier is for?
    >
    >

    Just go to Calculator - Scientific. Enter the decimal number then click on
    "bin".
    Sid Weaver
    W4EKQ
    Port Richey, FL


    [noparse][[/noparse]Non-text portions of this message have been removed]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-20 19:17
    In a message dated 12/20/2002 14:06:38 Eastern Standard Time,
    porter.sadler@s... writes:


    > Got to be an easier way. I want to turn a variable number into a BCD number
    > for seven segment displays. I'm not using the decoder chip. What
    > suggestions can you guys offer to get a number 0-9999 into a 4 byte string.
    > Currently I start by dividing by 1000 to get first digit, then divide the
    > remainder by 100 to get the second digit etc.
    >
    > I this what the DIG modifier is for?
    >
    >

    Just go to Calculator - Scientific. Enter the decimal number then click on
    "bin".
    Sid Weaver
    W4EKQ
    Port Richey, FL


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-20 19:30
    Yes, you can use the DIG function for this.

    dig3 = myValue DIG 3 ' thousands
    dig2 = myValue DIG 2 ' hundreds
    dig1 = myValue DIG 1 ' tens
    dig0 = myValue DIG 0 ' ones

    -- Jon Williams
    -- Parallax

    In a message dated 12/20/2002 1:06:37 PM Central Standard Time,
    porter.sadler@s... writes:

    > Got to be an easier way. I want to turn a variable number into a BCD number
    > for seven segment displays. I'm not using the decoder chip. What
    > suggestions can you guys offer to get a number 0-9999 into a 4 byte string.
    > Currently I start by dividing by 1000 to get first digit, then divide the
    > remainder by 100 to get the second digit etc.
    >
    > I this what the DIG modifier is for?
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-20 19:37
    Simple. I use a BCD thumb wheel switch and do the following:. The switch
    is mechanically limited to 10 positions. (0 thru 9). I have the 2 BCD
    digits feeding a parallel to serial chip converting them into a 8 bit
    variable called BCD for example. Simply break out the high nib and low nib
    of BCD. For example the two switches are set to 6 4:

    BCD variable gets set to the following, (binary), 01100100. The upper
    nib is 0110 (6 dec) and the lower is 0100 (dec 4). From here you can do
    what ever you want with the values..

    Mike B.

    Original Message
    From: "Sadler Porter" <porter.sadler@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, December 20, 2002 10:48 AM
    Subject: [noparse][[/noparse]basicstamps] number to bcd


    > Got to be an easier way. I want to turn a variable number into a BCD
    number
    > for seven segment displays. I'm not using the decoder chip. What
    > suggestions can you guys offer to get a number 0-9999 into a 4 byte
    string.
    > Currently I start by dividing by 1000 to get first digit, then divide the
    > remainder by 100 to get the second digit etc.
    >
    > I this what the DIG modifier is for?
    >
    >
    >
    >
    >
    Original Message
    > From: Tracy Allen [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=6bK73dVOB-Lo5kNaXryug8mVnqP6BaXXNqy-kqob6QivFmbcXS-Rr7ad2O1k7KCjGEVNo1WPiKAxYyCbT5M]tracy@e...[/url
    > Sent: Friday, December 20, 2002 1:11 PM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] Noise on data lines...
    >
    > Hi Chris,
    >
    > Shield the cable. Near the Stamp, run it through an RFI bead (the
    > fat thing you often see on cables).
    >
    > -- Tracy
    >
    > >Hello all,
    > >I have a stamp connected to a radio frequency tag system. The serial data
    > >line between the RF unit and the stamp pcb has a lot of noise on it
    coming
    > >from the rf unit. Does anybody have any ideas on an effective way to
    remove
    > >the noise from the serial data line ?, or any links to sites with info on
    > >this ?
    > >Thanks
    > >Chris (Western Australia)
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    > Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-20 19:45
    This dig command, is that using a BS2, or what devices?

    Looks like my documentation may be old. Where can I find more information on
    the DIG command?


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-20 21:02
    I used the serin,wait to get the string and used the dec command to put
    each digit into individual variables. I then used:
    var1 * 10 + var2 * 10 + var3 * 10 + var4 = newVar 'to get it all
    in one variable.
    I guess that only uses two lines of code? I was reading in a 4 digit
    number and outputting it to a lcd and led display converting it to xx.xx
    format.



    Great suggestion but then I would spend all my time at the calculator not
    machining parts.
    Sorry, I'm making an rpm gauge for my lathe and mill.
    It's not rally a stamp question cause I'm gonna make the final design using
    a pic, but Pic Basic Pro is almost Stamp.

    What I want to do it take the RPM counts input and convert that to a BCD
    string to display on 7-segs. SO I need it in bcd byte format. All serial
    output routines convert it for you using the "Dec" modifier but I need to
    use the bytes elsewhere in the program.
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-21 01:33
    It has been in the manual since the BS2 was released. See the section on
    binary operators. You can download the latest manual -- free -- from our web
    site. If you want a printed version, they're currently on sale. Don't delay
    though, sales don't last forever.

    -- Jon Williams
    -- Parallax


    In a message dated 12/20/2002 1:48:05 PM Central Standard Time,
    smartdim@a... writes:

    > This dig command, is that using a BS2, or what devices?
    >
    > Looks like my documentation may be old. Where can I find more information
    > on
    > the DIG command?



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-21 14:12
    Just for RPM? LED? Don't bother, its gling to be a lot of parts and
    wiring or a PCB, just get a LCD screen. Can get a 2 line x 24 char
    for $10. The serial LCDs would be even easier, but at $40 it gets
    pricey.

    I'm woirking on a DRO (with LCD) for my mill from a hacked digital
    caliper.(lathe really doesn't need one for my uses) Though its done
    with a 'normal' PIC since I need SPI and to custom configure the SPI.



    --- In basicstamps@yahoogroups.com, Sadler Porter
    <porter.sadler@s...> wrote:
    > Great suggestion but then I would spend all my time at the
    calculator not
    > machining parts.
    > Sorry, I'm making an rpm gauge for my lathe and mill.
    > It's not rally a stamp question cause I'm gonna make the final
    design using
    > a pic, but Pic Basic Pro is almost Stamp.
    >
    > What I want to do it take the RPM counts input and convert that to
    a BCD
    > string to display on 7-segs. SO I need it in bcd byte format. All
    serial
    > output routines convert it for you using the "Dec" modifier but I
    need to
    > use the bytes elsewhere in the program.
    >
    >
    Original Message
    > From: Newzed@a... [noparse][[/noparse]mailto:Newzed@a...]
    > Sent: Friday, December 20, 2002 2:18 PM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] number to bcd
    >
    > In a message dated 12/20/2002 14:06:38 Eastern Standard Time,
    > porter.sadler@s... writes:
    >
    >
    > > Got to be an easier way. I want to turn a variable number into a
    BCD
    > number
    > > for seven segment displays. I'm not using the decoder chip. What
    > > suggestions can you guys offer to get a number 0-9999 into a 4
    byte
    > string.
    > > Currently I start by dividing by 1000 to get first digit, then
    divide the
    > > remainder by 100 to get the second digit etc.
    > >
    > > I this what the DIG modifier is for?
    > >
    > >
    >
    > Just go to Calculator - Scientific. Enter the decimal number then
    click on
    > "bin".
    > Sid Weaver
    > W4EKQ
    > Port Richey, FL
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and
    > Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-21 14:41
    For LCD products at good prices, check out

    http://www.eio.com/lcdprodt.htm

    Larry

    At 02:12 PM 12/21/2002 +0000, you wrote:
    >Just for RPM? LED? Don't bother, its gling to be a lot of parts and
    >wiring or a PCB, just get a LCD screen. Can get a 2 line x 24 char
    >for $10. The serial LCDs would be even easier, but at $40 it gets
    >pricey.
    >
    >I'm woirking on a DRO (with LCD) for my mill from a hacked digital
    >caliper.(lathe really doesn't need one for my uses) Though its done
    >with a 'normal' PIC since I need SPI and to custom configure the SPI.
    >
    >

    Larry Bradley
    Orleans (Ottawa), Ontario, CANADA
Sign In or Register to comment.