Shop OBEX P1 Docs P2 Docs Learn Events
I/O's and ADC ? — Parallax Forums

I/O's and ADC ?

amossamamossam Posts: 35
edited 2012-08-04 18:07 in Propeller 1
Hey

I have Propeller QuickStart board, and I'm starting to develop a add-on board. Till some parts come, i did some research and now i need some hints from experienced peoples... ;-)

First "issue" is number of I/O's. Over here is written that pins 1 - 28 are generic I/O pins, and rest 12 pins are having some functions (in witch I don't want to interfere?)... Is there a simple way to extend number of pins?

The reason I ask is because the add-on board should had to have 5-6 motor drivers (pololu A4988 driver), but i'll first start with 4. Now, each motor driver have 3 signal pins, ENABLE, STEP, DIRECTION. I could connect ENABLE pin to 5V over jumper, but I would like to avoid that.
So, this part takes 15-18 pins, and 13 more available...

Next, I need to read temperature sensors, NTC resistors, so I need ADC. Here is also a second "issue", what simple ADC are you recommending? 3 or 4 channel ADC should be enought. So, let say that it's 4 chanel ADC, that takes 4 I/O pins (?). (and also, maybe it would be a good idea to put temperature sensor to motors? that's another 5-6 pins?!)

And, board will also need to control 2-3 MOSFET's, so that's another 2-3 pins taken...

And now we are left with 6-7 free I/O pins...

So, if I want, in near future, add a LCD display(say 2x40 chars), and/or (micro)SD card reader, I'm out of I/O pins?!

And, I would like to stick with QuickStart board, because is reasonably priced and easy obtainable (and I have already one at home!! :-) )...

thx for any comments or suggestions! (critics are also welcome! :-D )

