Sunday, February 21, 2016

Nextion HMI Display - A User Interface that is Simple and Easy to Use

Welcome-to-Nextion.jpg

With the complexity and sophistication of embedded systems today, a necessary component is a user interface that is more than an indicator LED. Today it is expected that the user will be updated with relevant and timely information in an aesthetically pleasing manner. While I have yet to meet an embedded developer who enjoys GUI design and programing there are some easy and some not so easy methods to accomplish this.

Just recently I was placed with the task of creating a controller with a touch display. The development software has over 1000 pages of “help files” and little to no worked demos. The first task was to try to use buttons to increase and decrease a displayed number and then load that to the control unit. After a large undisclosed number of hours neither have yet to be successfully accomplished. The support consisted of being sent completed projects to examine and run in simulation, sadly this did not help.

IMG_20160208_152054.jpg
Support documentation for a Control Display

Interestingly towards the end of my time evaluating this unit I was asked by ITead Studio if I could review their Nextion display. After reading all the demos and working through them (~20 pages plus ~20 pages for the Nextion instruction set), which are easy and intuitive, I thought I’d give my task a try. Yes there is a demo that is very similar, but with in 10 minutes I had the demo running on the Nextion. I will say the demo may not have looked all that pretty but with another 20 - 30 minutes that could have been rectified.

IMG_20160208_152645.jpgIMG_20160208_152721.jpg
Demo increasing both numbers and text values with input buttons

Out of the Box
The displays ship in a neatly packed box that fits the displays quite snuggly. The kit includes the display (3.5” in this case) and a power connector. The connector allows the display to be easily powered from any USB power source.

IMG_20160208_152432.jpg
IMG_20160208_152408.jpg
Nextion package and the contents. Screen, wire harness, and USB power connecor

When the unit is powered up for the first time there is a clean and neat welcome screen that displays the ITead name and logo as well as 6 demos. Going through the demos is not too impressive as they show the functions available in a very simplified form, that is except for the last one. The last demo allows an evaluator to see that the display is not merely a touch screen but can also run intelligent code.

The demo is to find 5 differences between the two pictures and shows three hearts as a player's lives, when a wrong area is selected these hearts go dark one at a time. While this may seem trivial, it clearly shows that the display has some computational abilities.

The User Interface
The GUI design and layout is done in a development environment (IDE) provided by ITead Studio. The Nextion IDE downloads with no issues from ITead Studio’s Nextion portal and is simple to install. Once installed opening the IDE presents the user with a clean and well organized user interface. The IDE is organized into 8 sections as shown in the image below, each section has a unique task to perform or information to convey.

800px-Nextion_Guide_1.jpg
Nextion IDE to design and program the user interface

The 8 sections functions are as such.
1) Menus including save, open, etc. are found here.

2) Image library, images used on the Nextion display need to be uploaded before hand. In order to do this all images first need to be imported to the IDE, the IDE then gives each image a unique number by which that image is referenced. It is then from this section that images and backgrounds can be selected and positioned in your GUI.

3) Font library, text entered in the GUI needs to be setup to be correctly displayed on the display. To do this fonts are created in specific sizes and styles and then configured for the specific display. After completing the configuration the font can be added to the font list.

4) Working area, this is where the graphical display is designed and shown. It is in this area a scale representation of the display is shown as a canvas on which to work. All desired components are added and arranged with in this area to represent how the final display should look.

5) Page area, display screens are called pages. New pages are added and named here. It is with the names listed in this panel that different screens are selected by either internally written code or by a connected microcontroller.

6) Attributes, component attributes such as, display text, value, color, background, are set in this window.

7) Compiler Output Window: if errors occur, they will be shown in this area.

8) Event area, code to control how the display behaves is added here allowing for simple display control to be achieved without the need of an external microcontroller.

Getting Started
ITead Studio have wisely provided a number of demos with explanations to get any user up and running in a short period of time. The user guide lists 7 examples that start with simple text and button components and ends with simulating a slide unlock and a battery charging symbol.

In each example the components used are well explained. The demos follow a simple and easy progression making them easy to follow and understand. The demos can easily be completed in a few minutes including understanding what each demo is trying to convey. One difficulty is some of the english. Because the sentence structure does not always flow as it should, one may need to take a second glance, but the intent is clearly understood. One other issue is the difficulty in finding the resources used in the demos. Pictures and fonts listed are not easily available. The only remedy for this is to download the completed demo, then remove all components and images from the working area. While this works to complete the demo it lacks the hands on feel for setting up the fonts and importing needed images.

Programing (Internal Code vs MCU Controlled)
Once all the demos have been completed the next step is creating your own GUIs. These GUIs can be self contained or they can interact with a connected MCU. The demo mentioned at the beginning of this blog is a self contained program. The demo was put together to explain what an easy to use display is. In that demo there was 6 lines of code. Four of the lines were the same and the other two only differed by a sign.

The first line is “page0.z0.val=page0.z0.val+1”. Page0 refers to the screen number the component is part of. z0 is the name of the component, in this example instead of using a variable a gauge was used to keep the demo simple. val is the value of the specific component, in this case the gauge counts between 0 and 360, if a variable was used this could be set to have different limits. By adding this one line of code the value of the gauge is incremented by clicking on a button without the need for a microcontroller.

The second line is “n0.val=z0.val”. This time the page was omitted to demonstrate that when referencing the same page, the page identifier can be omitted. This simple line updates the number displayed in the number displayed on the screen.

The last line of code is “cov z0.val, t0.txt, 0”. This takes in a value “z0.val” and converts it to a second type (string in this case) and sends it to the required parameter, “t0.txt”. This takes the value from the gauge and displays it in a text box.

The beauty about this is the same code can be easily switched to run on a microcontroller of your choosing. By attaching the UART lines to your microcontroller the same commands can be sent  to the display to achieve the same results. The Nexion sends hex commands to the microcontroller in a very predictable and easy to parse format. While a conversion from hex to the desired result (integer, text, etc) is required this would not be too complicated for most programmers.

Arduino Library
On the topic of parsing and programing a parser, this is not necessary if an arduino or arduino like device is being used (eg. Energia). This is because ITead Studio has taken the time to write a comprehensive Arduino library for the Nextion. This allows new makers as well as those trying to get a quick project out the door to complete their project that much faster.

Uploading Program to Nextion
One of the really nice features about the Nextion is the ease with which a new program can be installed. Open the IDE and click on File > Open Build Folder and select the .tft you would like to run on the display. Once this file has been copied to the microSD of your choice, insert the microSD into the Nextion’s microSD card slot and power on the Nextion.

The Nextion will go into a bootloader mode and will display the file size and the progress. This takes a few moments, once completed a message “Update Successful!” will be displayed on the display. Power down the display, remove the microSD card and power up the display again. This time the GUI you have selected will be running on the display.

IMG_20160208_152817.jpg
The size of the image to be uploaded along with the progress is then displayed.
IMG_20160208_152833.jpg
GUI successfully uploaded to the Nextion display

There is a second option to upload the program to the display, this time directly from your PC, for this a USB to serial converter is needed. While ITead Studio recommends using their Foca it appears that any converter would work. A benefit of using the serial connection is the IDE allows for debugging through this connection. In the bottom window of the simulation screen there is the option to have your MCU respond to the simulation running on the PC removing the need to use a logic analyzer to debug a project. An added benefit of using the simulation is all hex sent from the simulation to the MCU is translated making understanding the control flow significantly simpler.

2016-02-08 16_48_05-Nextion Editor.png
Debugging interface allowing the simulation to interact with an attached MCU or with user input commands

Pros and Cons
The Nextion is a very nice and easy to use product but every product has its pros and cons. With the previously mentioned IDE getting a GUI up and running is a simple task that can produce some really polished results. That being said there are some drawbacks to the IDE.

