Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need ideas and sugestions regarding a HMI implementation.

Status
Not open for further replies.

Sink0

Full Member level 6
Joined
Nov 25, 2009
Messages
390
Helped
37
Reputation
74
Reaction score
30
Trophy points
1,308
Location
Sao Paulo, Brazil
Activity points
4,186
Hi, i am working on a project and i need to implement a simple Human Machine Interface with a simple 4X20 LCD and several switches. The MCU i am working on is a LPC1754 but that information is worthless here. I need sugestions on how to create the structure of my code to be portable, and easy to maintain.

The aproach that i usually do on my projects is to use several standard structures that describes and interface with the real hardware. So the control logic just deals with these structures and if i need to change the MCU, i just have to change the interface files. That works and i use on several projects. A simple example. I got a structure called input_t described as:

Code:
/*********************************************************************
* Callback/Methods Types
*********************************************************************/

typedef void (*in_cb)(void);
typedef volatile U_8 (*in_ret_meth)(void);

/*********************************************************************
* IO Types
*********************************************************************/

typedef gen_pulse_t output_t;

typedef struct{
	in_cb posedge_cb;
	in_cb negedge_cb;
	gen_block_t debounce_desc;
	U_8 prev_state;
	U_8 check_flag;
	in_ret_meth read;
}input_t;

So basically it composed by a few informations used for its processing, function pointers that point to the real hardware interface (just the "read" fuction pointer here) and a few callback functions.

I got another higher level function that receives a pointer to an input_t and process it, calling the posedge_cb when it identifies a positive edge and calls negedge_cb when it identifies a negative edge.

On every situation the function also handles the debounce calling a system function using the debounce_desc structure, but that is meanless here.

It work great and i have used several times.

Now, all my program uses the same structure, incluiding UARTs, I2Cs, LCD, and so on. And that got several layers. I got a GPS structure, that got a pointer to a uart, and all the logic functions that handle the GPS protocol makes uses of the uart structure. On the top of everyhing threre is a structure called system_t that got a pointer for all its peripherals.

My problem is on the implementation of a HMI. I was planning on creating an independent structure for the HMI with its swicthes and the LCD. So for every different menu i will create a lcd refresh callback, and a callback for the switches.

The problem is that in theory, the system structure is at a higher layer, so the HMI structure is not suposed to make use of it. However, the system behavior is suposed to react according to the HMI state. So basically the switches callbacks will have impact on either systems states and the HMI states. So in theory i would have to create all the callbacks on the system layer, but thats looks very ugly.

Do you guys have any sugestions on how should i implement the HMI structure inside the system? How you guys usually implement that on your projects?

Thank you!

Let me know if i was too confusing.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top