element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smart Spaces Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Smart Spaces Design Challenge
  • More
  • Cancel
Smart Spaces Design Challenge
Forum Bit of human touch
  • Forum
  • Projects
  • DC
  • Leaderboard
  • Files
  • Members
  • More
  • Cancel
  • New
Join Smart Spaces Design Challenge to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 0 replies
  • Subscribers 39 subscribers
  • Views 43 views
  • Users 0 members are here
  • FRDM MCXN236
  • Smart Spaces Building
  • MCXN236
Related

Bit of human touch

balajivan1995
balajivan1995 3 days ago

In every elevator, there is an option for the user to select which floor they want to travel to. In case of DDS elevators, there will be feedback which immediately shows which elevator was assigned to them. In this blog, we will see how to interface human interaction between our lift model to our microcontroller through the use of HMIs. We will also cover the struggles it took to get the concept working.

Table of Contents

  • Why HMI
  • Struggling with setting up multiple UART
  • Scalability issue
    • Initial idea
    • Daisy chaining
  • Programming the HMIs
    • UI – Dynamic Floor selection
    • UI – Getting user input
    • UI – Feedback response from microcontroller
  • Conclusion

Why HMI

HMI provides a way for humans to provide their input and receive feedback immediately. While I could simplify the process using buttons for inputs and LEDs for feedback, it will include using lots of GPIOs and way too many wirings.

Imagine for a single floor, we need 4 buttons to get user input on floors, 1 RGB led with different light configuration for different statuses. That makes each floor requiring 5 GPIOs. Now, for our lift model, we have 4 floors and that makes 16 buttons to get user input and 4 RGB LEDs. We could reduce the number of GPIOs required by 4*4 matrix keyboard and bit addressable RGB LEDs. That still requires up to 9 GPIOs.

 image

image

Now, HMIs on the other hand, depending on the model can be operated by using just UART alone. That’s just 2 GPIOs for one floor, 8 GPIOs for 4 floors. Since it is a touch supported HMI, we could get user input and provide feedback on display.

For this project we will use a 2.8” touch display from Nextion Brand. It is a resistive touch display and cheaper.

image

Struggling with setting up multiple UART

Initially I wanted to use FRDM MCXA153 to control the HMI but when I tried to enable the second UART, it stopped working. So, I moved to MCXN236 board. Even there I faced similar issues. There is a UART port exposed as a Micro Bus expansion, which didn’t work as well. Luckily MCXN236 has multiple UART ports and one of them is exposed in the LCD header. On configuring that particular port, second UART was up and running.

Scalability issue

Since we have finalized to use 4 HMIs, we need to look for ways to minimize the number of wires. Each HMI comes with 4 pins – Vcc, Gnd, Rx, Tx. Supply and ground wires can be taken parallelly from a power source. But we still need to route 8 wires for UART.

Initial idea

My initial horrible plan was to make use of multiple MCUs each reporting back to MCXN236 board. MCXA153 has one extra UART port, ESP32 has 2 extra UART ports, and with one already working UART from MCXN236 combining all these resources we could wire something like this.,

image

Just looking at the above block diagram made it obvious this is a ridiculous way of connecting multiple HMIs, so I dropped this idea and decided to try an alternative.

Daisy chaining

Daisy chaining is a simple interface method where we connect multiple nodes in a linked list manner. I got this idea from Ethercat communication which uses two ethernet port, one will act as input and other as output.

image

The Ethercat master will send a process image, with request to fill the process image with data from slaves or update the slaves from the process image. By slightly modifying this for UART, we can use Tx as output port and Rx as input port.

image

Programming the HMIs

Nextion provides an application called “Nextion Editor” which can be used to design the UI. It also provides simulation mode to immediately visualize the changes.

Since steps to cover how to program an HMI display out of topic for this post, I will add few links in reference.

image

UI – Dynamic Floor selection

Instead of programming each HMI display with a different identification number, I have decided to create a configuration page where the floor in which display will be placed can be selected.

image

Values start with 0 for button 1, 1 for button 2 and so on. For example, on pressing the number 4, the value “3” will be written to memory ().

wepo 3,10

wepo is the write to EEPROM memory command, 3 is the identification for 4th floor and 10 is the address we are writing to.

On pressing the home icon, the HMI will restart. On initializing, it will read from memory address 10 and store the floor value in a variable for further use.

repo liftID.val,10

repo is the read from EEPROM memory command to read from the memory address 10 and store into variable called “liftID”.

UI – Getting user input

image

The HMI has few a variable initialized to “0xff” value. When user press a button, HMI will update the internal value like this. There is a timer which monitors the variable, once it detects the value is not “0xff”, it transmits the current value to next node and reset back to “0xff”.

Button value = Floor ID * 10 + Selected Floor num.

Example, if a user press button labelled 2 on 2nd floor, it will be saved as 32. The HMI will transmit the value as “but.val=32” which will update the variable of next node, and the process will continue until the message reaches the MCU.

Below is the screen record of the HMI logic in a simulator.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

UI – Feedback response from microcontroller

There are two types of feedback.

  1. Whether the elevator will go up, down, or rejected on pressing the button.
  2. Which elevator to select.

The message format is similar to getting input from user. There will be a commonly named variable which will be updated and passed on until it reaches the correct end node.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

I have created a simple code to check whether the logic works when used with MCXN236. Below are the videos I took when I tried to control only one HMI and with two HMIs. I am glad to find after all these ordeals, I got it working.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Conclusion

To be honest, neither the HMI UI design nor daisy chaining multiple UART is not the difficult part. I have worked with various HMIs, and I could set it up with MCUs from ST or Espressif without much difficulty. What I didn’t expect was how difficult it will be to enable a second UART in MCXN board and make it usable. This is slightly disappointing as I want to use one instance of most of the communication peripheral in that board. Anyways, we will see how to establish communication between MCXA and MCXN board in the upcoming post.

References

1. https://nextion.tech/instruction-set/

2. Nextion Displays - YouTube

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube