Daq card / arduino

Hi Chris,

Happy thanksgiving. Just emailing now so I don’t forget some details.

The task runs for a while (today several hours) without error and then gives a disconnection error (see below). I would send you the mwk2 but it’s with the camera so it’s about 30gb. Is there some other log file I could send more easily?

Since the switch to the M2 mac studio I have encountered this new mworks issue with the daq card. It happens stochastically and so far only when the animal is doing the task. First time was last week, then it didn’t happen for several days and now it happened two days in a row.

When I restart the task the error is gone (at least for a while).

Currently running the third attempt to recreate with the same task in ‘perfect fixation’ mode and the issue doesn’t happen.

This looks a bit like I pulled the cable out but I didn’t. Also when the task is running normally, wriggling the cable on either end doesn’t do anything.

The same issue wasn’t present with the identical Arduino in the old system. I did install the Arduino software, drivers as in previous setup, and the firmata installation following your description. (Setting up an Arduino or compatible microcontroller as a Firmata device)

I also did a reinstall of this firmata thing yet again. It blinks as expected, upload says it worked etc.

Any ideas?

Thanks

Hi Alina,

The Arduino is connected via USB (not Bluetooth), right? If so, then at some point before the “Cannot send data” messages start, you should see the following error messages (but only once):

Read from serial port failed: <some reason>
Disconnected from Firmata device "daq"

They’re probably somewhere farther back in the console log. If you can, it’d be helpful if you could confirm that they’re present, just so I know that things are failing in a “normal” way.

As a workaround, you could try setting the reconnect_interval parameter of the Firmata device to something greater than zero. That should at least allow the experiment to recover automatically, without you needing to stop, close, and reload it.

As for why this is happening with the new Mac, my first guess is that there’s an issue with the USB hub and/or adaptor you’re using. Anecdotally, I found that a USB hub I had been using for years with a 2013 Mac Pro (trash can) didn’t work reliably with a 2020 M1 Mac mini. I have no idea why, but it’s possible you’re having similar issue. Maybe try a different hub, or try connecting the Arduino directly to a USB port (via a USB-A to USB-C adaptor, presumably)?

Another thought: Is the camera connected to the same USB hub as the Arduino? If so, maybe try connecting them to different USB ports. It’s possible that the camera needs too much USB bandwidth to reliably share a hub with the Arduino (at least on the new Mac).

Is the Arduino IDE closed? If not, close it, then disconnect and reconnect the Arduino board. The IDE should never be running when you’re using the board with MWorks, since it might try to communicate with the board and thereby break its connection to MWorks.

Also, can you tell me what versions of MWorks and macOS you’re running?

Thanks,
Chris

Is there a way to open the console log and not work through the mwk2 file? Or only if I save that manually?

  • Mworks 12.2, ventura 13.6.1
  • Yes this is USB connected
  • It is connected directly to the machine, just like my second Arduino (which seems to be doing fine but is also used a lot more rarely)
  • The camera is connected with a hub because there are only two actual usb connections on the new machine. I could buy a usb a to c connector to connect it more directly.
  • Arduino ide is closed.

Hi Alina,

Is there a way to open the console log and not work through the mwk2 file? Or only if I save that manually?

Only if you save it manually. A quick way to get the messages out of the event file is to run the following in Terminal (replacing my_file.mwk2 with your actual file name):

python3 /Library/Application\ Support/MWorks/Scripting/Python/dump_events my_file.mwk2 '#announceMessage' > messages.txt

You could then send the file messages.txt to me. (Maybe compress it first, if it’s large.)

It is connected directly to the machine, just like my second Arduino (which seems to be doing fine but is also used a lot more rarely)

The camera is connected with a hub because there are only two actual usb connections on the new machine. I could buy a usb a to c connector to connect it more directly.

Hmm. It’d be interesting to see how the various devices are distributed among the available USB buses. Can you run the following command in Terminal

system_profiler SPUSBDataType > usb_info.txt

and send me the file usb_info.txt?

Thanks,
Chris

Hi Chris,

It turns out the error that it throws is ‘device not configured’. Notably after using the device hundreds/thousands of times that day.

Attached an example for a full day and the usb_info.

Event 9686:

time = 9167169308

code = 6

name = #announceMessage

value = {‘message’: ‘ERROR: Read from serial port failed: Device not configured’, ‘origin’: 1, ‘type’: 2, ‘domain’: 7}

Event 9687:

time = 9167169351

code = 6

name = #announceMessage

value = {‘message’: ‘ERROR: Serial port drain failed: Device not configured’, ‘origin’: 1, ‘type’: 2, ‘domain’: 7}

Event 9688:

time = 9167169362

code = 6

name = #announceMessage

value = {‘message’: ‘ERROR: Cannot restore previous serial port attributes: Device not configured’, ‘origin’: 1, ‘type’: 2, ‘domain’: 7}

Event 9689:

time = 9167169373

code = 6

name = #announceMessage

value = {‘message’: ‘ERROR: Disconnected from Firmata device “daq”’, ‘origin’: 1, ‘type’: 2, ‘domain’: 7}

messages_24.txt.zip (158 KB)

usb_info.txt (6.13 KB)

Hi Alina,

It turns out the error that it throws is ‘device not configured’. Notably after using the device hundreds/thousands of times that day.

Interesting. “Device not configured” is the description for error code ENXIO, which, according to the man page for the read system call, can mean either “an action is requested of a device that does not exist” or “a requested action cannot be performed by the device”. The “does not exist” case seems like what’d you see if the device spontaneously disconnected. Maybe the voltage supplied to the Arduino board dipped below the minimum it needs? I suppose it could be an error on the macOS side, too.

Attached an example for a full day and the usb_info.

Thanks. The USB info is helpful, because it shows that the camera and the Arduino are using the same USB bus. (It’s not unreasonable that the two USB-A ports share a bus, since each one is limited to a maximum of 5Gb/s, versus 10Gb/s for the USB-C ports on the front and 40Gb/s for the Thunderbolt/USB-C ports on the back.)

I think it’d be wise to move the camera to one of the USB-C ports on the back. That way, it will have a USB bus to itself, and the Arduino won’t have to compete with it for bandwidth. I don’t know if that will solve that problem, but it at least seems possible.

Cheers,
Chris

Hi Chris, this is the current setup as I see it from the outside.

The two arduinos (marked red) are in USB portson the one side. The ximea and keyboard etc are on a hub that connects to a usb c on the other side.

It seems unintuitive that these are connected?

I thought I was already separating things and using the best possible connection for the arduinos.

<img width=“339” height=“373” style=“width:3.5312in;height:3.8854in” id=“Picture_x0020_4” src=“//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/standard11/uploads/mworks/original/1X/cf5d05c6d7bfb7a6bd1bdac6b218eba49ca9fb86.png” alt="A back and side view of a device

Description automatically generated">

Would your recommendation be to move the usb hub to one of the back connectors and keep everything else as is?

Would the voltage supply possibly improve if I use an adapter and put the Arduino on a thunderbolt connection do you think? USB has been sufficient always so far.

image001.png

image005.png

Hi Alina,

The two arduinos (marked red) are in USB portson the one side. The ximea and keyboard etc are on a hub that connects to a usb c on the other side.

Oh, interesting. So it seems like the two USB-C ports on the front and the two USB-A ports on the back are all connected to the same USB bus. I guess that’s not unreasonable, since together they support a maximum 30Gb/s transfer rate, which is still less than the 40Gb/s provided by the USB-C ports on the back (each of which appears to have its own USB bus).

It seems unintuitive that these are connected?

Yes, it’s not at all obvious unless you look at the output of system_profiler. (You can also get the same info in GUI form via System Information, under Hardware → USB).

Would your recommendation be to move the usb hub to one of the back connectors and keep everything else as is?

Yes, I think that would be ideal.

Would the voltage supply possibly improve if I use an adapter and put the Arduino on a thunderbolt connection do you think? USB has been sufficient always so far.

The voltage thing was just a guess. If it’s correct, I think that moving the USB hub should be sufficient, since that will leave more power for the Arduino boards. It really doesn’t seem like a separate power supply should be necessary.

Chris

Ok. I also checked Yoon’s setup and he has the camera on the thunderbolt, not the front part. Fingers crossed that this fixes it.

Fyi this was gone until today and now back.

Let’s hope it stays this rare at least…