Comments

  • pik33pik33 Posts: 2,397
    edited 2012-08-02 10:54
    Sensors can be multiplexed. i2c multichannel ADC can communicate with a propeller with 2 pins

    There are 32 i/o in the Propeller. 4 of them are used to communicate with PC (2) and EEPROM (2). They can be reused after the Propeller start, if really needed (this is no trivial task)

    So, you can use 18 pins for motors, 2 pins for ADC, 3 pins for mosfets, all 23 pins. 5 pins free. Serial LCD display can be used and you still have free pins.

    You can always use a second propeller if you have no more pins. 6-7 free pins is more than needed to make communication between two Propellers. Two or three pins are sufficient to send serial data @ >>100kbps between props. Then you have another 28 i/o pins.
  • kwinnkwinn Posts: 8,697
    edited 2012-08-02 12:29
    I would suggest using a second prop as pik33 suggested. The prop chip costs less per I/O pin than most chips used for expansion and provides the added benefit of unloading some of the work from the master prop. A simple serial link would allow the master prop to issue commands to the motors and read the temperatures and other status information. I would also suggest using the MCP3208 adc. It does not cost much more than a 4 channel chip and the 8 channels would leave room for expansion.
  • TubularTubular Posts: 4,706
    edited 2012-08-02 14:18
    This is sounding like 3d printing that I am also wrestling with.

    Using the MCP3208 gives you 8 channels, 3 for thermistors and you can use 3 others for end stops.

    The stepper motor driver enables can be all joined to a single pin (single "All Motors Off" pin).

    If you use a serial LCD backpack, this can take just 1 pin on the Prop, and it can be P30 (so the same 'stream' is visible either on lcd or serial console)

    I'm guessing you're wanting VGA. You can use a 4 or 5 pin variant (losing color depth) and gain a few pins.

    But I'm coming to the conclusion a dual prop system would do it a whole lot more comfortably. I'm looking at one prop board that has all the HMI (screen, joysticks, buttons, SD card, optional video out) on the one PCB, and a RAMPS style driver board underneath.
  • amossamamossam Posts: 35
    edited 2012-08-02 15:34
    @pik33 & @kwinn: second propeller would be an option, true. but, for _basic_ functionality i would like to have only one propeller, and leave option for connecting second one if needed.

    so, MCP3208 is in the basket...

    @Tubular: yes, you got it! :cool: I'm currently designing(?) pcb, and now I have a dilema... you suggest that ENABLE pins of all motor could be tied together, and one my friend told me this evening that I could just put a jumper near each driver! And your idea of connecting end stops to ADC didn't crossed my mind, but i like it! :smile:

    Well, LCD would be used for info about print, and maybe settings (keypad also over I2C)...
    VGA? no thx, why should i want VGA on printer??

    P.S. with what part are you wrestling? for me, beside this electronics part, software seems, well not easy, but not that hard!?


    P.P.S.

    So, now we have this:
    2 x number of motor drivers + 1 (for "enable all") = 13 pins (before it was 18)
    SPI = 2 +
    1 for ADC
    1 for microSD reader
    = 4 pins
    for LCD display and keypad - 2 pins (I2C)
    for MOSFETs 3 pins

    TOTAL: 22 pins, and that leaves 6 free.
    So, if we leave 2 pins for communication with second prop, that leaves 4 pins free!

    P.P.P.S.
    In I2C bus specifications says that i can use single pull up resistors for SDA and SCL line for all devices.? And also, two wire communcation? But every device needs and separate CS line??

    thx to all
  • TubularTubular Posts: 4,706
    edited 2012-08-02 16:39
    Ok, great. I think the prop will do brilliantly

    I assumed VGA from your "12 pins reserved" comment - the 4 special pins P28~31 plus 8 for VGA. But what you mean is power rails, boen, reset, xtal pins, ie the 'other' pins on the 40 pin DIP package.

    For SPI it is more like 3 pins (CLK, SI, SO) plus the chip selects. I2C doesn't need anything beyond SDA and SCL, so just the two pins almost universally on P28 and P29.

    "Wrestling" really refers to the design phase, and how to squeeze the pins in. In my design I'm trying to accommodate analog joysticks for HMI navigation and manual axis control. I alternate between looking to use the RAMPS board and redesigning an equivalent that could take a dip40 prop.
  • amossamamossam Posts: 35
    edited 2012-08-03 01:09
    Tubular wrote: »
    Ok, great. I think the prop will do brilliantly

    I assumed VGA from your "12 pins reserved" comment - the 4 special pins P28~31 plus 8 for VGA. But what you mean is power rails, boen, reset, xtal pins, ie the 'other' pins on the 40 pin DIP package.
    yes, I meant on pins after P28.

    Tubular wrote: »
    For SPI it is more like 3 pins (CLK, SI, SO) plus the chip selects. I2C doesn't need anything beyond SDA and SCL, so just the two pins almost universally on P28 and P29.
    Ok, so ADC and microSD over SPI will take 5 pins. While I have found ADC over I2C, i haven't found microSD reader over I2C, and I would like to have microSD to be integrated in the board, without add-on board.
    Tubular wrote: »
    "Wrestling" really refers to the design phase, and how to squeeze the pins in. In my design I'm trying to accommodate analog joysticks for HMI navigation and manual axis control. I alternate between looking to use the RAMPS board and redesigning an equivalent that could take a dip40 prop.

    Well, my primary goal is to create fully functional, but basic, electronics and software for reprap, and leave space for expansion! And if I saw correctly, if I'm careful now in design stage , I could just replace 2x20 pin header with DIP40 prop and add voltage regulator!

    MCP3208 is ordered and it should arrive in 2 weeks or so, and at same time the driver boards should arrive also!
  • TorTor Posts: 2,010
    edited 2012-08-03 05:36
    Maybe Parallax should start selling a QuickStartDuo board.. the QS is so versatile as a starting point. If a dual-propeller board with the same easy-use approach (and reasonable price) as the QS existed I'm sure many people would jump at the opportunity to explore multi-prop possibilities.

    -Tor
  • kwinnkwinn Posts: 8,697
    edited 2012-08-03 12:27
    Tor wrote: »
    Maybe Parallax should start selling a QuickStartDuo board.. the QS is so versatile as a starting point. If a dual-propeller board with the same easy-use approach (and reasonable price) as the QS existed I'm sure many people would jump at the opportunity to explore multi-prop possibilities.

    -Tor

    Great idea Tor. If it was clocked and loaded from the first prop the additional cost would be mainly for the prop chip itself, and so pretty minimal. I wonder if the board could remain the same size if the touch pads were replaced with a second connector ?
  • kwinnkwinn Posts: 8,697
    edited 2012-08-03 12:28
    There are lots of ways to minimize the number of I/O pins required.

    For chip selects you can use a '595 and have 2 pins select 1 to 8 chips, and multiple chips can be chosen at one time. Putting multiple '595's in series lets you increase the number of chip selects in multiples of 8.

    A '138 allows you to select 1 of 8 chips using 3 pins, but only one chip can be selected at a time.

    A '4017 can select 1 of 10 chips using 1 I/O pin if the chips can be selected by a high level (usually CS is low).

    A multiplex/demultiplex chip like the '4051 can input or output 1 of 8 signals using 1 pin for data and 3 pins for addressing. Using 2 of them would allow you to read an array of 64 switches using 7 pins. It is an analog mux/demux so it could be used to select one of 8 analog voltages for input to an ADC channel.

    If you have several peripherals that require multiple parallel signals you can use a '244 to switch groups of 4 or 8 pins to different peripherals. If the signals need to be held for a period of time you can use a '273 or '373 octal D latch.

    These and similar chips can reduce the number of prop pins required for I/O, but there are limitations. The main ones are speed, flexibility, and board space. In many cases once the number of additional chips gets beyond 3 or 4 it is better to use a second prop as an I/O processor. The additional cost is not much if any more than the other chips would be once the board space is taken into account, you have 30 additional I/O lines, 8 processors to deal with the I/O and reduce the complexity of the main program.
  • amossamamossam Posts: 35
    edited 2012-08-03 14:40
    kwinn wrote: »
    .....

    i thought about that when I started to think about this project, but i abandoned that idea, mostly because of probable code complexity. and i think that second prop would give much more benefits. I want to keep it single sided, at least for start, and size the same as QuickStart board is.

    When I discovered Parallax Propeller, I was amazed by it's speed and number of cogs (cores)! and now, just few months later I'm thinking of using not one (8 cogs) but _two_ (16 cogs) props in single project!! :-S

    btw, on pin 40 goes Vin, external power. is enough to put a diode there or I need to put anything else so that board can be powered externally and still be able to connect to usb?
  • cavelambcavelamb Posts: 720
    edited 2012-08-03 15:21
    amossam wrote: »
    i thought about that when I started to think about this project, but i abandoned that idea, mostly because of probable code complexity. and i think that second prop would give much more benefits. I want to keep it single sided, at least for start, and size the same as QuickStart board is.

    When I discovered Parallax Propeller, I was amazed by it's speed and number of cogs (cores)! and now, just few months later I'm thinking of using not one (8 cogs) but _two_ (16 cogs) props in single project!! :-S

    btw, on pin 40 goes Vin, external power. is enough to put a diode there or I need to put anything else so that board can be powered externally and still be able to connect to usb?

    Pin 40 is Vin, which feeds the on-board regulator.

    As for using the USB and external power at the same time, I believe that would connect
    your external power supply to the PC via the USB power feed.

    Sounds link a dramatic way to let magic smoke out of lots of places.
  • kwinnkwinn Posts: 8,697
    edited 2012-08-03 19:44
    amossam wrote: »
    ....

    btw, on pin 40 goes Vin, external power. is enough to put a diode there or I need to put anything else so that board can be powered externally and still be able to connect to usb?

    If you wanted to connect the usb cable for programming or serial communications while the board is still powered by the external supply you would need to put a blocking diode between the usb +5V connection and the rest of the QS board. Not sure if there would be enough voltage after the diode to allow the regulator to power the QS board from the usb connector.
  • BitsBits Posts: 414
    edited 2012-08-03 21:13
    kwinn wrote: »
    There are lots of ways to minimize the number of I/O pins required.

    For chip selects you can use a '595 and have 2 pins select 1 to 8 chips, and multiple chips can be chosen at one time. Putting multiple '595's in series lets you increase the number of chip selects in multiples of 8.

    A '138 allows you to select 1 of 8 chips using 3 pins, but only one chip can be selected at a time.

    A '4017 can select 1 of 10 chips using 1 I/O pin if the chips can be selected by a high level (usually CS is low).

    A multiplex/demultiplex chip like the '4051 can input or output 1 of 8 signals using 1 pin for data and 3 pins for addressing. Using 2 of them would allow you to read an array of 64 switches using 7 pins. It is an analog mux/demux so it could be used to select one of 8 analog voltages for input to an ADC channel.

    If you have several peripherals that require multiple parallel signals you can use a '244 to switch groups of 4 or 8 pins to different peripherals. If the signals need to be held for a period of time you can use a '273 or '373 octal D latch.

    These and similar chips can reduce the number of prop pins required for I/O, but there are limitations. The main ones are speed, flexibility, and board space. In many cases once the number of additional chips gets beyond 3 or 4 it is better to use a second prop as an I/O processor. The additional cost is not much if any more than the other chips would be once the board space is taken into account, you have 30 additional I/O lines, 8 processors to deal with the I/O and reduce the complexity of the main program.

    The side effect to all this is the loss of speed. Is this correct to assume?
  • cavelambcavelamb Posts: 720
    edited 2012-08-03 23:07
    Bits wrote: »
    The side effect to all this is the loss of speed. Is this correct to assume?

    Yeah, Bits. You got it.

    I'm offering this for discussion and as an example of the "old ways".

    The problem I see with shift register I/O is performance.
    The software overhead guarantees that.
    Setup, clocking data, etc.
    t takes a while to get a bit set. Or read.

    This dumb TTL circuit takes 8 pins and turns them into 64 pins -
    your choice
    any combination of input or output (8 bits at a time, of course).

    For this circuit, driver software is pretty straight forward.
    Build a byte with address, enable high, and (for output) data bit.
    Write that to the eight pins.
    Mask enable low and write that. The bit appears at the selected pin.
    That's it. Yer done.

    For input the data pin needs to be turned around to an input,
    the address set and written with the enable bit low.
    Ina(data pin) to read the results.

    There are some electrical issues involved here.
    I haven't looks at the capacitive loading on the address and data pins.
    But as slowly as programmed I/O happens I can't imagine any real problems.


    EXP64.jpg
    915 x 829 - 94K
  • kwinnkwinn Posts: 8,697
    edited 2012-08-04 13:36
    @bits, yes, the side effect or trade off for this is speed, but in many cases the speed is more than adequate. The speed can also be increased greatly by having the code to shift the data out written in PASM and running in it's own cog. Lets say you have 4 '595's connected in series to provide 32 bits of output. You have a long variable in hub memory where a spin program updates the bits. A cog running a PASM program monitors that hub location and shifts out the data whenever a change occurs. These '595's can be updated several thousand times per second. More than adequate for most mechanical systems.
    cavelamb wrote: »
    Yeah, Bits. You got it.

    I'm offering this for discussion and as an example of the "old ways".


    For this circuit, driver software is pretty straight forward.
    Build a byte with address, enable high, and (for output) data bit.
    Write that to the eight pins.
    Mask enable low and write that. The bit appears at the selected pin.
    That's it. Yer done.

    For input the data pin needs to be turned around to an input,
    the address set and written with the enable bit low.
    Ina(data pin) to read the results.

    There are some electrical issues involved here.
    I haven't looks at the capacitive loading on the address and data pins.
    But as slowly as programmed I/O happens I can't imagine any real problems.

    This is an excellent way to speed up I/O but it also uses a lot more I/O pins. Very useful for accessing external memory. If you look at it in a certain light this is also a form of serial expander, the main difference being that you are writing 8 bits per clock pulse rather than 1 bit.
  • cavelambcavelamb Posts: 720
    edited 2012-08-04 14:44
    kwinn wrote: »

    This is an excellent way to speed up I/O but it also uses a lot more I/O pins. Very useful for accessing external memory. If you look at it in a certain light this is also a form of serial expander, the main difference being that you are writing 8 bits per clock pulse rather than 1 bit.

    Uh, not, not exactly.
    All of the chips in that circuit as single bit ports.
    The '259 does indeed have 8 outputs, but they are addressed as single bits.
    (Just one data pin on the chip). The '151 is the same.

    The speed advantage comes from not having to shift anything.

    Nor is is necessary to mask off the other 7 bits of an 8 bit parallel port (LS373, for instance)
    to set one bit, or mask off the other 7 bits when reading from an 8 bit port (like LS244)
    Want a 1, just write a 1. Want a 0, write a 0.

    The top chip on that drawing is an LS-151, eight to one multiplexer.
    It has the same advantage. Read the bit you are interested in,
    no masking needed.
    That's not all that unusual for the Propeller since it reads with ina[bit],
    you only get one bit anyway. But reading from a shift register takes a
    lot more code.

    But the main reason I wanted to bring this up is for massive I/O expansion.
    That circuit expands 8 Prop pins into 64 I/O pins.
    (call it two additional Propeller chps - without communications problems!)

    It's just a different approach from shift register chips like the '595.

    There is always the potential tradeoff - hardware for software - software for hardware.
    Software takes time to execute and cost money to write.
    Hardware takes board space and takes money to fill.
  • kwinnkwinn Posts: 8,697
    edited 2012-08-04 18:07
    Yes, my mistake. I thought you were writing bytes out to octal latches, not individual bits. I am a bit chagrined over this mistake because the '259 is my preferred chip for address decoding, enabling buffers, clocking octal latches, and latching individual bits. It is much more flexible and user friendly than the '138/'139.

    I can see how this would be very useful when you want to set or read individual bits, particularly in spin where the bit shifting/masking is done by the interpreter. This is definitely faster for randomly accessing and processing individual bits with spin. In PASM you would still need to shift and mask the bits.

    It is always good to have a number of options available for a task so you can choose the one that fits best.
Sign In or Register to comment.