introduce
本文重点介绍利用微软® .NET微架构来设计家用医疗器械,并介绍如何按照客户需求设计终端产品的观感。这可以通过设计吸引人的图形接口,集成各种通信接口(串口、I2C、SPI、以太网、USB、WiFi等)以及利用i.MX微处理器的优异性能来实现。其结果可能是一个高端的监测解决方案,例如血糖计,或其他一些满足特定客户需求的健康及安全设备。这些应用在价格、功能、易用性、外观及感受上有着显著区别。
As chronic diseases such as diabetes affect younger people, physicians face greater challenges in getting patients to collaborate in data collection (disease monitoring) to better manage their disease. For example, adolescents with diabetes often turn off the alarms on their glucose monitoring systems to monitor blood sugar, which can result in prolonged disruptions in glycemic control (see Table 1). However, monitoring systems that integrate multimedia capabilities may make it easier for patients to accept and better use the device, including responding to alarms.
Table 1: Glycemic control targets
from the American Diabetes Association (ADA), the American Association of Clinical Endocrinologists
(ACCE), and the International Diabetes Federation (IDF)
Personal medical devices can be used for general health and fitness applications in addition to chronic diseases. Highly intelligent design integrating advanced software and hardware is the key to successfully creating future health and safety applications. These applications will be used by millions of people. This article introduces a method to develop small and low-cost solutions using .NET Micro Framework and i.MX microprocessor family.
Table 2: High, low and normal blood sugar levels monitored by the CGMS
(CGMS monitoring of 17 children and adolescents with type 1 diabetes)
i.MX Application Processors and .NET Microframework
Freescale's i.MX series application processors are based on ARM® core technology and are optimized for multimedia applications. .NET Micro Framework can be ported to these processors to apply the various functions brought by these software.
.NET Micro Framework is the most compact system framework in the .NET framework provided by Microsoft, and can be configured to the smallest memory space (64KB memory, 256KB flash memory). This framework is optimized for embedded devices and fully provides the most commonly used embedded development tasks, while cutting out some unnecessary tasks in the .NET full framework. It allows developers to use communication interfaces (Ethernet, WiFi, USB, serial ports, SPI, I2C), LCD (displayed directly on the display or through video components), touch screens, and storage (flash memory, internal memory, SD/MMC memory cards). Due to its structural limitations, the .NET Micro Framework is limited to running one application, but it can support multi-tasking. The library of the .NET framework has the most commonly used objects and functions, and using them requires a license from Microsoft.
Freescale's i.MXS application processor can be used for .NET micro-framework applications. The processor features include:
• ARM920T® core, 100MHz
• Color LCD Controller
• Direct Memory Access Controller DMAC
• External Interface EIM
• SDRAM controller
• Multiple peripheral interfaces (SPI, USB and UART)
• Low power modes allow systems to gain additional performance while reducing cost and power budgets
Porting the .NET Micro Framework allows users to use Microsoft's Visual C# to develop embedded applications, giving high-end programmers an advantage when developing embedded applications.
The toolkit for developing i.MXS embedded health and safety applications using .NET Micro Framework includes:
• Microsoft Visual Studio 2008
• Microsoft Visual C#
• .NET Micro-framework
• USB data cable
• i.MXS development board
For more information about .NET Micro Framework, visit www.microsoft.com/netmf .
Design Tips and Considerations
Below are some tips and considerations when designing graphical user interfaces (GUIs) and data monitoring functions. Developers with C# programming experience can configure the hardware for specific health and safety embedded application requirements.
General Purpose Input Output (GPIO)
Almost all health and safety devices use GPIO to configure LEDs (to show some specific device status), special buttons (reset, test mode and calibration), and signals (extra interrupts to detect accurate sensor reading operations). Depending on the application requirements, .NET Micro Framework can configure GPIO in three ways:
1. As an input pin
InputPort inputPin = new InputPort(Pins.GPIO_PORT_C_5, true, Port.ResistorMode.PullUp);
if (inputPin.Read()) runInputAction();
2. As an interrupt pin
InterruptPort interruptPin = new
InterruptPort(Pins.GPIO_PORT_C_6, true, Port.
ResistorMode.PullUp, Port.InterruptMode.
InterruptEdgeHigh);
interruptPin.OnInterrupt += new GPIOInterruptEvent
Handle(inputPinInterrupt_onInterrupt);
3. As output pin
OutputPort outputPin = new OutputPort(Pins.GPIO_
PORT_C_7, true);
outputPin.Write(true);
Configure the thread as follows:
Thread t1 = new Thread(new ThreadStart(thread1));
t1.Priority = ThreadPriority.Highest;
t1.Start();
Saving data in memory
Another common task in embedded development is to save data in flash memory. Data is saved in many different types of medical devices such as blood pressure monitors and blood glucose meters. Using .NET Micro Framework to store data in flash memory requires the following steps:
1. Create a serializable class
[Serializable]
public class Device
{
private String name;
private byte value;
public String Name
{
set { name = value; }
get { return name; }
}
public byte Value
{
set { value = value; }
get { return value; }
}
public Device(byte Value, String Name)
{
value = Value; name = Name;
}
}
2. Create a sequence log
[Serializable]
class DeviceLog
{
private ArrayList log = new ArrayList();
public ArrayList Log
{
get { return log; }
}
public void AddToLog(Device device)
{
log.Insert(0, device);
}
public void RemoveFromLog(Device device)
{
log.Remove(device);
}
public void ClearLog()
{
log.Clear();
}
}
3. Create and use a flash reference
ExtendedWeakReference flashReference;
uint id = 0;
public Object load()
{
flashReference = ExtendedWeakReference.
RecoverOrCreate(
typeof(Program), //
marker class
id,
// id number in the marker class
ExtendedWeakReference.c_
SurvivePowerdown);// flags
flashReference.Priority = (Int32)
ExtendedWeakReference.PriorityLevel.Important;
Object data = flashReference.Target; //
recovering data
return data;
}
public void save(Object data)
{
flashReference.Target = data;
}
Graphical User Interface GUI
.NET Microarchitecture can also help programmers develop more attractive interfaces, thereby providing unique choices for end customers and influencing developers' decisions on chip suppliers.
The .NET microframework running on the i.MXS processor provides two ways to develop user interfaces: one is to use the user interface elements provided by .NET, and the other is to use the bitmap class to refresh the screen directly.
Table 3: User interface elements provided by .NET Micro-Framework
All the elements listed in the table can be programmed in a similar way, the procedure is as follows:
// Create a panel
StackPanel _panel = new StackPanel();
_panel.Height = _mainWindow.ActualHeight;
_panel.Width= _mainWindow.ActualWidth;
// Create and configure user interface elements
Text textTitle = new Text();
textTitle.Font = Resources.GetFont(Resources.
FontResources.small);
textTitle.TextContent = “Title Text”;
textTitle.HorizontalAlignment = Microsoft.SPOT.
Presentation.HorizontalAlignment.Center;
textTitle.ForeColor = (Microsoft.SPOT.Presentation.
Media.Color)0xFF0000;
// Add the user interface elements to the panel
_panel.Children.Add(textTitle);
The above code first creates a panel object, defines its size, then creates a text object and defines the font, size and color properties. Then the text object is added to the panel subclass stack.
Once a user interface element is added to the display panel, the only way to update the element's content is to update it asynchronously, as shown below:
delegate void UpdateTitleTextDelegate(String hint);
private void UpdateTitleText(String text)
{
if (textTitle != null) textTitle.TextContent =
text;
}
// When the update of the textTitle is required,
use the following code
_mainWindow.Dispatcher.Invoke(
new TimeSpan(0, 0, 1),
new UpdateTitleTextDelegate(UpdateTitleText),
new object[] { “New Title Text” });
When using a bitmap to update the screen, the coordinates of the items and the screen refresh are not automatic. Developers need to use code functions, state variables, timers, and threads to perform target positioning and screen refresh. Here is a simple example:
Bitmap _back = new Bitmap(240, 320); // bitmap
used for flush
Bitmap _screen = new Bitmap(240, 320); // based
bitmap to be updated
Font font = Resources.GetFont(Resources.
FontResources.small);
_back.DrawImage(35, 10, Resources.
GetBitmap(Resources.BitmapResources.freescale), 0,
0, 170, 57);
_back.DrawRectangle(Color.White, 1, 35, 10, 170,
57, 2, 2, Color.White, 0, 0, Color.White, 240,
320, 0);
_screen.DrawImage(0, 0, _back, 0, 0, 240, 320);
_screen.DrawTextInRect(“State: Background”, 10,
300, 220, 20, Bitmap.DT_AlignmentCenter |
Bitmap.DT_TrimmingCharacterEllipsis,
(Color)0xFFFFFF, font);
_screen.Flush();
Charts provide a way to examine historical data and perform analysis. Personal health and safety equipment is often displayed using graphs, such as bar charts and dot charts, to compare multiple variables in a unified format. Two methods of graph processing are described below.
The first is to use the image element in the user interface element. Developers can control the displayed information at the pixel level through the properties of the bitmap.
Figure 1
Table 4: The following bitmap class methods can be used to manipulate pixels in an image.
The second method uses the canvas element in the user interface element. Developers can manipulate the coordinates and display the user interface element in the specified area, as shown in the following example:
Canvas _canvas = new Canvas();
_canvas.Height = SystemMetrics.ScreenHeight;
_canvas.Width = SystemMetrics.ScreenWidth;
Shape shape = new Rectangle();
// Getting random numbers for width and height,
fixing the max number to the canvas size
shape.Width = Math.Random(_canvas.Width);
shape.Height = Math.Random(_canvas.Height);
shape.Stroke = new Pen(color);
shape.Fill = new SolidColorBrush(color);
// Setting the location in the canvas for the
element, these functions are static
Canvas.SetTop(shape, Math.Random(_canvas.Height -
shape.Height));
Canvas.SetLeft(shape, Math.Random(_canvas.Width -
shape.Width));
// Adding the shape to the canvas
_canvas.Children.Add(shape);
In the code above, we create a canvas object and define its width and height, then create a rectangle object and define its type, fill color, and material. Finally, we define the coordinates of the rectangle object in the canvas and add it to the canvas. Creating graphics is easier than ever before, and this is all based on the i.MXS microprocessor that supports .NET Micro Framework user interface elements.
Communication interface
Serial communication is the primary communication method in all health and safety applications. It is used to transfer data from the device to a personal computer for analysis by doctors and patients.
Common means of sending data to the PC using interfaces such as UART, SPI, I2C, USB, Ethernet, and Wi-Fi. In the following example, the code uses UART for communication:
SerialPort serialPort;
// The configuration is through the SerialPort.
Configuration class
SerialPort.Configuration serialConfig=new
SerialPort.Configuration(SerialPort.Serial.COM1,
SerialPort.BaudRate.Baud115200, false);
serialPort = new SerialPort(serialConfig);
// The read is through the Read function that
returns the number of bytes read numberOfBytesRead
= serialPort.Read(strBuffer, 0, READ_NUMOFCHARS,
READ_TIMEOUT);
// The write is through the Write function
serialPort.Write(strBuffer, 0, strBuffer.Length);
Unfortunately, the serial port does not use interrupts to alert the application layer that data has been received or that the serial port is ready to send data. The common way to check the number of bytes received is to monitor the return value of Read. However, the .NET micro-framework allows developers to use threads and events to build a more complete class, in which a thread with an infinite loop can be used to check the number of bytes received.
Figure 2 is an example of a healthcare system block diagram based on an i.MXS applications processor.
Figure 2. Block diagram of a healthcare system based on an i.MXS application processor.
in conclusion
i.MXS processors and .NET microframework are optimized for clocks, watches, remote controls, blood glucose meters, cholesterol meters and other applications. Using i.MXS processors and .NET microframework, developers can quickly design visually attractive user interfaces without having to be microprocessor experts. Advanced C# programming allows programmers to develop high-end programs in a similar way to PC programming.
Together, Microsoft and Freescale are enabling designers to bring compelling applications - that look and feel good and provide added value to the end user - to market quickly. More importantly, continuous disease monitoring can reduce pain and infection, thereby helping to improve medical response times.
Previous article:Development of a handheld thermal barcode printer based on LPC2148
Next article:A remote medical monitoring system based on wireless sensor networks
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【GD32450I-EVAL】Timer test ADC speed
- Common Operations of CCS Editor
- The influence of power supply on the spectrum of amplifier
- I have 4 24*18 P2.5 full-color LED dot matrix boards. Let's see what can be done? How to drive them?
- Will high voltage pulses and surges have energy and attenuation after passing through this reverse-connected diode?
- I would like to ask about the problem of low voltage detection.
- [MPS Mall Big Offer Experience Season] Unboxing
- Pingtouge RVB2601 Review: Connecting to Alibaba Cloud IoT Platform
- MSP430F5529 IO port pin interrupt study notes
- Circuit-level electrostatic protection design techniques and ESD protection methods