20150420235504-nextion43.jpg
Professional looking display (Credit: )

Firstly and most importantly is the error checking. I have compiled a number of projects that have an output stating 0 Errors and 0 Warnings, yet when I go to run the program errors are found. Invalid conversions or just plain incorrect code, while this may seem trivial, having to run through all the options in a program can take unnecessary time. When all that is needed is a simple user interface that will behave as expected, such issues can be a significant drawback.

Another issue that was a constant issue was meta data. Once a project is opened the name of the project is not displayed anywhere. If someone has multiple project that are of similar nature, maybe just the screen size is different, it is not possible to know what file they are in. Another subtle issue is the difficulty in finding the screen size. While the screen size one is working on should be readily available and displayed somewhere obvious, it is not. On needs to click on setting and there they will find the screen resolution. On the positive side, if you want to change the screen size this can be done even after everything has been setup. It should be noted that the images and components will not scale if this is done.

During the process of designing my simple GUI I was unable to have a number or text display in the fields I had set up. While this was frustrating
I thought there was a bug, but it turned out not to be the case. The font size chosen was to big for the display boxes and so nothing was displayed. An error message or warning would have been preferred as it would have saved a good deal of time.

Moving Forward
I had plans to use the display screen in an ongoing project to wind coils as well as a short project to measure force. The first was going to be an interface to allow for the desired number of rotations to be entered and then to display the ongoing progress. The later was going to be used to display the max applied force and graph the force over time. Unfortunately after updating the display to get back to the out of the box demo, the screen appears to have died. ITead Studio does have a recommended fix which unfortunately has not worked. I have created a ticket and will update as I get more information.

Update: ITead has responded that an attempt with a different microSD card or with the use of a USB to serial converter may remedy the issue. As I had already used a different microSD card with no luck I decided to try the USB to serial converter. I only have cheap eBay USB to serial converters and that is what I figure most hobbyists would use I thought I’d give that a go. The IDE easily found the COM port and connected and with no issues the Nextion was back up and running.

Conclusion
In conclusion ITead Studio have put a good deal thought into the Nextion and the associated IDE. The ease with which anyone can build a simple yet elegant GUI is at a new high. The connections kept simple with only providing UART and power to the user. The commands to control the Nextion are also simple and can easily be parsed should an Arduino like device not be used. The ability to have the display do most of the onboard control or even be self contained is both handy and useful in relieving a connected microcontroller from needing to constantly tend to the display.

The Nextion is a display I would recommend for the home user or DIYer. I have seen a lot of projects on line now that use this display with no reports of issues.My reported issue may be one in a large number, but until the issue is understood and resolved I would feel slightly uneasy installing it in a consumer product.

That being said, I have been asked to do some further testing on the Nextion to potentially replace the controller mentioned at the beginning of this blog. Depending on how those tests go I may change my opinion on the reliability of the display and its updatability.

Wednesday, January 13, 2016

Texas Instruments Educational Boosterpack II - Review

23331_LaunchPad_Booster_MKII.JPG

I would like to thank Element14 and Texas Instruments for giving me the opportunity to review the new MSP432P401R and the Educational BoosterPack MKII. Seeing a new low power device from Texas Instruments excited me as the MSP430 is a proprietary core that for some reason some people turn away from. I was looking to compare the support and easy of use to that of previous TI launchpads I have used in the past. Also the MKII brings a whole new offering in the launchpad space allowing those wanting to learn embedded software a single test bed to experiment with so many different sensors and protocols.

Introduction
The new MSP432 uses an ARM Cortex M4F core which opens Texas Instruments up to compete with all the latest innovations by other manufacturers in this space. While Texas Instruments has had the MSP430 in the low energy space for a long time, it is a proprietary core and this has caused some potential users to skip over it. The choice of a M4F core gives the user a lot of options while still, hopefully, keeping power consumption to a minimum.

