Pins instead of memory bits

Will it come to us consumers?

I want microcontrollers that using 1 kb of RAM to pins so I can control huge of stepper motors and lights and inputs.
Am I correct that ports using same method as bytes in RAM?

If you want that, you want a microprocessor where most or all the memory is external, not a microcontroller.

You can either have all of the pins on the chip functioning as I/O ports - which is a microcontroller - or all functioning as the address and data buses to access memory which is the configuration of a microprocessor. It is a bit of an ask to have both though some early chips did to a limited extent.

In practice, as you are not going to have that many pins on a single chip, you will need to use a large number of I/O expander chips, either parallel, serial or I2C. If speed is critical, you would use parallel buses on a microprocessor, otherwise serial interface to a microcontroller would use very few pins.

On a chip that supports external memory (like the ATmega2560 used on the Arduino Mega, you CAN set up a bunch of latches and gates that act just like memory, but are connected to external things. Thousands would be easy, at least from a "logic" perspective (actual wiring, power consumption, and etc would get messy...)
Usually (and especially for complex things like stepper motors), it turns out to be a lot easier to use a "smarter" external controller that need not be accessed so quickly.

I have some chips with over 1000 pins, but they're very expensive and nearly impossible to use. In fact, nearly any solution I can think of for putting 1000 "pins" on an Arduino is more expensive than just using 100 ATmega chips...

The registers that control the pins are accessed like memory, and are part of the same address space, but they are connected to additional circuitry. (Also, there are 3 or 4 registers per 8 pins, as you probably know)

I don't think there are microcontrollers designed for that sort of thing available - the biggest microcontrollers I've seen have under 200 pins, and those are sort of exotic, because needing oodles of pins is not a very common use case.

For cases where you need lots of outputs, there are other solutions that are probably more appropriate...

If they're output only, you can string (almost) as many shift registers together as you want, and control with a small number of pins.

If you need full-fledged pins, with input/output, you can use I2C or SPI port expanders, like the MCP23016 (you can put up to 8 of those onto an I2C bus, giving you 128 pins) or the MCP23S16 (SPI, can use as many as you have pins to drive the CS line of)

For the specific case of controlling LEDs, there are a number of daisychainable individually addressable LEDs, that you just string together, and control the whole string of them via a single pin (the most popular is the WS2812 ).

I don't see the point or need to have every thing memory mapped inside the micro-controller in h/w.

In my opinion at the end of the day, most of it really comes down to s/w anyway.
If you define a nice clean layered architecture of APIs, what is underneath and how it is implemented becomes fairly irrelevant.
Performance can be an issue but that really comes down to overall system design.

i.e. define your layered APIs and write your s/w to the APIs. Then you can write the lower level functions to push the information over whatever interface is needed to wherever it needs to do.

It ought to be easy to enhance "digitalWrite()" to operate on any number of "external" pins, using any number of possible communications mechanisms. (Of course, if you're not careful, you'll wind up like the original Arduino Galileo, with the pin update rate being shamefully and unexpectedly low.)

It's be an interesting FPGA project, to interface to the AVR external memory bus and provide N individually addressable pins at full memory speeds. Expensive, though; the cheapest 64pin FPGA is about $20. I wonder if it would fit in a CPLD? (cheapest 64-pin CPLD is less than $1.)

(Oh wait: there are some cheaper FPGAs with MORE pins.)

Adding external shift registers is significantly cheaper tho, just 20 cents/8 bits in for 800 output pins for example

100 pieces = $20.20

100 SPI.transfers at 8 MHz can take just over 100uS if done smartly (17 clocks per byte, reading data from an array).
Daisy chain them all, buffer SCK and SSPIN so they're not degraded driving 100 chips.
I've done 45 without any issue doing that, updating them at 20KHz rate.

If you are willing to abandon the AVR, you could use other processors (pic32 or ARM) that have DMA and you could set up a block of RAM that gets pushed out to the external h/w using DMA which would be much faster than shifting out data using the AVR SPI.

--- bill

Hmm... Let me count how many pins I roughly need for this huge project:
Roughly 80 stepper motor at 4 pins each
200 LED diodes
200 toggle switches at 2 pins each
and an amount of rotary encoders, buttons and such.
I need roughly 1000 pins.
Most of pins to my home cockpit project are system logic such as calculate fuel flow, APU, startup engine, navigator, warning. Of course I shall have X-Plane as rendering to play the simulator with.

Divide by 8 bits, then I get 125 bytes, maybe more if something happens unexpectedly.
Maybe I am needing 16-bit microprocessor ? Or is 8-bit with support for 64 kB enough ?
I see I need to find a lot of trick because of RS-232 limit speed but that should be possible.

Use shift registers for the LEDs.

For the rest use multiple interconnected Mega's or Due's. This might also give you some degree of fault-tolerance if you design it well.

Ah! Here's the answer! :roll_eyes:

How much easier is it once we get over the XY problem!

You don't drive stepper motors with Arduino pins. You can't!

You drive steppers with stepper drivers, and they use two pins per motor.

You don't drive LEDs individually with pins either. You can't!

You drive LEDs in matrices with MAX7219 drivers which require 3 pins and can be cascaded. It also makes the wiring immeasurably easier. You need four MAX7219s to drive 256 (single) LEDs, and when cascaded, they are still only 3 pins for the lot.

Similarly, you matrix the switches. You require a diode for each switch, and read them with shift registers, so your 200 switches come back to about 3 or 4 pins.

If you use shift registers to control the stepper drivers, that could be an extra pin as the others are shared with the other shift registers.

So you can do it all with a single ATmega328 though you just might require something with more memory.

And again, using shift registers and such makes the wiring far easier than it would be if you ever did have a single chip with that many pins (but you would require driver chips for all the functions other than switches anyway.)

Understood!
But is 16 MHz enough to drive every instruments, LED, switches, rotary encoders, etc?
It should be enough speed. Otherwise, I have an Arduino DUE.

You drive LEDs in matrices with MAX7219 drivers

MAX7219 is way overpriced, at least for real ones from real distributors. (~$9)

You could get an Adafruit/Scanlime "Fadecandy" that will drive 512 neopixels (arranged as 8 strips of 64 each) for about $25. Of course, the "Neopixel smart RGB LEDs" are more expensive than regular LEDs, but they might be worth it.

Qwseyvnd:
But is 16 MHz enough to drive every instruments, LED, switches, rotary encoders, etc?
It should be enough speed.

Well, that's for you to figure out.

We can't as we have no idea what you want it for. Sixteen million instructions per second is pretty fast and there is always the option of using direct assembler.

westfw:
Of course, the "Neopixel smart RGB LEDs" are more expensive than regular LEDs, but they might be worth it.

They have one particular advantage- they do PWM for you.

Qwseyvnd:
Hmm... Let me count how many pins I roughly need for this huge project:
Roughly 80 stepper motor at 4 pins each
200 LED diodes
200 toggle switches at 2 pins each
and an amount of rotary encoders, buttons and such.
I need roughly 1000 pins.

It is possible that your conclusion on number of pins may be overly aggressive.
You may need to control 1000 "things" but that does not necessarily mean you need 1000 pins.
There are many ways to control things that don't need or use a separate pin especially on the main controller.
(you may end up with desperate slave i/o boards)

I'd recommend stepping back to consider your high level requirements.
and let that determine your overall architecture.
Things like: features, functionality, performance, power budget, money budget, physical size, calender time available, all must be decided.
And often there must be re-world tradeoffs as you progress from the original "wish list" to the final what is possible within all the real world constraints.

For example, you say you need to control 200 LEDs.
A big questions is how fast do you need them to be updated and do they need dimming, and if they need dimming, do they need to be dimmed individually or can all of them be dimmed together?

200 toggle switches? That is a lot of switches.
Do you really need that many individual switches, or is it possible to use an alternative user interface so that the user can set the toggles in s/w instead? i.e. a LCD with a menu system that allows the user to set options. Or a combination of dials and buttons that allows the user to select and modify a given toggle, etc...

This is just an example of the types of things you must determine in order to help guide to your final design.

--- bill

200 leds is one pin by my count. I'd you dont need rgb ones, just single color, could use ws 2811s with 3 single color leds, and update them 3x faster...

No matter what, I think this project calls for multiple microcontrollers, though.....

bperrybap:
(you may end up with desperate slave i/o boards)

Definitely a possibility! :grinning:

Modular and chained slave boards are the obvious approach, just in regard to the practicality of wiring.

We still do not know the actual application, but it sounds like some sort of interactive "chessboard" or "Monome" style interface, similar to Mike's project, but scaled up somewhat. Just don't know how the steppers feature.

DrAzzy:
No matter what, I think this project calls for multiple microcontrollers, though.....

I cannot see that multiple microcontrollers is an advantage. Multiple secondary interfaces most certainly, and a single microcontroller with sufficient memory, but you lose both performance and efficiency when you have to arrange the inter-processor communication.

It is for home cockpit project.

Well, that sounds relatively simple.

Switches are just switches. Not going to be changed rapidly, so can be multiplexed very nicely.

Similarly, indicator lights do not require to be (individually) colour changing or dimmed, so the MAX7219s will be perfect.

And the steppers (or possibly servos which would probably be much more appropriate for gauges) do not have to respond particularly quickly from a computational point of view.

Servos can be multiplexed eight to one pin using a 74HC4017 though that might be an application for a second ATmega328.

westfw:
I have some chips with over 1000 pins, but they're very expensive and nearly impossible to use.

I'm curious as to what these are? I'm pretty certain (but not completely) that even the latest Intel or AMD CPUs don't have that many pins/lands...

I'd like to see it, or look at the datasheet - whatever it is.