Arduino: Sometimes I love it and sometimes it is a hate relationship. Were I a teacher in computer science and Arduino were a student, she would likely get a C-. With a little extra credit time, maybe a C+. My belief is that the Arduino is so popular not because it is particularly easy to learn but because it hides a lots of ugly underneath the disguise of easy. Said another way, the only easy thing about Arduino is that doing the example projects always work 100% of the time.. Move to either side of the center-line in the Arduino highway and you are likely to get hit. I have been using the Arduino for more than 3 1/2 years and I still venture very carefully when deviating from the Arduino prescribed way of doing things.
What's wrong with the Arduino way? Primarily efficiency. The Arduino libraries mask many ugly programming sleight-of-hand tricks to provide a relatively easy syntax for the Arduino programmer. But such things come at an expense of code size which impacts the flash storage which impacts the number of instructions the microcontroller must execute to perform a function. Another fault with the Arduino is that the chip is purely digital - there are no analog components such as OpAmps. If you need an OpAmp, they must be placed external - adding cost and complexity to the design. And the older Arduinos are 8-bit and showing signs of age. Still a worthy investment especially at clone-prices due to the vast library support; the 8-bit migration has already started and is quickly moving to the 32-bit platforms, such as the Arduino Due.
So, the big question I asked myself 2 months ago was whether to learn the Due which is based on ARM core technology or go down a different road entirely? After a weekend of Internet surfing, I took the road less traveled.
Cypress' PSoC 4 is now over a year old and is supported by Professional Grade tools all of which are downloadable for free.
While searching for a new 32-bit technology to in which to immerse myself, I looked at the Teensie 3.1 as well and the Arduino Due and a number of NXP microcontrollers recommended by friends. However, I kept returning to the Cypress line of PSoC controllers - especially the PSoC 4 line including the 4100 and 4200. Cypress is selling what they call a "prototype board" which has the 4100 and 4200 series processor which has a 5LS series processor pre-programmed as the USB-serial interface. These prototype boards are being sold through parts houses such as Element14 and Mouser for $4. Yes, that is one dollar, two dollar, three dollar, four... four dollars! These boards are high quality boards with the two microcontrollers separated by a break-away area so that you can detach the USB-serial unit if desired. I have a picture showing a breakaway with pin headers to be reused. (Hint: buy the 4200 and not the 4100 as it is more capable at the same price!)
Also, in pictures is the Pioneer Kit. This is a $25 board that has Arduino UNO style headers pre-soldered. The uniqueness of this offering is that the 5-series uC on the board provides full source code debugging for the primary microcontroller - a 4200. Wow. It was this offering coupled with the $4 prototype boards that made me jump the fence.
If you have never worked with a professional software development system (free) and a full-uC debugger, you are in for the treat of your life. Breakpoints, variable tracing, and memory views create a died-and-gone-to-heaven scenario: All for $25. The code developed and debugged can be instantly ported to the 4200 on the $4 board for deployment. Through August and September of 2014, Cypress is offering the naked 4200 for only $1 each, shipped. For those with reflow ovens, this is a hobbyist dream come true.
This news is worth investing a few neurons to contemplate: A 32-bit professional development system, a fully interactive and register level debugger, and a deployment board all for under $30.
Too good to be true? No! What is the downside?
Well, now that you asked, you need to be semi-proficient to use a professional software product and to grasp the concepts around the PSoC 4 implementation.
- The good news, there are hours and hours of training videos available. http://www.cypress.com/?id=1162&source=support
- The bad news, there are hours and hours of training videos available plus enough PDF documents to constipate the largest of hard disks.
Said another way, the entry path to professional is to become professional. The terminology is no longer the colloquial vernacular of ":sketches" but rather the use of the term "firmware". Yep, you have to learn to speak professionally. Each short video has a repetitive sales-pitch: It gets monotonous, but it only last about a minute (per video.) PDFs exist for everything: you can highlight a component, right-click, and pull the specific PDF out of the installation. Great, but unless you have text to voice enabled, you are still going to have to read the technical documentation. And Cypress has volumes of technical documentation.
I was comfortable with my Pioneer board after I got the blinking LED to work. Then, I found out that unlike the Arduino (excepting PWM), there are large numbers of sub-systems in the PSoC that can run without any processor intervention! So, in PSoC there are 3 (probably more) ways to blink a LED and only one uses firmware. For Arduino users, this is going to be a shock.
For me, I went from comfortable to terribly confused - I wondered what I was thinking when I broke away from my Arduino comfort zone. But after a good nights rest or a nice long nap, your rested brain will realize the magic of the PSoC concept: configurable building blocks of digital electronics, gates, and analog components all in one package. Sheer Magic, Remarkable Flexibility. Your mission, if you decide to take it, is to invest the time and effort to breakthrough the conceptual barrier - for me, about 2 weeks, a few hours per day.
I found a most welcome treasure trove of project examples here:
That is 100 PS0C 4200 projects; something for everyone.
PSoC It To Ya!
Read about it here: http://www.cypress.com/psoc4/?source=CY-ENG-HOMEPAGE&medium=Body-Products
UPDATE: My view after 90 days...
I am a hobbyist; I am not presently working on any commercial projects. Essentially, I am retired and just playing with the PSoC. I have a couple of years of PIC experience and 3 years of Arduino experience and the following summary must be cast in that light.
After 3 months, I am still impressed with the PSoC 4200. The Cypress Creator 3 programming tool is excellent for a no-cost development environment. However, even after exploring many parts of the environment over the past months, there are still areas in which I have not ventured. The tool is massive and for a hobbyist spending only a few hours a week, it may be too daunting. Unfortunately, I do not know of much that Cypress can trim because a good portion of the tool is required to utilize the PSoC. Also, the tool integration into the back-end store of component PDF files is necessary. Way too much time must be dedicated initially in reading the various PDF files. The sheer volume of documentation is a two-edged sword; the information is available, but the datasheets on the component configurations can be heavy reading. As I stated earlier, this is a professional development environment and the documentation is professional, too.
Note to anyone following my footsteps: spend the $25 and get the PSoC 4200 Pioneer Kit. You cannot use the internal breakpoint debugger on the $4 Prototype boards. I nearly drove myself crazy trying to use the Arduino serial debugging philosophy; it is simply too crude for the PSoC capabilities. The Pioneer evaluation board shines and the integrated debugging capabilities will return your $25 investment many times over. Additionally, and I consider this important, the Pioneer board is jumper selectable between 3.3 Volts and 5.0 Volts. The $4 Prototype board is always 5V when used with USB and can only be 3.3V when used with an external power supply. If you have 3.3V sensors connected to the Prototype board, you MUST disconnect all 3.3V components before using USB to reprogram the PSoC. The Pioneer board jumper settings for V+ is an efficiency tool and may well save a few 3.3V sensors from cremation.
I am not a professional C/C++ programmer although I have attended professional classes back during the days I was working for 'the man'. Using the Arduino, I never had many issues but the SoC is going to drive a stake into your heart. By default, the PSoC is C-code. There are a few internet articles on how to use C++ with the PSoC but this should not be taken to assume that you can use Arduino libraries... you cannot, unless you rewrite them in C or unless you rewrite a significant amount of Arduino code to interface with the PSoC. I found the Internet articles to be of little value. Most of the time, sections of Arduino libraries (Example: Adafruit GPS) can be extracted and used directly in your own C inline or put into a simple function. For the most part, the Types between the two environments translate at the 16-bit level but the ARM has extended Types to manage the 32-bit variables. So, be forewarned that you will spend some time dealing with type casting.
Praise be to the Arduino team for making things easy for novice programmers and hiding complexity. PSoC will hide nothing from you, so be prepared for a shock. Hardware Pins in the Arduino world are all converted for our convenience to aliases such as D1 and A0. PSoC uses route-able physical pin technology where signals are (for the most part) simply assigned to an arbitrary external pin number and then the whole collection is given a cute name (alias) for code use. This is ultimately flexible but does not automatically transcend from project to project. As your knowledge grows with PSoC you will find yourself evolving your usage of external pins. Unfortunately, few of us actually take the time to return to past projects to bring them in-line with our current knowledge level.
Getting a handle on all of the PSoC configurable hardware, such as Universal Digital Blocks (UDB), can be overwhelming. Everything has a separate datasheet but the TRM (Technical Reference Manual) is the king-book. For the PSoC 4200 series, this document is a 16M Byte PDF file... 678 Pages. Many Arduino users have never opened the Atmega328P reference manual but you will open the PSoC TRM.
The single item that impacts programmer productivity (or ability to just complete a project) is the lack of library support from the community. Remember, libraries are C-centric and not C++, so some of the everyday magic used in Arduino does not translate into PSoC. Critical libraries for Nokia GLCD and TFT Color SPI displays exist and Cypress has an embedded software component for 2x16 Hitacahi LCD but I have found nothing as complete as the Adafruit or Henning Karlsen software. With enough research, you can likely find pieces of the puzzle, but you will likely need to work diligently to complete or perfect the code.
In my opinion, the Cypress PSoC 4 users forum is nothing to write home about - I'm not sure it has reached critical mass and should even be called a forum. The active members are few and because of the nature of the PSoC product, most inquiries generally require uploading a complete ZIP of your project for inspection by others. There are no 'code tags' for the forum and the overall feel is "rough' in my opinion: no edit and no delete at present: to Cypress's defense, I have spoken with one of the EVP and have been informed that improvements are forthcoming. Cypress is a professional company and have a staff of engineers that answer questions relating to product; technical or otherwise, but these inquiries are managed through "case numbers" submission. Cypress sell PSoC in huge quantities to large corporations that demand no-nonsense support. This is not a hobbyist market. If you venture into this world, know that there is no hand-holding like the Arduino forum.
So, my overall summary is mixed: fantastic technology, free development tools, reasonably priced development products, reasonably priced IC's. I am delighted that I have spent a few months in this environment and I have created a few projects but I did cheat somewhat and followed work that I had previously done on the Arduino AVR platform. GPS Clock & Calendar, TFT Color Terminal, Nokia B/W SPI Terminal, 6 channel A/D, etc. I used very little of the overall capability of the PSoC 4200 in the area of configurable hardware; for example, I did not use a single OpAmp. But, I have gotten a taste of the hardware resource editor, the schematic project template, the bootloader, the UART, and the UDB. I really like the concept of PSoC and I have assembled enough of the PSoC 4200 prototype boards ($4) to continue to experiment. I have my 4200 Pioneer board for real-time debugging of my C code and examining the internal workings of the PSoC. (I really, really like this board.) I expect to continue my learning, but I am ready to go back to Arduino for my everyday playtime. Remember, I am a hobbyist and I am not working on commercial "stuff", so I can play with the Arduino and accomplish something in a short matter of time. At $3 each, the Atmega328P-PU are affordable and I have a tube of chips here on the workbench for my own designs. I also like to play with the Attiny85 chips. And then there is the 1284P-PU that I also love in my Bobduino board. Oh, that 8-bit vs 32-bit stuff is way overrated: only a few mathematical functions actually benefit from the 32-bit architecture. Mostly, I found myself having to cast variables to uint8_t in the PSoC. The 48MHz clock is very nice, but it takes more manipulation in many cases. When working with GPS or serial at 19200 BAUD, I saw no differences in human perception between the PSoC and the 8-bit 16MHz Arduino. In the case of the GPS, all of the character gathering from the GPS, the string parsing, the display arrangements, the display output were all accomplished and the Arduino was waiting on the next NEMA sentence to come in from the GPS. Hurry-up and wait in the Arduino translated to hurry-up and wait longer in the PSoC.