FunkyMonkey
Posts: 3
Joined: Mon Jun 03, 2013 2:15 pm

Which expansion board(s) to interface these...

Mon Jun 03, 2013 2:32 pm

Hi all,

Very new to Pi, have an idea for a project, but I can't figure which expansion board I should be using, or whether the number of I/Os I need is too much. I've been looking around the forums and cannot find something similar. Here is what the Pi will need to be able to work with in my final project:
  • 8x keys (push to make buttons), possibly with LED indicators behind some of them
    5x six-wire stepper motors at 12-17v @ 310ma per phase. These will be active for less than a second at a time, but ideally need to move together - not essential though.
    5x voltage measurements taken from pots on an analog circuit (to check position of pots)
    MIDI in/out/Thru (though this can be done through a USB interface)
    1x display, could be as simple as a two digit 7-segment display if necessary, but a 2 or 4 row character display would be great.
I know that I will need to provide external power for elements such as the Steppers, my post is just about whether from a control/IO perspective it is possible to work with this much using the IO expansion cards that have already been created.

Any thoughts much appreciated!

Duncan

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5470
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Which expansion board(s) to interface these...

Mon Jun 03, 2013 6:40 pm

Duncan, Before committing to a purchase of one of the more complex (pre-built) expansion boards with most of the "bells and whistles" your project needs, it might be more worthwhile to "have a go" with something "cheap & cheerful" such as the "Slice of PI/O" board. For me, >15 years since I'd last done "lab-electronics" (having turned "keyboard jockey" :) , and with "not-so short sight") it was a good "re-start" project board. Currently I'm trying out other options (see the link in the sig.)
Cheers, Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Which expansion board(s) to interface these...

Mon Jun 03, 2013 7:20 pm

Personally I think that is a lot of disparate I/O there and I would personally build it up in stages after sketching out an overall plan of how to fit that many I/Os, analog I/O and motor control onto a Pi.

Do some planning out first
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

FunkyMonkey
Posts: 3
Joined: Mon Jun 03, 2013 2:15 pm

Re: Which expansion board(s) to interface these...

Mon Jun 03, 2013 9:16 pm

Thanks for the responses, and all good advice, starting a bit at a time is definitely the way to go. I have some electronics experience, but it is audio. I started programming with a ZX81 and school BBC, but eventually left programming behind after my degree, and am now getting the bug again :)

My main worry was whether the Pi could control (not power) that much, as a lot of what I have read says that you cannot use multiple expansion boards with a single Pi and give them different port/addressing spaces. The standard GPIO or Gertboard does not look as though it has enough on it, so I was starting to think I might need to use the Pi to control another microcontroller.

Duncan

tummychow
Posts: 41
Joined: Wed Feb 20, 2013 6:36 am

Re: Which expansion board(s) to interface these...

Tue Jun 04, 2013 12:03 am

Hm, I was going to suggest that you look for GPIO expanders, but the devices you want to use are a bit more... exacting.

Let's start with the easy stuff. Five pots, no problem. MCP3208 or something will clean that up easily. 8 channels of 12-bit analog input is more than enough for reading a pot. You could also do it digitally via a rotary encoder, depending on your application, but if it's audio, pots probably make more sense. I personally prefer i2c adcs (takes up fewer pins, and the Pi is very pin sensitive for big projects), but i2c adcs in a through hole package are basically non existent. If you're comfortable with surface mount parts, then I'm sure you know how to find the adc that's right for you. But if you aren't, then you're stuck with the SPI parts from microchip, because microchip is one of the only companies that sells almost ALL its stuff in dip packages.

Pushbuttons with LEDs - you can buy the buttons with LEDs built into them, but make sure you know where the current of the LED is coming from; the Pi can't safely drive an LED directly. If you don't need a lot of speed on the buttons, I would recommend you offload them to a GPIO expander http://www.raspberrypi.org/phpBB3/viewt ... 44&t=45258 because 8 buttons is quite a few for the Pi. However interrupts will be a lot more annoying if you take them off your main pins, and polling them is much slower, so it's a tradeoff you need to keep in mind.

MIDI - you're probably more familiar than me with this interface, but to be plain, the Pi doesn't have any onboard support for it, and I personally doubt you'd be able to run it off of GPIOs; audio algorithms always seem to need more speed and timing that only a real-time device can provide. Your guess is right - USB is definitely the easiest way to do this

steppers - this is the type of motor I'm not particularly familiar with. Lots of stepper driver boards exist but idk how they're controlled or addressed. I'd start off by looking on sparkfun.

display - a simple 2 to 4 line character display can be found on places like adafruit for a fair price. They throw in the soldering work to connect it to an i2c GPIO expander, which reduces the pin consumption of these devices. Libraries also exist, I know lots of people on these forums have played with these, so getting started should be a breeze. If you want a graphical/TFT type LCD, that's a bit of a steeper challenge, but it sounds like you're not aiming that high, so I won't go into it here.



Slaving a microcontroller to the Pi is a pretty big allocation of resources imo. You have to program another device, and worry about organizing comms between the Pi and the micro, which I would definitely want to do over a standard serial bus (i2c/spi/uart) and NOT over USB, because USB ports are even more precious than GPIO. There is one undeniable advantage to adding a micro though; you can compress a lot of these parts into one. A typical pic/avr will have a fair number of 10-bit adc lines for those pots, and it'll have enough GPIOs to handle those buttons (plus direct current source/sink for LEDs). If you already know your way around a microcontroller that's suited to this application, it might be a good solution as well. But if you don't, then that's a whole extra platform you have to learn, yada yada, that takes time.

