Shop OBEX P1 Docs P2 Docs Learn Events
Prop pins equaling more numbers — Parallax Forums

Prop pins equaling more numbers

HumanoidoHumanoido Posts: 5,770
edited 2010-03-25 06:19 in Propeller 1
A hardware question

Eight prop pins can represent 256 unique binary numbers
and nine pins 512 numbers.

But pins are rare. Can less than nine pins do 512 numbers?

Thank sincerely for your reply.

humanoido

Comments

  • pullmollpullmoll Posts: 817
    edited 2010-03-23 10:09
    humanoido said...
    A hardware question

    Eight prop pins can represent 256 unique binary numbers
    and nine pins 512 numbers.

    But pins are rare. Can less than nine pins do 512 numbers?

    Thank sincerely for your reply.

    humanoido

    In parallel: of course not. In serial: you can use a 2 pin protocol to transfer a number of any size. You could e.g. add one ore more serial to parallel shift registers to obtain the parallel result of the serial transfer. An example for such a shift register is the CMOS 4094. If you want to avoid intermediary outputs, you would need 3 pins and use the LE of the 4094 to latch the result after 8 shifts. By using 2 of these chips, connecting Q0 of the first chip to D of the second, attaching the Propeller pin for the data bit to D of the first chip, the pin for clocking to both CLK and the pin to latch the result to both LE, you can shift out up to 16 bit numbers and latch them after 16 shifts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    He died at the console of hunger and thirst.
    Next day he was buried. Face down, nine edge first.

    Post Edited (pullmoll) : 3/23/2010 10:27:48 AM GMT
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-23 14:46
    pullmoll said...
    In parallel: of course not. In serial: you can use a 2 pin protocol to transfer a number of any size. You could e.g. add one ore more serial to parallel shift registers to obtain the parallel result of the serial transfer. An example for such a shift register is the CMOS 4094. If you want to avoid intermediary outputs, you would need 3 pins and use the LE of the 4094 to latch the result after 8 shifts. By using 2 of these chips, connecting Q0 of the first chip to D of the second, attaching the Propeller pin for the data bit to D of the first chip, the pin for clocking to both CLK and the pin to latch the result to both LE, you can shift out up to 16 bit numbers and latch them after 16 shifts.
    Nice idea. But software can only read the hardware to get the number, not create it. How would you wire the circuits (512 different circuits) to create 512 numbers?

    humanoido
  • pullmollpullmoll Posts: 817
    edited 2010-03-23 15:22
    humanoido said...
    Nice idea. But software can only read the hardware to get the number, not create it. How would you wire the circuits (512 different circuits) to create 512 numbers?

    humanoido

    I'm not sure what you're talking about. 512 different circuits?
    If you want to read an external number which is available as parallel bits, you can use a parallel to serial shift register, or more than one, and do it in a similar way as shifting the bits out. The 4021 is a 8 bit PISO (parallel in, serial out) you could use for that job. Two of them will give you up to 16 bits via 3 Propeller pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    He died at the console of hunger and thirst.
    Next day he was buried. Face down, nine edge first.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-23 15:32
    The original idea for thought: the propeller chip dedicates 8 ports to create numbers from 0 to 256, by physically wiring the pin to a high or low circuit. All the prop has to do is read the 8 or 9 pins to know the binary number. There is no code other than reading the pins. Each prop gets one consecutive number. There's 256 (or 512) props total. I want wire the circuits individually to create the numbers with hardware, then each prop will read its circuit and get its number. Example, prop 1 is 0, prop 2 is 1, prop 3 is 2 .... prop 255 is 256...

    humanoido
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-23 15:46
    Using eight pins and base 3 instead of binary, you can detect 6561 different states. Each pin will either be pulled high or pulled low (though resistors), or left floating. Its state can be detected by precharging the pin (both high and low) then taking a reading.

    This can be extended further using an RC circuit on each pin and measuring the time it takes the pin to charge or discharge. That way, one pin could reliably take on many possible states.

    -Phil
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-23 17:35
    Phil said...
    Using eight pins and base 3 instead of binary, you can detect 6561 different states. Each pin will either be pulled high or pulled low (though resistors), or left floating. Its state can be detected by precharging the pin (both high and low) then taking a reading.
    Phil - perfect idea. Thank you. I know how to make a pin high, or low, but how to float a pin and detect neither high or low???
    Phil said...
    This can be extended further using an RC circuit on each pin and measuring the time it takes the pin to charge or discharge. That way, one pin could reliably take on many possible states.
    Another excellent idea and well within the range of a 3-state r/c circuit.

    humanoido

    Post Edited (humanoido) : 3/23/2010 5:41:28 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-23 17:41
    humanoido said...
    ...but how to float a pin and detect neither high or low???
    Just don't connect anything to it. To detect this state, set it to a high output, then set it to an input and read the pin. Do the same with a low output. If the pin reads the same both times, you know it's pulled to that state with a resistor. If it reads differently, you know it's floating.
    humanoido said...
    In the Basic Stamp SEED Supercomputer, I used this technique to measure resistor-capacitor values. I was hard pressed to get ten unique numbers. How would this technique work for a thousand different numbers?
    Use more than one pin.

    -Phil
  • John R.John R. Posts: 1,376
    edited 2010-03-23 17:48
    As an alternative, you could possibly use the ID from a "one wire" or similar device with a serial number. This does not give you the ability to "set" the address for a given device, but it would give you a unique address.

    If you have different "classes" or types of devices you are addressing, you could also "hard code" some of the digits, and use the switches for the balance. This would reduce the number of pins required while still allowing you to set the specific addresses (more properly, set a portion of them).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-23 18:18
    Edit:

    I had changed my post about r/c saying that it would be a workable solution to have three states for each pin. For some reason, the edit was not accepted by the Forum server.

    humanoido
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-23 18:27
    John R: Thank you for the info. It would be important to keep the ability to set the number as a numerical sequence, so probably a serialized chip isn't going to work here.

    What do you mean by "hard code?"

    Phil: thanks for explaining the technique of reading a floating pin.

    humanoido
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-23 18:50
    http://forums.parallax.com/showthread.php?p=892408
    Phil said...Make sure you don't have any floating inputs, as they can make the Prop draw excessive power. Either use pull-ups/pull-downs or set unused pins to outputs to reduce power consumption.

    Phil said...Just don't connect anything to it. To detect this state, set it to a high output, then set it to an input and read the pin. Do the same with a low output. If the pin reads the same both times, you know it's pulled to that state with a resistor. If it reads differently, you know it's floating.

    Phil, just cross-checking this information. With high, low, and floating pins, does this information agree and are any special procedures necessary? Is there a dangerous or undesired software condition to be aware of that could cause less than optimal performance?

    humanoido
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-23 18:59
    There's no inconsistency. For the pins that are detected at startup to be floating, just set them to output during operation, and leave the ones with pull-ups/-downs as inputs.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-03-23 18:59
    How will you boot up the props? ·If each prop has its own eeprom you could program a unique ID in each eeprom.
  • John R.John R. Posts: 1,376
    edited 2010-03-23 19:03
    humanoido said...
    John R: Thank you for the info. It would be important to keep the ability to set the number as a numerical sequence, so probably a serialized chip isn't going to work here.

    What do you mean by "hard code?"

    Phil: thanks for explaining the technique of reading a floating pin.

    humanoido
    By "hard code", I mean, for conversation sake, lets say we have a half dozen different "types" of devices, for example a "host", "Analog Input", "Digital Input", etc.
    ·
    Each of those types could be given a 3 bit code (up to eight different devices or more bits for more device types or “prefixes&#8221[noparse];)[/noparse] that was "hard coded" into the application code.· (A host would always be 000, Analog input 001 ...·type 8 module 111)· Then you could have however many inputs you needed to fill out the address, but you save three (or however many) input pins by using the "prefix".
    ·
    This only works if you can "pre assign" a part of the address as described, and depending on what you're doing, this may not be workable.
    ·
    Depending on how bad you need the input pins, and how much circuit board real-estate (and ability to bear costs) you have, you could also hook up a bank of dip switches to the parallel side of a Parallel Serial converter (or shift register, not sure what the proper term is), and read the address in serially.
    ·
    I'm toying with a few of these ideas myself for a network of aquarium sensors.·
    ·
    I'm also looking at possibly doing a "self addressing" daisy chain serial network.· Basically, each unit would have a send and receive data connection.· Each unit would "echo" the communication in and out.· You could then send a command with "set address" and the first unit in the chain would grab address one, the second two, etc.· This would support both a "broadcast" message, as well as messages to/from a specific node.· This method does not help with other types of communication (Ethernet, wireless, etc.)· It depends on a true daisy chain, with each station receiving, interpreting and either responding to and/or passing on (with or without modification) the command packet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-24 07:52
    Dave Hein said...
    How will you boot up the props? If each prop has its own eeprom you could program a unique ID in each eeprom.
    Each prop does not have its own eeprom. This is why hardware options are in review. There is only one eeprom for a board of 5 or 10 props. What happens if there is more than one board?

    humanoido
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-24 07:59
    John R said...
    Each of those types could be given a 3 bit code (up to eight different devices or more bits for more device types or “prefixes&#8221[noparse];)[/noparse] that was "hard coded" into the application code. (A host would always be 000, Analog input 001 ... type 8 module 111) Then you could have however many inputs you needed to fill out the address, but you save three (or however many) input pins by using the "prefix".
    If it were that simple. The challenge is... the same program loads into all devices (the props) and cannot simply "assign" a unique number to each prop. Each prop has no eeprom.

    humanoido
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-24 08:12
    John R. said...
    Depending on how bad you need the input pins, and how much circuit board real-estate (and ability to bear costs) you have, you could also hook up a bank of dip switches to the parallel side of a Parallel Serial converter (or shift register, not sure what the proper term is), and read the address in serially.
    pullmoll said...
    In parallel: of course not. In serial: you can use a 2 pin protocol to transfer a number of any size. You could e.g. add one ore more serial to parallel shift registers to obtain the parallel result of the serial transfer. An example for such a shift register is the CMOS 4094. If you want to avoid intermediary outputs, you would need 3 pins and use the LE of the 4094 to latch the result after 8 shifts. By using 2 of these chips, connecting Q0 of the first chip to D of the second, attaching the Propeller pin for the data bit to D of the first chip, the pin for clocking to both CLK and the pin to latch the result to both LE, you can shift out up to 16 bit numbers and latch them after 16 shifts.
    John: it looks like pullmoll had a similar good idea back in the first reply. If the shift register was used in the direction of reading from 6 pins and then put a serial signal back into the prop, latching the number, it could read the base 3 result. However, it takes 3 pins to control the shift register and another pin for the data (or two?). That would get it down from 6 pins to 4 or 5. Right?

    humanoido
  • John R.John R. Posts: 1,376
    edited 2010-03-24 12:09
    Yes, that sounds right on the pin count. But by the time you add that hardware, why not just add a small eeprom for the explicit purpose of holding the address? This probably wouldn't get connected to pins 28 and 29, and could potentially be used for other purposes as well.

    You could probably get the count down lower by using a serial ADC and use a voltage divider to set the address on the input(s).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • kwinnkwinn Posts: 8,697
    edited 2010-03-24 12:40
    @humanoido

    Re: "The challenge is... the same program loads into all devices". How is this program loading accomplished without an eeprom? Are all the props loaded in parallel from the same serial bit stream? If so, how are they all synchronized?

    If it is possible to load the same program to all the props pullmoll's idea seems to be the most practical way to go. It takes only 3 pins ( 1 to load the data into the shift register, 1 to read the shift register output data, and 1 for clocking the data in) and allows numbers to be any arbitrary bit length.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-24 15:41
    John R. and Kwinn:

    We're down to 3 pins with this method: (shift register, 3 components)
    Actually I see now, by sketching out the circuit, the shift register requires only three pins on the prop side and on the switching side, it can read up to eight bits, with no need for extra serial connections. That's plenty of bits for lots of ID numbers especially in base 3 (thanks Phil). I like this idea because the bits can be changed around with a dip switch. But, it comes with a price - the shift register chip, a dip switch, and a sip resistor array.

    This method uses 2 pins: (eeprom, 2 components)
    I was overlooking this method, thinking that the eeprom had to boot, but it does not need to boot if relocated to other pins. If it is possible to put the eeprom on pins 26 and 27 instead of 28 and 29, the prop will not try to boot from it and it can be used for storage of a unique sequential ID number and read by prop software. The component count is down too - one chip and one resistor. However, the question is...with lots of props, how will you get the number into the eeprom? I suppose the brute force method is just plug the eeprom into a prop circuit and run software to burn in the number, one eeprom chip at a time... Additional thoughts on this?
    John R. said...
    You could probably get the count down lower by using a serial ADC and use a voltage divider to set the address on the input(s).
    You mean a lower number of pins? How can you get any lower than the eeprom's two pins? Is there a sketch of this circuit?

    humanoido
  • John R.John R. Posts: 1,376
    edited 2010-03-24 17:43
    Just as a note: If you go with a shift register, you won't be able to use base 3, the sift registor only knows 0 and 1. The "floating" value only was available directly on the prop pin.

    The ADC was for lower than some of the other methods, not the eeprom.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • halkhatahalkhata Posts: 1
    edited 2010-03-24 18:25
    I'm also looking at possibly doing a "self addressing" daisy chain serial network. Basically, each unit would have a send and receive data connection. Each unit would "echo" the communication in and out. You could then send a command with "set address" and the first unit in the chain would grab address one, the second two, etc. This would support both a "broadcast" message, as well as messages to/from a specific node. This method does not help with other types of communication (Ethernet, wireless, etc.) It depends on a true daisy chain, with each station receiving, interpreting and either responding to and/or passing on (with or without modification) the command packet.

    Edinburgh Accommodation
    NBA and NCAA Picks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Russell Khan
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-03-24 18:52
    You could get by with two pins and no extra hardware if you wire all of the props into a long daisy chain.· Prop number 0 would have its input pin hardwired to low.· All of the other props would have their input pin connected to the output pin of the lower address prop.· A 1,000 prop chain would look something like this:

    [noparse][[/noparse]000]->[noparse][[/noparse]001]->[noparse][[/noparse]002]->[noparse][[/noparse]003]->[noparse][[/noparse]004]->[noparse][[/noparse]005]->...->[noparse][[/noparse]997]->[noparse][[/noparse]998]->[noparse][[/noparse]999]

    On boot-up, the props would look at their input pin and determine if they're the first prop.· All the props that are not the first one would wait to be assigned their number from the previous prop.· You could use a high-speed serial protocol to communicate from one prop to the next.· With a little bit of external logic the zero state on prop number 0 could go away, and a connection could be estabished to the last prop's output pin.· This way, you could create a token ring network that would allow sending messages from any prop to any other prop.

    Dave

    Edit:· I was editing my post·before I saw·Russell's post.· Quite a coincidence, or maybe the thread was slowing drifting that way.

    Edit 2: Oh, I should have read the whole thread.· I see that John R. proposed this yesterday.

    Post Edited (Dave Hein) : 3/24/2010 7:12:14 PM GMT
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-24 20:42
    Dave Hein:

    Wow - Unbelievable! We're at 2 pins and no parts.
    Advantages? Fewest number of pins, consecutive sequential numbers, no parts, no cost.
    Downside? Probably waiting times for assignments to complete (with large numbers of props), no way to "long term" remember the ID number unless eeprom storage is added (process must be repeated at every boot), and any fault in the hardware or software of any previous computer (such as hanging).

    humanoido

    Post Edited (humanoido) : 3/24/2010 8:50:08 PM GMT
  • mctriviamctrivia Posts: 3,772
    edited 2010-03-24 22:43
    I can do better. 0 pins and no parts(well kind of). Since I know the schematic i think you plan to use this is how you can do it.

    Prop 0 starts up with reset. It copies eeprom contents to ram(like normal) it then inctrements address $7FFF on the EEPROM and allows the next prop to start its boot.

    Props will alwasy have same id number in hub ram at location $7FFF

    Only con is the EEPROM will wear out after 100,000 boots.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    24 bit LCD Breakout Board now in. $24.99 has backlight driver and touch sensitive decoder.

    If you have not already. Add yourself to the prophead map
  • markaericmarkaeric Posts: 282
    edited 2010-03-25 04:34
    Humanoido,

    If I'm understanding your original question correctly, your trying to figure out how to convert an 8-bit value to individually address one of 256 physical lines, like the device in the following:

    
         _____________
        |              |
     1--|              |--1
        |              |--2
     2--|              |--3
        |              |--4
     3--|              |--5
        |              |--6
     4--|              |--7
        |              |--8
     5--|              |--..
        |              |--..
     6--|              |--..
        |              |--..
     7--|              |--..
        |              |--..
     8--|              |--256
        |____________|
    
    
    



    The left most column with inputs 1 through 8 correspond to the 8-bit addressing, and the right side is pins 1 to 256 that are activated based on the 8-bit address. I don't know if any specific device exists for this function (especially a full 8-bit one), but any mcu with a lot of pins could obviously easily do this.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-03-25 06:19
    No parts and no pins! Absolute winner!
    mctrivia said...
    Prop 0 starts up with reset. It copies eeprom contents to ram (like normal), it then increments address $7FFF on the EEPROM and allows the next prop to start its boot. Props will alwasy have same id number in hub ram at location $7FFF.
    I will try this and report the results. humanoido
Sign In or Register to comment.