# Serial port communication between MWorks and new laser unit

**URL:** <https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929>\
**Category:** Support\
**Created:** [November 13, 2023, 11:44pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929 "2023-11-13T23:44:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasmine\_El-Shamayleh](https://avatars.discourse-cdn.com/v4/letter/y/258eb7/32.png) [@Yasmine\_El-Shamayleh](https://mworks.discourse.group/u/Yasmine_El-Shamayleh)\
**Post date:** [November 13, 2023, 11:44pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/1 "2023-11-13T23:44:03Z")

</div>

Hi Chris -

We recently received a new laser unit from the National Primate Research Center at UWashington, and MWORKS seems to be complaining about connecting to it via serial port.

Attaching the console error we get (Error\_Laser.txt) - as well as the mwel that configures the laser (config\_Laser.mwel). The mwel is based on the plugin you kindly wrote for us and includes the following:

```auto
iodevice/qcualor laser (
    serial_port = '/dev/cu.usbserial-AR0JVL1T' //check the correct portal
    mode_1 = 'off'
    mode_2 = mode_2
    mode_3 = 'off'
    mode_4 = 'off'
    modulation_frequency = modulation_frequency
    max_gain = 1
    // select the gain to TURN ON a specific laser channel
    gain_1 = 0
    gain_2 = amplitude
    gain_3 = 0
    gain_4 = 0
    )

```

However, Im not sure how to check for the correct portal. Could you help us with that?

This code works beautifully on our first rig, with our older laser and Mac - but not with this newer laser and Mac.

Thoughts?

Many thanks,  
Yasmine (CCing Taylor our new technician to keep her in the loop!)

[Error\_Laser.txt](https://mworks.discourse.group/uploads/short-url/x1dNrCiQ1Ai6YUgW0MM6mgx5kjS.txt) (959 Bytes)

[config\_Laser.mwel](https://mworks.discourse.group/uploads/short-url/q1MAI7BDzp8W6d6rZHPx9TUkoFA.mwel) (4.12 KB)

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [November 14, 2023, 3:02pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/2 "2023-11-14T15:02:02Z")

</div>

Invited @Yuan\_Xie on November 14, 2023, 3:02pm UTC



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [November 14, 2023, 3:02pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/3 "2023-11-14T15:02:02Z")

</div>

Forwarded the above email



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [November 14, 2023, 3:05pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/4 "2023-11-14T15:05:49Z")

</div>

Made this topic public on November 14, 2023, 3:05pm UTC



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [November 14, 2023, 3:22pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/5 "2023-11-14T15:22:37Z")

</div>

Hi Yasmine & Taylor,

The quickest way to find the correct serial port is to open Terminal (on the machine running MWServer) and run the following command:

```
ls /dev/cu.usb*

```

There will probably be just one match, and that’s the port you want.

If that doesn’t work (e.g. if `ls` reports “no matches found” or something similar), an alternative approach is to comment out the line with the `serial_port` parameter, e.g.

```auto
iodevice/qcualor laser (
    //serial_port = '/dev/cu.usbserial-AR0JVL1T' //check the correct portal
    ...

```

and then try loading the experiment. One of two things should happen:

1. If there’s only one serial device present, MWorks will assume it’s the laser and try connecting to it.
2. If there are multiple serial devices present, the experiment will fail to load, with an error message listing the ports of the discovered devices. You can then try each of these in turn, until you find the correct one.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![taylor.xie](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@taylor.xie](https://mworks.discourse.group/u/taylor.xie)\
**Post date:** [November 14, 2023, 8:03pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/6 "2023-11-14T20:03:52Z")

</div>

Hi Chris,

Thank you for your help! We commented out the line and it worked. The console gave error when we did that but it also told us the serial port of the laser on this rig.

There seems to be some communication issue with the laser. We are still troubleshooting and will get back to you!

Best,  
Taylor

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [January 2, 2024, 2:51pm UTC](https://mworks.discourse.group/t/serial-port-communication-between-mworks-and-new-laser-unit/929/7 "2024-01-02T14:51:48Z")

</div>

Closed on January 2, 2024, 2:51pm UTC


