Shop OBEX P1 Docs P2 Docs Learn Events
How to accomplish this mask in spin? — Parallax Forums

How to accomplish this mask in spin?

T ChapT Chap Posts: 4,223
edited 2012-07-01 05:26 in Propeller 1
I have 16 Propellers, each assigned an ID from %0000 - %1111. If I want to address any single device, that is easy, just send that ID. But what if I want to address device 1 and 2 only?

I thought that ORing 1 and 2 would work, and it does but is also allows #3 to be addressed: %0001 OR %0010 = %0011. In this case, if $03 is sent as a bitmask, then #1, 2, and 3 devices are able to be addressed. Likewise, If I just wanted to address #3 and #1, the same problem exists.

How do you address any or all of 16 ID's without the other values getting included that are unwanted? Or, is 4 bits not possible to do this inside, and I must use a 16 bits?

Comments

  • kwinnkwinn Posts: 8,697
    edited 2012-06-30 18:24
    It's not possible with less than 16 bits if you want to be able to address any arbitrary number of the 16 micros at once.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2012-06-30 18:29
    You might need to re-think your addressing scheme...

    If your limited to 4-bits and have 16 addresses assigned to those 4-bits, then you can only address one Propeller at a time.
  • T ChapT Chap Posts: 4,223
    edited 2012-06-30 18:31
    Actually Beau, the thought was to address any single address with 4 bits. If any multiple addresses are required, I would use a 5th bit to designate that it was a mask to be ANDed with the local addresses.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-30 18:40
    Splurge a little and use 16 bits. That's the only way you will be able to address any subset of the 16 units.

    -Phil
  • cavelambcavelamb Posts: 720
    edited 2012-06-30 19:44
    T Chap wrote: »
    I have 16 Propellers, each assigned an ID from 00 - 11. If I want to address any single device, that is easy, just send that ID. But what if I want to address device 1 and 2 only?

    I thought that ORing 1 and 2 would work, and it does but is also allows #3 to be addressed: 01 OR 10 = 11. In this case, if $03 is sent as a bitmask, then #1, 2, and 3 devices are able to be addressed. Likewise, If I just wanted to address #3 and #1, the same problem exists.

    How do you address any or all of 16 ID's without the other values getting included that are unwanted? Or, is 4 bits not possible to do this inside, and I must use a 16 bits?

    What you are really trying to do it write to multiple targets at the same time.
    (Will you then want to READ from multiple devices at the same time?)

    I think what you want is called a Cross-Point switch...
    http://en.wikipedia.org/wiki/Crossbar_switch

    But the addressing confusion? What's that about?

    4 bits can be four selects,
    or it can be a binary encoded number (0 to F as we say in hex).
    The difference is how they are used.
    4 bits are used to select 4 devices
    That's not addressing. That's mode /Chip Selects or /Chip Enable.

    4 bits are DECODED to produce 16 selects for 16 devices.
    That's the A, B, C, and D inputs:
    (from digital prehistory - the 74LS154 4 to 16 decoder)

    But that doesn't let you access two units at the same time.
    In fact, its built to prohibit just exactly that.
    One To, One From.

    GPIB (General Purpose Instrument Bus) allowed multiple listeners.
    iirc?


    Anyway, after all that, would a straight question be in order?

    What is it that you think you are doing?
    358 x 501 - 28K
  • T ChapT Chap Posts: 4,223
    edited 2012-06-30 20:08
    I am trying to reduce airtime for a single Propeller addressing 1-16 remote wireless devices. I can use 16 bits easily, but was curious if any tricks existed to reduce the packets so that 4 bits could be used as the ID plus a bit for designating a bitmask function. Obviously not possible with only 5 bits.
  • cavelambcavelamb Posts: 720
    edited 2012-06-30 21:01
    T Chap wrote: »
    I am trying to reduce airtime for a single Propeller addressing 1-16 remote wireless devices. I can use 16 bits easily, but was curious if any tricks existed to reduce the packets so that 4 bits could be used as the ID plus a bit for designating a bitmask function. Obviously not possible with only 5 bits.

    Nope. 'fraid not.
  • Mark_TMark_T Posts: 1,981
    edited 2012-07-01 05:26
    T Chap wrote: »
    I am trying to reduce airtime for a single Propeller addressing 1-16 remote wireless devices. I can use 16 bits easily, but was curious if any tricks existed to reduce the packets so that 4 bits could be used as the ID plus a bit for designating a bitmask function. Obviously not possible with only 5 bits.

    If you have N possibilities then you need ceiling(log2(N)) bits to select one possibility (ceiling rounds up to next integer), its fundamental information theory.

    Say you want to address one or two (but not more) devices from a set of 16. That is 16+120 = 136 possibilities which requires 8 bits. You'd have to invent a coding scheme too. Selecting just one is 16 possibilities, therefore 4 bits (obvious coding scheme). Selecting any sub-set at all from the 16 (including none) is 2^16 possibilities which is exactly 16 bits (with an obvious coding scheme).
Sign In or Register to comment.