When I applied for this road test I was really excited as I am an avid user and promoter of Texas Instruments products for various reasons. Firstly, the launchpads I have used in the past have all been very well supported with demo code that is well commented and easy to manipulate. This allows for a project to be easily and quickly started by simply joining a few projects together to get the skeleton of the project completed before adding any task specific code. The second reason I enjoy Texas Instruments products is their documentation. I have not found another manufacturer with such well and clearly written documentation.

MSP432P401R

When I applied for the road test I was interested in the MSP432P401R for a few reasons. The first reason was the ARM core. With the basis of the core being an ARM Cortex M4F this was something new and something that if it could be as low energy as Texas Instruments wanted us to believe it to be would be an interesting and very useful controller. The second reason I was interested in this launchpad was the EnergyTrace technology. Having seen the same idea first from Energy Micro with their Geko Boards a few years ago (now bought out by Silicon Labs), I was wondering how Texas Instruments implemented this functionality. Lastly I was wondering how well the MSP432P401R was supported by both Code Composer Studio as well as Energia. Included in this was how well third party applications such as Temboo and 2lemetry could be integrated with the MSP432P401R through either Code Composer Studio or Energia.

MSP432P401R Board Layout and Specs
As with all previous Launchpads the the MSP432 comes with an onboard programmer and debugger. The open source XDS-110-ET is included on the top of the board in away that should it be desired it can be fully isolated from the target controller. The extent of isolation can be selected using jumpers between the two blocks, a user could select from 5V, 3.3V, UART jumpers when isolating the two sections. There is also the possibility to use an external programmer via a JTAG connector. Along with the built in programmer is a backchannel that allows for serial data to be transmitted back to a PC without the need for a UART - USB adapter.

2016-01-12 15_47_17-www.ti.com_lit_ug_slau597a_slau597a.pdf.png
Figure 1. MSP432 launchpad overview

2016-01-12 15_48_14-www.ti.com_lit_ug_slau597a_slau597a.pdf.png2016-01-12 15_47_44-www.ti.com_lit_ug_slau597a_slau597a.pdf.png
Figure 2. MSP432 launchpad layout and isolation

In terms of user interfaces, the MSP432 has two user input buttons and two LEDs. On this launchpad LED2 is a RGB LED allowing for a full array of colors to be output via a PWM signal. Along with these interfaces are the two 20 pin header pins that allow this launchpad to interface with any of the many boosterpacks created for the launchpad ecosystem. It should be noted that the pin assignments follow the launchpad pin assignment standard. In addition to the these 40 pins there are an additional 30 pins broken out but without headers at the bottom of the board should some functionality be needed for a project.

2016-01-12 16_21_19-www.ti.com_lit_ml_slau596_slau596.pdf.png
Figure 3. MSP432 launchpad pin configurations

Educational BoosterPack MKII
I was also interested to see the Educational Boosterpack as it incorporated a lot of interesting inputs and outputs (display, servo control, buzzer, sensors, etc.). This is useful for someone looking to start learning embedded programing as there are numerous devices to play with without needing to wire anything extra to the launchpad. With the layout of the board and the incorporation of the sensors, this boosterpack seems to have a large advantage over a lot of the other boosterpacks mainly because of it’s large array of possibilities.

In order to help a novice as well as an experienced programer, everything is meticulously labeled, part name and header assignment, on the devices (RGB LED; blu: J4.37, grn: J4.38, red: J4.39, Buzzer; J4.40  , Gator hole; J4:34, Servo; J2.19,  etc). This makes matching a device to a pin a lot easier as well as allowing for stand alone use through jumper wires as it is clear now where to connect a jumper to access a particular device without referencing the schematics.

Educational BoosterPack MKII Specs
The MKII follows the standard boosterpack pin assignments allowing for the MKII to be used in a stack with other boosterpacks. Interestingly enough the MKII incorporates stacking pins on top which if used would block the screen as well as could only be used by a board that could accommodate the joystick.

