Monthly Archives: August 2017

8/30/2017 – Arduino revisited one more time

So things have been rather quiet at OPP central right now.  Got back from Pintastic, and I’ve basically done no real pinball related things.  I kinda miss it since I was spending so much time for a while.  Nobody is even posting on the BPA (Boston Pinball Association) except for the random machine for sale here or there.  Pinside has also been rather dull, but that is probably because I don’t know what threads are interesting.  There are some small email exchanges going on, but even those are mostly short and to the point.

So, pondering one evening, I thought to myself that I should create an Arduino shield since so many people use that platform.  As you’ve all read before, I hate the Arduino framework, but I actually thought that I liked the base processors a lot.  The one guy mentioned that I could simply program everything in C and ignore all the “helpful” classes that get rid of all the dirty nastiness of the processor.  (Of course that dirty nastiness is what allows you to squeeze so much performance out of these little processors).  My original thought is because it has more I/O it would be easier for people to use it in a centralized way.

Anyhow, last weekend, I started to do the base research of the feasibility and the value of creating such a shield.  So below I will do a little bit of a comparison with the PSoC 4200 that currently use for the OPP wings, and the Arduino Mega.

  1. Cost – PSoC $4, Mega $8.45 on Ebay.  The Arduino is more than twice as much.  This is buying off Ebay and trying to find the cheapest source.  If you went aliexpress you could get it for about $7, but I have never bought off aliexpress, so fear of the unknown factors in that a little bit.  You can probably assume about a 30 day wait if you buy from aliexpress.  PSoC is the winner here.
  2. I/O Pins – Mega 54, PSoC 36.  The mega definitely has more I/Os.  That makes it very attractive and probably why I started doing this exercise.  It was difficult for me to figure out the data sheet and find how many are dedicated I/Os versus general purpose I/Os.  I think that is mostly because the Arduino framework wants to configure certain pins to certain functions so people can create generic shields.  For a pinball controller, you mostly want raw inputs and outputs.  Some PWMs would be great also if they could be routed to the correct pins.  PSoC has 36 pins which 32 are generic I/Os, leaving 2 pins for communications (Tx/Rx), plus 2 more pins.  For me it is really the sweet spot of I/Os.  I can send a 4 byte (32 bit) value back to the host that gives the state of all the inputs.  At 54, I would probably choose to send back a 6 byte (48 bit) value back to the host.  That would make the host code a little more sticky.  Regardless, more is always better, so Arduino is the winner.
  3. Voltage – PSoC 5V, Mega 5V.  I like 5V I/O more than 3.3V and both processors support it.  At 5V you have more choices of MOSFETs so that is all good.  Interfacing to a Pi is more difficult, but level shifters are pretty easy to work with in this day and age.
  4. Flash – Mega 256K, PSoC 32K.  Mega has much more flash.  In the latest version of the OPP firmware, it is using approximately 70% of the flash of the PSoC.  If I had more codespace, I’m not sure what I would do with it.  I’m guessing the Mega needs more flash because of the Arduino framework.  That is not a big selling point to me as mentioned before.  Arduino is clearly the winner.
  5. SRAM – Mega 8K, PSoC 4K.  Once again, Mega has more resources including SRAM.  (Places where you store variables in your code, stack and heap).  The OPP original project worked with a processor that had 8K of flash, and 512 bytes for RAM.  (That included a bootloader that took 768 bytes of flash).  Again, Arduino is clearly the winner, but since I have enough resources, it doesn’t matter that much.
  6. Processor Frequency – PSoC 48 MHz, Mega 16 MHz.  OK, this is one parameter that I do care about.  With the addition of switch matrix support, the processor is starting to need to do much more processing.  With the PSoC it has plenty of headroom and I don’t worry about things like updating LEDs, sending responses to the host, reading the switch matrix, and firing solenoids all at the same time.  The running loop happens so quickly, that all of these things can happen within that loop time.  At 16 MHz, I’m not so certain.  When trying to decide whether to make an Arduino shield, this was the nail in the coffin for me.   PSoC is clearly the winner.

There is an Arduino Due.  It has the same number of I/Os, but changes the processor to 3.3V.  It has even more flash (512K) and RAM (96K), and it is running at 84MHz.   It also costs about $12.50.  As a processor, that is interesting.   As a pinball controller, it is just seems a little expensive to me.  (Going into this, I thought I was going to find an equivalent part to the PSoC at about $6 in the Arduino world, but I just haven’t found it.)

I’m glad I took the time to learn more about the Arduinos, and do a little bit of research.  At this point, the idea is going back onto the shelf until the prices drop a little further.  I might ask for an Arduino Due for Christmas, just to play with it, but that’s what it is going to end up being, one more toy in the basement in a box.