Hello Waijung (Part I : Hardware Setup)

Hello Waijung

This is the first article in our Hello Waijung series.

Part I: Hardware Setup

Waijung (means “so fast” in Thai), developed by Aimagin, is a software product to be used with MATLAB/SIMULINK and some supported processor board such as STM32F4DISCOVERY from STMicroelectronics. This software, available for free download from Aimagin website, is particularly useful for control system design and simulation. It supports modern design approaches using MATLAB powerful computing engine and user-friendliness of SIMULINK. Rapid prototyping and hardware-in-the-loop simulation are among the techniques already familiar to experienced MATLAB users. Nevertheless, the necessary hardware and software setups are not so trivial to a novice. The purpose of this article series is to help introduce the audience to this development tool.

Even though one of my research areas is in control engineering, I cannot call myself a MATLAB/SIMULINK expert, and this line of Aimagin products is new to me as well. Actually, I am among those who heard about Waijung, bought the STM32F4DISCOVERY board for some time and left it on the shelf, simply because I did not know how to get started. Recently, Techsource and Aimagin organized a workshop that included embedded software development session with a nice introduction to this product combination. Figure 1 captured the atmosphere of this workshop on April 3, 2014, at King Mongkut’s University of Technology, North Bangkok.

Figure 1 MATLAB & SIMULINK Developer Day 2014 at KMUT-NB

In this event, the instructor used a basic experiment setup in Figure 2 for introductory purpose. The plant was simply a 2.2 K\Omega resistor and 470 \mu F capacitor connected as a low-pass filter. An op-amp on aMG SIGCON-A signal conditioning board was formed as voltage follower to prevent voltage drop from impedance loading. The communication between the host PC and STM32F4DISCOVERY target was carried out via the aMG USB converter N2 board. The aMG F4 connect 2 board was used to provide a convenient connection between the processor and USB converter board.

Figure 2 experiment setup using Aimagin products

Now, I want to mimic this setup at home. I don’t have all the products in Figure 2, but only the STM32F4DISCOVERY, a standard USB to serial module, and electronic components on my shelf. In this article I will show you how it can be done.

First we need to draw a circuit diagram of the plant as shown in Figure 3. I search my drawers and find a 470 \mu F capacitor and 3.3 K\Omega resistor (different value from the one used in workshop so I need to recomputed the plant transfer function. That’s the topic of Part II).

Figure 3 circuit diagram of RC plant

The electrolytic capacitor is quite aged (like myself) but for demonstration purpose this should work fine. The voltage follower circuit is not mandatory, but a good idea to protect the DAC output of STM32F4DISCOVERY board. So I use 1/4 of MCP604 from Microchip for such purpose. This op-amp works with low-voltage, single-rail power supply (2.7 – 6V, according to Microchip datasheet). Here I connect to +5 V from the board.

Another modification form the original setup used in Aimagin workshop is the A/D input pin. There they used pin C0 (AN10). First I followed that pin assignment and found the voltage was off from expected reading. It took me a while to figure out from the board schematics that the pin C0 was connected some other circuit on-board with a pull-up resistor, hence the voltage reading error. So I guess the STM32F4DISCOVERY board used in the workshop, if not modified, is somehow different from the one I have. Anyway, for our project we change the analog input to pin C1 (AN11). Some blocks in the SIMULINK files then have to be adjusted accordingly.

Figure 4 and 5 show the top and bottom of the prototype board with STM32F4DISCOVERY mounted. The RC plant is soldered on the board and wired to the connector pins, which is labeled by handwriting. The surface-mounted MCP 604 is also soldered and glued to one rim of the board.

Figure 4 top of the prototype board with STM32F4DISCOVERY mounted

Figure 5 bottom of prototype board

*From the above figures, the used prototype board has a couple of old components unrelated to this experiment. Sorry if this amateur illustration irritates you. I’m really out of budget. LOL.

That’s all for the plant. Now we shift our attention to the USB connection between the host and target. Not knowing the schematics of the aMG USB converter N2 board, I can only check the SIMULINK diagram to see that the Txd and Rxd of USB-to-serial are connected to pin D9 and D8 of STM32F4DISCOVERY, respectively; i.e., USART3 is used. So regardless of what USB-to-serial hardware you are using, that’s all required to make it work. Of course, you can use other USART such as wiring Txd to B7 and Rxd to B6 (use USART1), but then you need to setup the SIMULINK blocks accordingly. For simplicity, I follow the original setup from the workshop by connecting Txd to D9 and Rxd to D8 of the STM32F4DISCOVERY board. Don’t forget to wire the ground between the USB converter and prototype board. Signals for hardware flow control (CTS and RTS) are not needed.

In my case, I find on my shelf an UM232R module from FDTI. I set up the module for 3.3V logic level and it works just fine. Another convenient choice is the USB-to-serial cable made by FDTI or some other vendors. Make sure you select a 3.3V signal model. From my experience, the driver from some cheap product does not work with Windows 8. I don’t know whether that problem is fixed. Nevertheless, I recommend FDTI products. Never have problem with them.

Figure 6 shows the UM232R connected to the prototype. Install the VCP driver and check which COM port it consumes. On my computer it’s COM5. We need to setup the SIMULINK blocks to match.

Figure 6 connecting a USB-to-serial module to prototype board

This is quite enough material for the hardware setup part of our Hello Waijung. Next time we will continue the discussion by performing some open-loop experiment and see whether our hardware works.

Next: Hello Waijung Part II: Open-Loop Test



Comments are closed.