Shop OBEX P1 Docs P2 Docs Learn Events
Taking two sample arrays — Parallax Forums

Taking two sample arrays

ArchiverArchiver Posts: 46,084
edited 2003-11-06 23:57 in General Discussion
Hi All

Is there a way of taking two sample arrays ON A BS2
ie

SA VAR W1 ........ SAMPLE A
too
SL VAR W12 ........ SAMPLE L

ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L

start:
PULSIN 0,0 SA
TO
PULSIN 0,0 SL
ARRAYONE(0) = SA
ARRAYONE(11) = SA

PUSLIN 0,0 SA
TO
PULSIN 0,0 SL
ARRAYTWO(0) =SA
ARRAYTWO(11)= SL

THEN DO SOME MATHS COMPARISONS


I am pretty sure I run out of space to store two arrays???

Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do one VAR and
ARRAY(14) but slower I WOULD think in out come.. i.e. miss some samples.

Thanks

Rob

This email is confidential and may also be privilege.
If you are not the intended recipient, please notify us immediately.
You should not copy or use it for any purpose, nor disclose it's contents to any
other person.

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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-11-06 02:11
    The Stamp has just 12 word-sized registers, so you an your max would be:

    one VAR Word(6)
    two VAR Word(6)

    ... but that would leave you without any variables to do your math. So,
    the practical limit for your application is going to be five elements.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: Rob Farrand ... FTech Connection
    [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=C5LK_BmZUtyNcRjaasWDA2DKRIHOAKSe4QhyYIZy65TzmTYWhdTy47vjW9tPOnEq1j5O1GJE036-JfqiqeqCTNcuMw]ftech@n...[/url
    Sent: Wednesday, November 05, 2003 7:46 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    Hi All

    Is there a way of taking two sample arrays ON A BS2
    ie

    SA VAR W1 ........ SAMPLE A
    too
    SL VAR W12 ........ SAMPLE L

    ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L

    start:
    PULSIN 0,0 SA
    TO
    PULSIN 0,0 SL
    ARRAYONE(0) = SA
    ARRAYONE(11) = SA

    PUSLIN 0,0 SA
    TO
    PULSIN 0,0 SL
    ARRAYTWO(0) =SA
    ARRAYTWO(11)= SL

    THEN DO SOME MATHS COMPARISONS


    I am pretty sure I run out of space to store two arrays???

    Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do one
    VAR and ARRAY(14) but slower I WOULD think in out come.. i.e. miss
    some samples.

    Thanks

    Rob

    This email is confidential and may also be privilege.
    If you are not the intended recipient, please notify us immediately.
    You should not copy or use it for any purpose, nor disclose it's
    contents to any other person.

    [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/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-06 02:22
    Thanks Jon
    Thats what I thought from the manual ...but I was hoping there might have
    been a trick to get around it.....is there anyway of adding extra memory to
    expand that or is there away I can store results of 1-9999 in smaller value
    array say a byte?


    Original Message
    From: "Jon Williams" <jwilliams@p...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 06, 2003 12:41 PM
    Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    > The Stamp has just 12 word-sized registers, so you an your max would be:
    >
    > one VAR Word(6)
    > two VAR Word(6)
    >
    > ... but that would leave you without any variables to do your math. So,
    > the practical limit for your application is going to be five elements.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: Rob Farrand ... FTech Connection
    > [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=jLOVbifldXr9Sj2DCA8B0KKNM1aQumLFSUbweZZIW5p-laY_WkcNhtqqfhs8wM3xLM_UzAzKjt5ADi2NetceGQ]ftech@n...[/url
    > Sent: Wednesday, November 05, 2003 7:46 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >
    >
    > Hi All
    >
    > Is there a way of taking two sample arrays ON A BS2
    > ie
    >
    > SA VAR W1 ........ SAMPLE A
    > too
    > SL VAR W12 ........ SAMPLE L
    >
    > ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    > ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L
    >
    > start:
    > PULSIN 0,0 SA
    > TO
    > PULSIN 0,0 SL
    > ARRAYONE(0) = SA
    > ARRAYONE(11) = SA
    >
    > PUSLIN 0,0 SA
    > TO
    > PULSIN 0,0 SL
    > ARRAYTWO(0) =SA
    > ARRAYTWO(11)= SL
    >
    > THEN DO SOME MATHS COMPARISONS
    >
    >
    > I am pretty sure I run out of space to store two arrays???
    >
    > Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do one
    > VAR and ARRAY(14) but slower I WOULD think in out come.. i.e. miss
    > some samples.
    >
    > Thanks
    >
    > Rob
    >
    > This email is confidential and may also be privilege.
    > If you are not the intended recipient, please notify us immediately.
    > You should not copy or use it for any purpose, nor disclose it's
    > contents to any other person.
    >
    > [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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p....
    >
    >
    > 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 2003-11-06 02:49
    If you can figure out how to store a value from 1 - 9999 in a byte
    you'll make Bill Gates look like a chump. Don't spend your energy,
    though, it won't happen.

    You can't add variable memory to the Stamp. If you use one of the
    multi-bank Stamps you have more RAM space -- in the Scratchpad. It's
    not as easy to access, but not tough and even the BS2e gives you 64
    extra bytes (32 words -- two 16-word arrays). You have to use PUT and
    GET to access the Scratchpad. Here's some starter code to give you an
    idea:

    ' {$STAMP BS2e}
    ' {PBASIC 2.5}

    idx VAR Nib
    addr VAR Byte
    pulsVal VAR Word
    tVal1 VAR Word
    tVal2 VAR Word


    Test_1:
    FOR idx = 0 TO 11
    PULSIN pin, level, pulsVal
    addr = 2 * idx
    PUT addr, Word pulsVal
    NEXT


    Test_2:
    FOR idx = 0 TO 11
    PULSIN pin, level, pulsVal
    addr = 24 + (2 * idx)
    PUT addr, Word pulsVal
    NEXT


    Compare:
    FOR idx = 0 TO 11
    addr = 2 * idx
    GET addr, Word tVal1
    addr = addr + 24
    GET addr, Word tVal2

    ' do your thing with tVal1 and tVal2 here

    NEXT


    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office



    Original Message
    From: Rob Farrand ... FTech Connection
    [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=erT4qGjfcFmlzMczvWEZsh5Fy6eAKVOQ7DwKyQKU4CK4plhUP38RhXKTYYycyz9rauvaj8RM3veXQwgcp09f_wQ2]ftech@n...[/url
    Sent: Wednesday, November 05, 2003 8:22 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    Thanks Jon
    Thats what I thought from the manual ...but I was hoping there might
    have been a trick to get around it.....is there anyway of adding extra
    memory to expand that or is there away I can store results of 1-9999 in
    smaller value array say a byte?


    Original Message
    From: "Jon Williams" <jwilliams@p...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 06, 2003 12:41 PM
    Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    > The Stamp has just 12 word-sized registers, so you an your max would
    > be:
    >
    > one VAR Word(6)
    > two VAR Word(6)
    >
    > ... but that would leave you without any variables to do your math.
    > So, the practical limit for your application is going to be five
    > elements.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: Rob Farrand ... FTech Connection
    > [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=erT4qGjfcFmlzMczvWEZsh5Fy6eAKVOQ7DwKyQKU4CK4plhUP38RhXKTYYycyz9rauvaj8RM3veXQwgcp09f_wQ2]ftech@n...[/url
    > Sent: Wednesday, November 05, 2003 7:46 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >
    >
    > Hi All
    >
    > Is there a way of taking two sample arrays ON A BS2
    > ie
    >
    > SA VAR W1 ........ SAMPLE A
    > too
    > SL VAR W12 ........ SAMPLE L
    >
    > ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    > ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L
    >
    > start:
    > PULSIN 0,0 SA
    > TO
    > PULSIN 0,0 SL
    > ARRAYONE(0) = SA
    > ARRAYONE(11) = SA
    >
    > PUSLIN 0,0 SA
    > TO
    > PULSIN 0,0 SL
    > ARRAYTWO(0) =SA
    > ARRAYTWO(11)= SL
    >
    > THEN DO SOME MATHS COMPARISONS
    >
    >
    > I am pretty sure I run out of space to store two arrays???
    >
    > Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do
    > one VAR and ARRAY(14) but slower I WOULD think in out come.. i.e.
    > miss some samples.
    >
    > Thanks
    >
    > Rob
    >
    > This email is confidential and may also be privilege.
    > If you are not the intended recipient, please notify us immediately.
    > You should not copy or use it for any purpose, nor disclose it's
    > contents to any other person.
    >
    > [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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p....
    >
    >
    > 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/
    >


    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/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-06 03:00
    Thanks Jon

    yes I could do with bills cash too
    no I was thinking of
    SA/255 so 9999 would be 39.21

    I am new to this program thing... it all seems simple on paper

    problem then is if I get a

    SA 235
    SB 245
    SC 9999

    CAN I MAKE IT SOMEWAY TO SAY THAT SC WAS /255

    Thanks anyway

    Original Message
    From: "Jon Williams" <jwilliams@p...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 06, 2003 1:19 PM
    Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    > If you can figure out how to store a value from 1 - 9999 in a byte
    > you'll make Bill Gates look like a chump. Don't spend your energy,
    > though, it won't happen.
    >
    > You can't add variable memory to the Stamp. If you use one of the
    > multi-bank Stamps you have more RAM space -- in the Scratchpad. It's
    > not as easy to access, but not tough and even the BS2e gives you 64
    > extra bytes (32 words -- two 16-word arrays). You have to use PUT and
    > GET to access the Scratchpad. Here's some starter code to give you an
    > idea:
    >
    > ' {$STAMP BS2e}
    > ' {PBASIC 2.5}
    >
    > idx VAR Nib
    > addr VAR Byte
    > pulsVal VAR Word
    > tVal1 VAR Word
    > tVal2 VAR Word
    >
    >
    > Test_1:
    > FOR idx = 0 TO 11
    > PULSIN pin, level, pulsVal
    > addr = 2 * idx
    > PUT addr, Word pulsVal
    > NEXT
    >
    >
    > Test_2:
    > FOR idx = 0 TO 11
    > PULSIN pin, level, pulsVal
    > addr = 24 + (2 * idx)
    > PUT addr, Word pulsVal
    > NEXT
    >
    >
    > Compare:
    > FOR idx = 0 TO 11
    > addr = 2 * idx
    > GET addr, Word tVal1
    > addr = addr + 24
    > GET addr, Word tVal2
    >
    > ' do your thing with tVal1 and tVal2 here
    >
    > NEXT
    >
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    >
    Original Message
    > From: Rob Farrand ... FTech Connection
    > [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=CIS4YgOU2hYGIzzh-GAt2PqPe0JMzAOYceCDvqUBgm8CFNoaFsq8F_nIBexLophPRkEc-zmNeyQnTXksHRQ8]ftech@n...[/url
    > Sent: Wednesday, November 05, 2003 8:22 PM
    > To: basicstamps@yahoogroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >
    >
    > Thanks Jon
    > Thats what I thought from the manual ...but I was hoping there might
    > have been a trick to get around it.....is there anyway of adding extra
    > memory to expand that or is there away I can store results of 1-9999 in
    > smaller value array say a byte?
    >
    >
    >
    Original Message
    > From: "Jon Williams" <jwilliams@p...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Thursday, November 06, 2003 12:41 PM
    > Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >
    >
    > > The Stamp has just 12 word-sized registers, so you an your max would
    > > be:
    > >
    > > one VAR Word(6)
    > > two VAR Word(6)
    > >
    > > ... but that would leave you without any variables to do your math.
    > > So, the practical limit for your application is going to be five
    > > elements.
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: Rob Farrand ... FTech Connection
    > > [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=CIS4YgOU2hYGIzzh-GAt2PqPe0JMzAOYceCDvqUBgm8CFNoaFsq8F_nIBexLophPRkEc-zmNeyQnTXksHRQ8]ftech@n...[/url
    > > Sent: Wednesday, November 05, 2003 7:46 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    > >
    > >
    > > Hi All
    > >
    > > Is there a way of taking two sample arrays ON A BS2
    > > ie
    > >
    > > SA VAR W1 ........ SAMPLE A
    > > too
    > > SL VAR W12 ........ SAMPLE L
    > >
    > > ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    > > ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L
    > >
    > > start:
    > > PULSIN 0,0 SA
    > > TO
    > > PULSIN 0,0 SL
    > > ARRAYONE(0) = SA
    > > ARRAYONE(11) = SA
    > >
    > > PUSLIN 0,0 SA
    > > TO
    > > PULSIN 0,0 SL
    > > ARRAYTWO(0) =SA
    > > ARRAYTWO(11)= SL
    > >
    > > THEN DO SOME MATHS COMPARISONS
    > >
    > >
    > > I am pretty sure I run out of space to store two arrays???
    > >
    > > Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do
    > > one VAR and ARRAY(14) but slower I WOULD think in out come.. i.e.
    > > miss some samples.
    > >
    > > Thanks
    > >
    > > Rob
    > >
    > > This email is confidential and may also be privilege.
    > > If you are not the intended recipient, please notify us immediately.
    > > You should not copy or use it for any purpose, nor disclose it's
    > > contents to any other person.
    > >
    > > [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/
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p....
    > >
    > >
    > > 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/
    > >
    >
    >
    > 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/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p....
    >
    >
    > 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 2003-11-06 06:10
    Hi Rob,

    One way to collapse data X that covers a wide range, into a smaller
    range, is to work with the logarithm of X instead of X itself. That
    is justified when percentage changes are more important that absolute
    changes, for example, if a change from 100 to 200 counts for as much
    as a change from 1000 to 2000.

    With log base 2, numbers from 1 to 65535 can become compressed into
    the range from 0 to 256, but still maintain the correct order of
    magnitudes among your samples. The Stamp does not have a logarithm
    operator per se, but it comes close, with the NCD operator. That is
    essentially a log base 2. Here is a URL with more explanation of how
    it works and also a simple extension to the fractional part, which is
    commonly called the quick bitlog function:

    http://www.emesystems.com/BS2math3.htm#bitlog

    Your example numbers were, 235,245,9999.

    Transformed to log base 2, the sequence is:
    7.87, 7.94, 13.29
    or multiplying each value *16 (in order to scale it into one byte),
    you would have,
    125, 127, 212.

    I haven't the foggiest idea what the numbers you are collecting
    represent, so I can't really say what is appropriate mathematically.

    As to the processing, you might be able to do the math as you bring
    in successive values, rather than collecting them all into an arrays
    first. This will involve accumulating several sums: 1)the sum of the
    values, 2)the sum of the squares of the values, and also 3) probably
    the sum of a cross product. The computations will take time on the
    Stamp, so that approach won't work if the samples have to be taken in
    a split second. It is possible that some non-parametric statistic
    might give you the answer you need, without so much computation.

    -- regards,
    Tracy




    >Thanks Jon
    >
    >yes I could do with bills cash too
    > no I was thinking of
    >SA/255 so 9999 would be 39.21
    >
    >I am new to this program thing... it all seems simple on paper
    >
    >problem then is if I get a
    >
    >SA 235
    >SB 245
    >SC 9999
    >
    >CAN I MAKE IT SOMEWAY TO SAY THAT SC WAS /255
    >
    >Thanks anyway
    >
    >
    Original Message
    >From: "Jon Williams" <jwilliams@p...>
    >To: <basicstamps@yahoogroups.com>
    >Sent: Thursday, November 06, 2003 1:19 PM
    >Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >
    >
    >> If you can figure out how to store a value from 1 - 9999 in a byte
    >> you'll make Bill Gates look like a chump. Don't spend your energy,
    >> though, it won't happen.
    >>
    >> You can't add variable memory to the Stamp. If you use one of the
    >> multi-bank Stamps you have more RAM space -- in the Scratchpad. It's
    >> not as easy to access, but not tough and even the BS2e gives you 64
    >> extra bytes (32 words -- two 16-word arrays). You have to use PUT and
    >> GET to access the Scratchpad. Here's some starter code to give you an
    >> idea:
    >>
    >> ' {$STAMP BS2e}
    >> ' {PBASIC 2.5}
    >>
    >> idx VAR Nib
    >> addr VAR Byte
    >> pulsVal VAR Word
    >> tVal1 VAR Word
    >> tVal2 VAR Word
    >>
    >>
    >> Test_1:
    >> FOR idx = 0 TO 11
    >> PULSIN pin, level, pulsVal
    >> addr = 2 * idx
    >> PUT addr, Word pulsVal
    >> NEXT
    >>
    >>
    >> Test_2:
    >> FOR idx = 0 TO 11
    >> PULSIN pin, level, pulsVal
    >> addr = 24 + (2 * idx)
    >> PUT addr, Word pulsVal
    >> NEXT
    >>
    >>
    >> Compare:
    >> FOR idx = 0 TO 11
    >> addr = 2 * idx
    >> GET addr, Word tVal1
    >> addr = addr + 24
    >> GET addr, Word tVal2
    >>
    >> ' do your thing with tVal1 and tVal2 here
    >>
    >> NEXT
    >>
    >>
    >> -- Jon Williams
    >> -- Applications Engineer, Parallax
    >> -- Dallas Office
    >>
    >>
    >>
    >>
    Original Message
    >> From: Rob Farrand ... FTech Connection
    >> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=CWeEKuizVwLz1NYtdIEH2ne3zCNC9e2TBX3YJ9VAbhlBjnw27a2kqS0x9tkAkpiBA3Pq8wbcsdN7lJjIXYmN5w]ftech@n...[/url
    >> Sent: Wednesday, November 05, 2003 8:22 PM
    >> To: basicstamps@yahoogroups.com
    >> Subject: Re: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >>
    >>
    >> Thanks Jon
    >> Thats what I thought from the manual ...but I was hoping there might
    >> have been a trick to get around it.....is there anyway of adding extra
    >> memory to expand that or is there away I can store results of 1-9999 in
    >> smaller value array say a byte?
    >>
    >>
    >>
    Original Message
    > > From: "Jon Williams" <jwilliams@p...>
    >> To: <basicstamps@yahoogroups.com>
    >> Sent: Thursday, November 06, 2003 12:41 PM
    >> Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >>
    >>
    >> > The Stamp has just 12 word-sized registers, so you an your max would
    >> > be:
    >> >
    >> > one VAR Word(6)
    >> > two VAR Word(6)
    >> >
    >> > ... but that would leave you without any variables to do your math.
    >> > So, the practical limit for your application is going to be five
    >> > elements.
    >> >
    >> > -- Jon Williams
    >> > -- Applications Engineer, Parallax
    >> > -- Dallas Office
    >> >
    >> >
    >> >
    Original Message
    >> > From: Rob Farrand ... FTech Connection
    >> > [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=CWeEKuizVwLz1NYtdIEH2ne3zCNC9e2TBX3YJ9VAbhlBjnw27a2kqS0x9tkAkpiBA3Pq8wbcsdN7lJjIXYmN5w]ftech@n...[/url
    >> > Sent: Wednesday, November 05, 2003 7:46 PM
    >> > To: basicstamps@yahoogroups.com
    >> > Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    >> >
    >> >
    >> > Hi All
    >> >
    >> > Is there a way of taking two sample arrays ON A BS2
    >> > ie
    >> >
    >> > SA VAR W1 ........ SAMPLE A
    >> > too
    >> > SL VAR W12 ........ SAMPLE L
    >> >
    >> > ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    >> > ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L
    >> >
    >> > start:
    >> > PULSIN 0,0 SA
    >> > TO
    >> > PULSIN 0,0 SL
    >> > ARRAYONE(0) = SA
    >> > ARRAYONE(11) = SA
    >> >
    >> > PUSLIN 0,0 SA
    >> > TO
    >> > PULSIN 0,0 SL
    >> > ARRAYTWO(0) =SA
    >> > ARRAYTWO(11)= SL
    >> >
    >> > THEN DO SOME MATHS COMPARISONS
    >> >
    >> >
    >> > I am pretty sure I run out of space to store two arrays???
    >> >
    >> > Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do
    >> > one VAR and ARRAY(14) but slower I WOULD think in out come.. i.e.
    >> > miss some samples.
    >> >
    >> > Thanks
    >> >
    >> > Rob
    >> >
    >> > This email is confidential and may also be privilege.
    >> > If you are not the intended recipient, please notify us immediately.
    >> > You should not copy or use it for any purpose, nor disclose it's
    > > > contents to any other person.
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-06 10:43
    Hi Rob,

    If you're running low on available RAM on your BS2 you might like to
    consider using the RAM Pack B from Solutions Cubed.

    http://www.warburtech.com/Modules/RAM Pack B/RAM Pack B.htm

    The RAM Pack B module maintains 8Kx8 bytes of RAM and makes use of buffers
    and an on board microcontroller to allow addressable access to the RAM using
    only 1 or 2 I/O lines on your BASIC Stamp. The 8Kx8 bytes of static RAM
    comes socketed and may be expanded to handle 32Kx8 bytes of RAM.

    If you would like more information about the RAM Pack B, or need help with
    your BASIC Stamp code, just let me know. I look forward to hearing from you.

    Best regards,

    Russell Warburton
    email: russell@w...
    website: http://www.warburtech.com
    telephone: +44 (0)7814 044 754
    Original Message
    From: "Rob Farrand ... FTech Connection" <ftech@n...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 06, 2003 1:46 AM
    Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    > Hi All
    >
    > Is there a way of taking two sample arrays ON A BS2
    > ie
    >
    > SA VAR W1 ........ SAMPLE A
    > too
    > SL VAR W12 ........ SAMPLE L
    >
    > ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    > ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L
    >
    > start:
    > PULSIN 0,0 SA
    > TO
    > PULSIN 0,0 SL
    > ARRAYONE(0) = SA
    > ARRAYONE(11) = SA
    >
    > PUSLIN 0,0 SA
    > TO
    > PULSIN 0,0 SL
    > ARRAYTWO(0) =SA
    > ARRAYTWO(11)= SL
    >
    > THEN DO SOME MATHS COMPARISONS
    >
    >
    > I am pretty sure I run out of space to store two arrays???
    >
    > Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do one
    VAR and ARRAY(14) but slower I WOULD think in out come.. i.e. miss some
    samples.
    >
    > Thanks
    >
    > Rob
    >
    > This email is confidential and may also be privilege.
    > If you are not the intended recipient, please notify us immediately.
    > You should not copy or use it for any purpose, nor disclose it's contents
    to any other person.
    >
    > [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 2003-11-06 23:57
    THANKS ALL

    I will look at Your Idea Russell as option thanks

    Tracy I think that is possibly the way to do it!

    I lead you all up a path a bit with the 9999 value it will of course only be
    as high as max pulsin value (I don't know what that is maybe it is I assume
    65535 I haven't reached it yet).
    Its not a life and death result so extreme accuracy is not needed but a
    reliable average would be good if that makes sense.
    The trick is in capturing the input pulses which could happen in 4 samples
    or over 48 -60
    samples then working out the increase or decrease in the pulses. The action
    of the pulse can be re sent over an over once a action/stray is detected
    from the norm..... so the math time is not an issue... ie...
    nothing happening
    nothing happening
    change (start sample show
    warning
    saying...that sampling..then when result worked out and displayed you can
    re in act the change if its what I want do for X if not
    continue) ----nothing
    happening. etc

    Thanks heaps everyone


    Original Message
    From: "Tracy Allen" <tracy@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 06, 2003 4:40 PM
    Subject: Re: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS


    > Hi Rob,
    >
    > One way to collapse data X that covers a wide range, into a smaller
    > range, is to work with the logarithm of X instead of X itself. That
    > is justified when percentage changes are more important that absolute
    > changes, for example, if a change from 100 to 200 counts for as much
    > as a change from 1000 to 2000.
    >
    > With log base 2, numbers from 1 to 65535 can become compressed into
    > the range from 0 to 256, but still maintain the correct order of
    > magnitudes among your samples. The Stamp does not have a logarithm
    > operator per se, but it comes close, with the NCD operator. That is
    > essentially a log base 2. Here is a URL with more explanation of how
    > it works and also a simple extension to the fractional part, which is
    > commonly called the quick bitlog function:
    >
    > http://www.emesystems.com/BS2math3.htm#bitlog
    >
    > Your example numbers were, 235,245,9999.
    >
    > Transformed to log base 2, the sequence is:
    > 7.87, 7.94, 13.29
    > or multiplying each value *16 (in order to scale it into one byte),
    > you would have,
    > 125, 127, 212.
    >
    > I haven't the foggiest idea what the numbers you are collecting
    > represent, so I can't really say what is appropriate mathematically.
    >
    > As to the processing, you might be able to do the math as you bring
    > in successive values, rather than collecting them all into an arrays
    > first. This will involve accumulating several sums: 1)the sum of the
    > values, 2)the sum of the squares of the values, and also 3) probably
    > the sum of a cross product. The computations will take time on the
    > Stamp, so that approach won't work if the samples have to be taken in
    > a split second. It is possible that some non-parametric statistic
    > might give you the answer you need, without so much computation.
    >
    > -- regards,
    > Tracy
    >
    >
    >
    >
    > >Thanks Jon
    > >
    > >yes I could do with bills cash too
    > > no I was thinking of
    > >SA/255 so 9999 would be 39.21
    > >
    > >I am new to this program thing... it all seems simple on paper
    > >
    > >problem then is if I get a
    > >
    > >SA 235
    > >SB 245
    > >SC 9999
    > >
    > >CAN I MAKE IT SOMEWAY TO SAY THAT SC WAS /255
    > >
    > >Thanks anyway
    > >
    > >
    Original Message
    > >From: "Jon Williams" <jwilliams@p...>
    > >To: <basicstamps@yahoogroups.com>
    > >Sent: Thursday, November 06, 2003 1:19 PM
    > >Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    > >
    > >
    > >> If you can figure out how to store a value from 1 - 9999 in a byte
    > >> you'll make Bill Gates look like a chump. Don't spend your energy,
    > >> though, it won't happen.
    > >>
    > >> You can't add variable memory to the Stamp. If you use one of the
    > >> multi-bank Stamps you have more RAM space -- in the Scratchpad. It's
    > >> not as easy to access, but not tough and even the BS2e gives you 64
    > >> extra bytes (32 words -- two 16-word arrays). You have to use PUT and
    > >> GET to access the Scratchpad. Here's some starter code to give you an
    > >> idea:
    > >>
    > >> ' {$STAMP BS2e}
    > >> ' {PBASIC 2.5}
    > >>
    > >> idx VAR Nib
    > >> addr VAR Byte
    > >> pulsVal VAR Word
    > >> tVal1 VAR Word
    > >> tVal2 VAR Word
    > >>
    > >>
    > >> Test_1:
    > >> FOR idx = 0 TO 11
    > >> PULSIN pin, level, pulsVal
    > >> addr = 2 * idx
    > >> PUT addr, Word pulsVal
    > >> NEXT
    > >>
    > >>
    > >> Test_2:
    > >> FOR idx = 0 TO 11
    > >> PULSIN pin, level, pulsVal
    > >> addr = 24 + (2 * idx)
    > >> PUT addr, Word pulsVal
    > >> NEXT
    > >>
    > >>
    > >> Compare:
    > >> FOR idx = 0 TO 11
    > >> addr = 2 * idx
    > >> GET addr, Word tVal1
    > >> addr = addr + 24
    > >> GET addr, Word tVal2
    > >>
    > >> ' do your thing with tVal1 and tVal2 here
    > >>
    > >> NEXT
    > >>
    > >>
    > >> -- Jon Williams
    > >> -- Applications Engineer, Parallax
    > >> -- Dallas Office
    > >>
    > >>
    > >>
    > >>
    Original Message
    > >> From: Rob Farrand ... FTech Connection
    > >> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=MW01ziPZS8DsD1cvvWdlCemhAVJgUsT9CafhBBdRUR9j5qOKm7KVmXeegGTULCKOXlBpjzL_ntlVwVOiK6FfTzD7]ftech@n...[/url
    > >> Sent: Wednesday, November 05, 2003 8:22 PM
    > >> To: basicstamps@yahoogroups.com
    > >> Subject: Re: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    > >>
    > >>
    > >> Thanks Jon
    > >> Thats what I thought from the manual ...but I was hoping there might
    > >> have been a trick to get around it.....is there anyway of adding extra
    > >> memory to expand that or is there away I can store results of 1-9999 in
    > >> smaller value array say a byte?
    > >>
    > >>
    > >>
    Original Message
    > > > From: "Jon Williams" <jwilliams@p...>
    > >> To: <basicstamps@yahoogroups.com>
    > >> Sent: Thursday, November 06, 2003 12:41 PM
    > >> Subject: RE: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    > >>
    > >>
    > >> > The Stamp has just 12 word-sized registers, so you an your max would
    > >> > be:
    > >> >
    > >> > one VAR Word(6)
    > >> > two VAR Word(6)
    > >> >
    > >> > ... but that would leave you without any variables to do your math.
    > >> > So, the practical limit for your application is going to be five
    > >> > elements.
    > >> >
    > >> > -- Jon Williams
    > >> > -- Applications Engineer, Parallax
    > >> > -- Dallas Office
    > >> >
    > >> >
    > >> >
    Original Message
    > >> > From: Rob Farrand ... FTech Connection
    > >> > [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=MW01ziPZS8DsD1cvvWdlCemhAVJgUsT9CafhBBdRUR9j5qOKm7KVmXeegGTULCKOXlBpjzL_ntlVwVOiK6FfTzD7]ftech@n...[/url
    > >> > Sent: Wednesday, November 05, 2003 7:46 PM
    > >> > To: basicstamps@yahoogroups.com
    > >> > Subject: [noparse][[/noparse]basicstamps] TAKING TWO SAMPLE ARRAYS
    > >> >
    > >> >
    > >> > Hi All
    > >> >
    > >> > Is there a way of taking two sample arrays ON A BS2
    > >> > ie
    > >> >
    > >> > SA VAR W1 ........ SAMPLE A
    > >> > too
    > >> > SL VAR W12 ........ SAMPLE L
    > >> >
    > >> > ARRAY...ONE VAR WORD(12)....... first run of SAMPLE A - SAMPLE L
    > >> > ARRAY.....TWO VAR WORD(12).....second run of SAMPLE A - SAMPLE L
    > >> >
    > >> > start:
    > >> > PULSIN 0,0 SA
    > >> > TO
    > >> > PULSIN 0,0 SL
    > >> > ARRAYONE(0) = SA
    > >> > ARRAYONE(11) = SA
    > >> >
    > >> > PUSLIN 0,0 SA
    > >> > TO
    > >> > PULSIN 0,0 SL
    > >> > ARRAYTWO(0) =SA
    > >> > ARRAYTWO(11)= SL
    > >> >
    > >> > THEN DO SOME MATHS COMPARISONS
    > >> >
    > >> >
    > >> > I am pretty sure I run out of space to store two arrays???
    > >> >
    > >> > Max I can do is 5 samples and array(5) TIMES TWO.... OR I could do
    > >> > one VAR and ARRAY(14) but slower I WOULD think in out come.. i.e.
    > >> > miss some samples.
    > >> >
    > >> > Thanks
    > >> >
    > >> > Rob
    > >> >
    > >> > This email is confidential and may also be privilege.
    > >> > If you are not the intended recipient, please notify us immediately.
    > >> > You should not copy or use it for any purpose, nor disclose it's
    > > > > contents to any other person.
    >
    > 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/
    >
Sign In or Register to comment.