# M4S Controller

The M4S Controller output sends actuator positions to a **Motion4Sim (M4S)** motion platform. DR Sim Manager supports two connection methods: **Serial** (USB) and **UDP** (network). Both methods support 7 output channels with 24-bit position resolution.

---

## M4S Controller (Serial)

Connects to the M4S controller over a serial (USB) connection.

### Setup Steps

1. Connect your M4S controller to your PC via USB.
2. In DR Sim Manager, go to the **Outputs** tab and click the **+** tab.
3. Select **M4S Controller (Serial)** from the list.
4. Select your **COM port** from the dropdown (click **Refresh** if it's not listed).
5. Enable **Auto Online** if you want the controller to come online automatically.
6. Map each channel to the appropriate sim component actuator.

### Settings

- **COM Port** — Select the serial port your M4S controller is connected to. Click **Refresh** to rescan for available ports. The connection uses a **fixed baud rate of 250,000** with **24-bit position values**.
- **Auto Online** — When enabled, the controller is automatically brought online when DR Sim Manager connects, and taken offline when it disconnects. This saves you from having to manually toggle the controller's online state.
- **Output Rate** — Adjust the output rate in milliseconds (default: **2 ms** / 500 Hz).

### Axis Mapping

Map each of the 7 available channels to a sim component actuator:

- **Device** — Select the sim component
- **Actuator** — Select which actuator output to send on this channel

---

## M4S Controller (UDP)

Connects to the M4S controller over a UDP network connection using multicast. This is useful for setups where the controller is on a separate machine or you prefer a network connection.

### Setup Steps

1. Ensure your M4S controller and PC are on the same network.
2. In DR Sim Manager, go to the **Outputs** tab and click the **+** tab.
3. Select **M4S Controller (UDP)** from the list.
4. Set the **IP Address** and **Port** (defaults are usually correct for most M4S setups).
5. Configure the auto-management options as desired.
6. Map each channel to the appropriate sim component actuator.

### Settings

- **IP Address** — The multicast IP address of the M4S controller (default: `232.11.12.14`).
- **Port** — The UDP port number (default: `51324`).
- **Auto Online** — Automatically bring the controller online when DR Sim Manager connects, and take it offline on disconnect.
- **Auto Home** — Automatically home the actuators when the connection is established. The homing process takes approximately 2 seconds to complete before the controller goes online.
- **Auto Shutdown** — Automatically shut down the controller when DR Sim Manager disconnects. This sends an offline command followed by a full shutdown command after a 5-second delay. **Use with caution** — this will power down the controller hardware.
- **Output Rate** — Adjust the output rate in milliseconds (default: **2 ms** / 500 Hz).

> **note**
When **Auto Home** and **Auto Online** are both enabled, the startup sequence is: Home → wait 2 seconds → Online. This ensures actuators are in a known position before motion begins.

> **caution**
When **Auto Shutdown** is enabled, disconnecting the output will fully shut down the M4S controller hardware (not just take it offline). Only enable this if you want the controller to power down when you close DR Sim Manager.

### Axis Mapping

Map each of the 7 available channels to a sim component actuator:

- **Device** — Select the sim component
- **Actuator** — Select which actuator output to send on this channel

---

## Troubleshooting

### Actuators not responding (Serial)

1. **Check the COM port** — Verify in **Device Manager > Ports (COM & LPT)**.
2. **Check Auto Online** — If Auto Online is off, the controller may not be in an online state. Enable it or bring the controller online manually through its own interface.
3. **Check USB connection** — Try a different USB port or cable.

### Actuators not responding (UDP)

1. **Check the IP address and port** — Ensure they match your M4S controller's network configuration.
2. **Check network connectivity** — The PC and controller must be on the same network. Multicast traffic must be allowed.
3. **Check firewall** — Windows Firewall may block outgoing UDP multicast. Add an exception for DR Sim Manager or the specific port.
4. **Check Auto Online** — The controller may need to be brought online before it accepts position data.

### Homing fails or takes too long

- Ensure the actuators are free to move to their home position.
- Check that the controller is powered and not in an error state.

### COM port not listed or "Access Denied"

See [Serial Output Not Working](../frequently-asked-questions/serial-output-not-working.md) for general COM port troubleshooting steps.
