MMC904S CAN Bus Examples
MMC904S (Linux) code example for controlling 3 UIM342 motors via CAN bus. Uses C++ SDK with Qt GUI and Visual GDB cross-compilation.
This page provides an **MMC904S** (Linux) example project for controlling **3 UIM342 motors** via CAN bus, using the **UIROBOT C++ SDK** with a **Qt5 graphical user interface**.
---
## Quick Selection
| Connection Method | Compatible Products | Docs |
|-----------------|-------------------|------|
| **MMC904S + SDK → CAN Bus** | 3× UIM342 motors | [DEMO_MMC_3x342] |
---
## Background
This demonstration program runs on the **MMC904S** platform — UIROBOT's embedded Linux mini-PC. It uses the **libUirSdkRaspI32.so** SDK library and a **Qt5 GUI** to control three UIM342 servo stepper motors simultaneously over a CAN bus network.
### System Architecture
```
MMC904S (DemoApp ↔ SDK) ↔ Gateway ↔ Motors/I/O
```
Three gateway options are supported:
| Gateway | Type | Protocol |
|---------|------|----------|
| **UIM2513** | RS232-to-CAN | Serial |
| **UIM2523** | Ethernet-to-CAN | TCP/IP |
| **MMCGtwy** | Built-in MMC gateway | Internal |
### Key Features
- Qt5 graphical user interface with real-time status display
- Individual control of 3 motors (JOG, PTP, Homing, Stop)
- Group motion control for synchronized multi-axis movement
- Real-time notification (RTCN) message processing
- Speed slider control (up to 100,000 pps)
- Driver ON/OFF control
- LED status indicators for connection and motor status
---
## Required Hardware
| Item | Qty | Description |
|------|:---:|-------------|
| MMC904S | 1 | Embedded Linux mini-PC |
| UIM342 Motors | 3 | CAN bus smart motors (Node IDs configurable) |
| UIM2513 or UIM2523 | 1 | CAN bus gateway |
| 24V DC Power Supply | 1 | For motors and gateway |
| Ethernet Cable | 1 | For network connection |
| Windows PC | 1 | For development (Visual Studio + Visual GDB) |
---
## Wiring
```
Windows PC MMC904S
(Visual Studio --- (Linux Target)
+ Visual GDB) | IP: 192.168.1.16
| | |
| Ethernet Built-in Gateway
| | |
+-------------+ +-----+-----+
| |
CAN Bus (twisted pair)
+------+----+------+
| | |
UIM342-1 UIM342-2 UIM342-3
(ID: 1) (ID: 2) (ID: 3)
```
> **Note**: The MMC904S can communicate via UIM2513 (serial), UIM2523 (Ethernet), or its built-in MMC gateway.
---
## Software Structure
### Project Files
| File | Description |
|------|-------------|
| `Demo_3xUIM342.pro` | Qt5 project file |
| `MainWindow.cpp / .h` | Qt GUI main window (UI with sliders, buttons, status LEDs) |
| `MainWindow.ui` | Qt Designer UI layout |
| `ControlFunction.cpp / .h` | Motor control logic (individual + group motion) |
| `MMC_3xUIM342.cpp` | Application entry point |
| `CAN30SDK.h` | CAN bus SDK header |
| `uirSDKgen3.h` | UIROBOT SDK header |
| `libUirSdkRaspI32.so` | Pre-compiled SDK library for Raspberry Pi / MMC |
| `DEMO_MMC_3x342.sln` | Visual Studio solution for Visual GDB |
### GUI Features (from MainWindow.cpp)
The Qt interface provides:
- **3 motor control panels** — each with Start, Stop, Set Origin buttons
- **Speed slider** — up to 100,000 pps
- **Position display** — real-time position readout for each motor
- **LED indicators** — Connection status, Motor SON status
- **Driver ON/OFF** — Global motor driver control
### Control Functions (from ControlFunction.h)
```cpp
// Gateway management
ERRO StartMmcGateway(void); // Open MMC904 gateway
ERRO CloseMmcGateway(void); // Close MMC904 gateway
// Motor power control
ERRO SetDriverON(void); // Turn motor driver ON
ERRO SetDriverOFF(void); // Turn motor driver OFF
// Individual motor control
ERRO SetMotorMotion1(void); // Configure Motor 1 motion
ERRO SetMotorMotion2(void); // Configure Motor 2 motion
ERRO SetMotorMotion3(void); // Configure Motor 3 motion
// Group motion
ERRO SetGroupMotion(void); // Synchronized multi-axis motion
// Real-time notification
void CRevRtcnNotify(UI_MSG_OBJ* uiMsgObj); // Handle RTCN messages
void RtcnProcess(void); // RTCN thread
// Utility
bool StopMotion(int CNAid); // Stop specific motor
bool WaitFlag(bool* pFlag, unsigned int nWaitTimsMS = 60000);
```
---
## Development Environment Setup
### Step 1 — Install Visual Studio
Download and install from [visualstudio.microsoft.com](https://visualstudio.microsoft.com/) with **Desktop development with C++** workload.
### Step 2 — Install Visual GDB
Download and install from [visualgdb.com](https://visualgdb.com/). This extension enables cross-compilation and remote debugging for Linux targets.
### Step 3 — Download Sample Code
Download the project archive:
| Description | Download |
|-------------|----------|
| MMC 3×UIM342 Demo (C++ SDK + Qt GUI) | [Download ZIP](https://www.uirobot.com/uploads/files/851ca2aac2177dbc5f8f199b275048c8.zip) |
### Step 4 — Open and Build
1. Open the solution file `DEMO_MMC_3x342.sln` in Visual Studio
2. Configure Visual GDB to connect to your MMC904S (IP: 192.168.1.16)
3. Build the project — Visual GDB will cross-compile and deploy to the target
---
## Related Documents
- [UIROBOT Code Examples Overview](/docs/code-examples-overview)
- [UIM342 CAN Bus Motor Controller](/docs/uim342)
- [MMC90X Miniature Motion Control Computer](/docs/mmc90x)
- [Quick Start Guide](/docs/quick-start)
---
*Last updated: 2026-06-25 | Based on source code analysis of DEMO_MMC_3x342*