On the MKII there is a large bag of goodies to play with. Starting with the inputs, the most noticeable thing about the MKII is the joystick and how it helps give the whole board a game console fee and lookl. The joystick is a two axis and one push button joystick. The inputs on the two axis are both analog and the pushbutton is digital. Along with the joystick giving the console feeling are the two pushbuttons, these are simply two standard press to connect push buttons.

Next we have some interesting sensors. Instead of including a standard contact temperature sensor, Texas Instruments and Circuitco have chosen to use a infrared sensor instead. This allows for a larger array of uses as well as opening the door for more learning opportunities in a real educational setting. Also included is a light sensor that again is a non-contact sensor. Measuring values without coming into contact with what you are measuring is always a peculiar thing, and for those in an educational setting this can be used to introduce other related topics. Lastly in the sensor package, there is a 3-axis analog accelerometer. The interesting thing about including such a sensor is that again it incorporates multiple learning aspects. There is obviously the acceleration aspect, measuring how the device accelerates is interesting but then to do so using analog signals incorporates the fact that the world is analog while microcontrollers are not.

Lastly there is also a microphone for sound input and gator connectors that can presumably used for any type of input. While this last one may not be high on my list of interesting inputs/outputs I’m sure there will be someone who will find a very interesting and unusual use for this connection point.

The outputs, while there are fewer of them,  are just as interesting as the inputs. As a basic indicator, there is a RGB LED. This is great for basic debugging as well as displaying a vast array of colors using both PWM and on/off control. For a more complex visual output , there is the 128x128 color TFT display that uses SPI. While I have not been able to get this to do anything outside of the demo code provided, this opens up a lot of interesting options. It should also be noted that the control line for the backlight and the red LED share the same pin through a jumper and as such only one can be used at a time. On the sound side there is a buzzer, while one user has noted that it would be nice to disconnect the buzzer from the available PWM pins through a jumper, this is not possible and therefore one PWM pin is used up by the buzzer unless desoldered from the board. Lastly is a servo output, this is nice as it would allow input from an accelerometer to influence a mechanical output. While Texas Instruments has clearly labeled the three lines to the servo (GND, POWER, SIGNAL) it should be noted not all servos follow this arrangement on their connectors.

2016-01-12 15_40_43-www.ti.com_lit_ug_slau599_slau599.pdf.png
Figure 4. MKII boosterpack overview

Unboxing
The unboxing of the kit was a mixed bag of tricks. The MSP432 was packed in the new standard launchpad box. The launchpad was in an anti-static as would be expected and under a side flap in the box was the needed USB cable. On top of everything in the box was the quickstart guide along with the regulatory approvals.

IMG_1652.JPG
Figure 5. Unopened boxes of both the MKII and the MSP432

IMG_1659.JPGIMG_1658.JPG
Figure 6. Unboxing the MKII and the MSP432

The Educational BoosterPack MKII was packed in a non-standard box. The large white box reminded me of a previous road tested from Texas Instruments that was also a new product (TI C2000 InstaSPIN™-FOC LaunchPad w/ Motor Driver). At this point I was concerned as I was remembering the issues I and others had in getting the C2000 to do anything other than flash a LED or run the quickstart demo.

Getting Started
After the package arrived I was eager to get started. Opening the boxes and mounting the Educational BoosterPack MKII to the MSP432P401R was easily accomplished due to the 40 pin headers that easily allow for boosterpacks to connect to most of the launchpads in the launchpad family.

Opening Code Composer Studio (CCS) was the next step, as I use CCS for all my work with Texas Instruments controllers. I then attempted to import a project for the MSP432 but to my dismay there was an issue. I was unable to import the project due to an issue that I am no longer able to replicate (CCS has been updated and the issue apparently fixed). This issue persisted until I was able to revert back to a previous version of CCS.