One thing is for sure - existing expansion boards for the Pi will provide the features you want, but no one board will provide all of them, and I'm doubtful of the ability to stack boards to the heavens on the Pi. This is probably something you'll have to roll yourself.

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Which expansion board(s) to interface these...

Tue Jun 04, 2013 1:33 am

tummychow wrote:Hm, I was going to suggest that you look for GPIO expanders, but the devices you want to use are a bit more... exacting.

Let's start with the easy stuff. Five pots, no problem. MCP3208 or something will clean that up easily. 8 channels of 12-bit analog input is more than enough for reading a pot. You could also do it digitally via a rotary encoder, depending on your application, but if it's audio, pots probably make more sense. I personally prefer i2c adcs (takes up fewer pins, and the Pi is very pin sensitive for big projects), but i2c adcs in a through hole package are basically non existent.
If happy with 4 channels of 8but ADC then PCF8591P is available in DIP from places like CPC and plenty of software examples around on how to programme them as they are a design about 15 years old, you can have more than one of them as well.
Pushbuttons with LEDs - you can buy the buttons with LEDs built into them, but make sure you know where the current of the LED is coming from; the Pi can't safely drive an LED directly. If you don't need a lot of speed on the buttons, I would recommend you offload them to a GPIO expander http://www.raspberrypi.org/phpBB3/viewt ... 44&t=45258 because 8 buttons is quite a few for the Pi. However interrupts will be a lot more annoying if you take them off your main pins, and polling them is much slower, so it's a tradeoff you need to keep in mind.
Consider for that many switches something like a MAX6818 8 switch debouncer no extra components (resistors or capacitors needed) Feed the 8 outputs to an 8 or 16 bit I2C GPIO device like PCF8574 or PCF8575 or MCP23016. MAX6818 has an output to tell you if any of the switches have changed. If using 16 bit device the other 8 bits can be used to drive 8 LEDs.
Slaving a microcontroller to the Pi is a pretty big allocation of resources imo. You have to program another device, and worry about organizing comms between the Pi and the micro, which I would definitely want to do over a standard serial bus (i2c/spi/uart) and NOT over USB, because USB ports are even more precious than GPIO.
For slaving micros and two way communication UART is often easier to do as it is often easier to talk to UARTs and the Pi cannot act as a SLAVE device for I2C and SPi. So if the slave device needs to alert the master or send data it can just do it with UART, without using extra GPIO pins.
There is one undeniable advantage to adding a micro though; you can compress a lot of these parts into one. A typical pic/avr will have a fair number of 10-bit adc lines for those pots, and it'll have enough GPIOs to handle those buttons (plus direct current source/sink for LEDs). If you already know your way around a microcontroller that's suited to this application, it might be a good solution as well. But if you don't, then that's a whole extra platform you have to learn, yada yada, that takes time.

One thing is for sure - existing expansion boards for the Pi will provide the features you want, but no one board will provide all of them, and I'm doubtful of the ability to stack boards to the heavens on the Pi. This is probably something you'll have to roll yourself.
I am currently part way through a special design for another user as the requirements were beyond standard expansion boards, there is no magic expansion board to cover all applications stacked or not.

I also know as I do have some I sell as well, but I dont think they would be FULLY suitable for this much I/O and additional conditioning.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

FunkyMonkey
Posts: 3
Joined: Mon Jun 03, 2013 2:15 pm

Re: Which expansion board(s) to interface these...

Tue Jun 04, 2013 7:40 am

Thanks for such detailed responses - does anyone have any thoughts on how to control 5 6-wire steppers, could the I2C described above handle that as well (accepting that I will need to provide separate power).? I'll have a read, but the most Steppers I have seen projects using here is 4.

Duncan

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Which expansion board(s) to interface these...

Tue Jun 04, 2013 9:41 am

FunkyMonkey wrote:Thanks for such detailed responses - does anyone have any thoughts on how to control 5 6-wire steppers, could the I2C described above handle that as well (accepting that I will need to provide separate power).? I'll have a read, but the most Steppers I have seen projects using here is 4.
Depends on the stepper motor spec and what you are trying to achieve, MOST 6 wire steppers can be driven by using only 4 wires as the extra is for half steps. You need to ensure you have the details for the motor (a full datasheet would help).

Also depends on what stepping rates and for how long the stepping will occur.

Personally if I was to off load anything to a separate micro I would put motor control as that function,as this means you can get more timers and other motor support hardware in some micros. Then the main system commands this micro to start/stop etc the motors and provide feedback in a more guaranteed timing fashion, often with more control of the range of speed control.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

User avatar
liudr
Posts: 687
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
Contact: Website

Re: Which expansion board(s) to interface these...

Wed Jun 05, 2013 2:03 pm

I would think a microcontroller is better suited for the task instead of separate chips for separate parts of the project. You can start with an Arduino UNO microcontroller dev board. It has excellent tech support and hardware/library selection by the Arduino community. Programming part is separate from PI but pretty easy. It won't have enough pins to do all that you asked. It has 6 analog channels, 12 digital I/Os and 2 pins for UART. You can get an HD44780 61X2 character display (uses 6 I/O pins) for a few bucks. Then for motors you can get modules on ebay for cheap. Test your ideas and possibly go to a larger controller such as Arduino MEGA later.
Arduino data loggers, user interface, printed circuit board designer since 2009, RPI 3B 2B 2B Zero Jessie, assembly/C/C++/java/python programmer since the 80's

Return to “Interfacing (DSI, CSI, I2C, etc.)”