Once this issue was resolved the next step was to run some demo code. Texas instruments provides a good deal of demo projects for this setup (MSP432 + Educational Boosterpack), there are at least 5 projects to get started with, each focusing on a different input/output on the boosterpack. When attempting to compile and run these projects a new error would pop up.

“Message: CORTEX_M4_0: Error connecting to the target: (Error -1063 @ 0x0) Device ID is not recognized or is not supported by driver. Confirm device and debug probe configuration is correct, or update device driver. (Emulation package 6.0.14.5)”

Once this had happened the MSP432 would no longer respond and I had assumed I had bricked the launchpad, thankfully I was not the only one with this issue. After following some simple steps the MSP432 was back up and running but I was still not able to run the joystick or accelerometer projects without this issue reoccurring.

By this point I had spent a good deal of time attempting to get the kit working with CCS and was not having much success. While I did want to try out EnergyTrace as well as third party applications I was hitting a wall to often and was feeling it was time to wait for Texas Instruments to fix CCS before reattempting my tests.

Energia
After having no luck with CCS I decided to give Energia a try. Since Energia is supposed to be an Arduino type user experience, that is easy to get started with little to no background in programming when you start I thought this was the place to go. Sadly this too was to not be, there appeared to be an issue with the screen driver to which a solution was posted, but I was unable to get this to work. Besides this issue there were issues with compilation of other sketches as well as issues programing the MSP432 though Energia. This last issue is an incompatibility with the firmware on the XDS 110-ET on board programer.

Next Steps
Moving forward with board and boosterpack will be a slow process, with no clearly defined projects (although an IoT type project may be in need for a cold room environment monitoring) there is nothing pushing to make the board work before Texas Instruments fixes the issues with both CCS and Energia.

Hopefully the fixes will come soon and at that point I will get a chance to try the MSP432 with EnergyTrace to see how it compares with what Energy Micro had done a good few years back. I would also like to eventuly see how easy it is to use this board with an online graphing site such as Xlivley.com, plot.ly or 2elemetry.com. As for the educational boosterpack, if I could get something working with the joystick and buttons I have someone who would really like to play with that.

Conclusion
At this point in the the product life I would be hesitant to go out and get this board just for the fun of it. If someone had a project in mind and this fitted there needs then I’m sure the demo code for the MSP432 would serve just fine. That being said with the speed Texas Instruments appears to be fixing the mentioned issues I do not believe it will be long before this will be a really good board to get started with ARM Cortex controllers.

With respect to the boosterpack the demo code is also getting patched at a reasonable pace. It can be seen that Texas Instruments is actively working to ensure these issues are resolved quickly. With respect to the hardware, this is a very well thought out board. It has a great mix of inputs and outputs as well as different protocols. In an educational setting I would find this to be a very valuable yet cost effective tool for teaching the basics of electrical projects.

Overall while I have had frustrations with these boards I am happy in that I know they will be useful and soon the demo projects and surrounding issues will be fixed usable and I will be working on my next project with yet another Texas Instruments launchpad.

Links that Solved Issues

LaunchPad MSP-EXP432P401R – Beginning


How to unbrick a MSP-EXP432P401R

CORTEX_M4_0: Error connecting to the target: (Error -1063 @ 0x0) Device ID is not recognized or is not supported by driver. Confirm device and debug probe configuration is correct, or update device driver. (Emulation package 6.0.14.5)


CORTEX_M4_0: Error connecting to the target: (Error -1063 @ 0x0) Device ID is not recognized or is not supported by driver.


MSP432 LaunchPad: Error connecting to the target since upgrading CCS 6.1


MSP432 LP, and the EPB MK II examples for Energia?


When I Import MSP-EXP432P401R_Software_Examples' sources toCSSv6.1 , it can't be build successfully.


6.1.1 Debug Error using MSP432P401R Launchpad


msp432 problem with XDS110 and firmware version 2.2.4.2




Original post on Element14 can be found here