Arduino issues

Hi Chris,

I wrote to you a couple of months ago about arduino related issues we were having - we though it might be related to the Arduino we were using (an Arduino nano), but we’ve since upgraded to the Arduino nano 33 IoT and are having similar problems.

We have two arduinos in our set up - one for two levers and reward delivery, and one for sending words to blackrock. The Arduino sending words does not have any issues, but the Arduino for the levers and reward does. Sometimes the levers will stop working, or it will show that a lever is being held when it isn’t. After much debugging, we noticed that the issue is directly correlated with correct trials, and narrowed it down specifically to the line of code that assigns the pin for the reward (i.e., taking out the pin assignment resolves the issue, adding it back in reproduces the issue). Our thinking is that the reward pin may have some negative interaction with other pins, so we opted to isolate the reward to a separate Arduino (meaning 3 total arduinos for the set up).

While trying to implement that, we’ve encountered some new issues. Mainly:

  • We are often (~50% of the time, although probably more) experiencing errors upon loading. I’ve attached a screenshot of the error message. It seems that all 3 arduinos have equal likelihood of failing.

  • When we are able to load successfully, the reward output is usually inconsistent. Sometimes it doesn’t work every other correct trial, every 3rd correct trial, etc. The pattern changes, but is consistent, at least within a session. Sometimes the levers stop working. Sometimes everything works correctly.

I’ve attached the code that we’ve been using for debugging purposes - a very simplified version of our program. Any insight into what we might be seeing here?

Thank you,
Jessica


DIO_TEST.mwel (3.1 KB)

Hi Jessica,

I’m sorry to hear you’re still having Arduino problems!

The fact that the load-time errors happen only some of the time suggests a hardware issue. Since you see the errors with all three Arduino boards, I suspect the boards themselves are OK. If the boards are connected to the Mac via a USB hub, I think the hub is the most likely point of failure. Can you try loading your “DIO TEST” protocol a few times with the two Arduino’s connected directly to the Mac, i.e. with a single USB cable connecting each board to a USB port on the Mac (with a USB-A to USB-C adaptor if needed)?

Another possibility is that the boards aren’t getting enough power. Again, this could be a USB hub issue. If you’re connecting the Arduino’s via a hub, is the hub powered (i.e. is there a power cable that connects it to an electrical outlet)? If not, then I suggest either switching to a powered hub or connecting the Arduino’s directly to an external power source.

One final thought: Please make sure that the Arduino IDE is not open when you’re trying to use Arduino’s with MWorks. If it is, it might attempt to interact with the boards via serial I/O, which could break the communication channel with MWorks.

Cheers,
Chris

Hi Chris,

Thank you very much for the suggestions - we switched to a powered USB hub, and haven’t observed the issue since.

Before, we were actually plugging them into the USB ports on the Mac (we have Mac pros from 2010-2012). I assume we should always default to using a powered hub for the arduinos, even with newer machines? It would be good to have clarity on that as we think about implementing mworks with arduinos in other rigs.

A couple of other quick questions:

  1. Sometimes, a red bar appears on the side of the console (picture attached). Usually it is when there is an error message farther up in the console (from a previous reload), but sometimes there are no errors indicated. Have you seen this before?

  2. If we were to upgrade our machines, any recommendations? We were considering the Mac mini or Mac Studio, but are open to any suggestions.

Thanks again,
Jessica

Hi Jessica,

Thank you very much for the suggestions - we switched to a powered USB hub, and haven’t observed the issue since.

Glad to hear it! I hope things stay that way.

Before, we were actually plugging them into the USB ports on the Mac (we have Mac pros from 2010-2012).

Huh. If the issue was power, I’m surprised the boards couldn’t get enough of it when connected directly to the Mac Pro. Maybe the entire load on the USB bus was sufficient to deprive them of adequate power? I’m just guessing here – I’m no expert on USB.

I assume we should always default to using a powered hub for the arduinos, even with newer machines? It would be good to have clarity on that as we think about implementing mworks with arduinos in other rigs.

It’s hard to say. In all my years using Arduino boards with MWorks, I’ve literally never needed a powered hub or external power source. USB bus power has always been completely adequate.

However, another user recently had Arduino issues that seemed to stem from an over-burdened USB bus – although whether the problem came down to power or data bandwidth wasn’t clear. Given your experience, I’m now inclined to think that power is the more likely issue.

To be safe, if you’re buying new USB hubs, I would get powered ones.

Sometimes, a red bar appears on the side of the console (picture attached). Usually it is when there is an error message farther up in the console (from a previous reload), but sometimes there are no errors indicated. Have you seen this before?

I have not. What versions of MWorks and macOS are you running?

If we were to upgrade our machines, any recommendations? We were considering the Mac mini or Mac Studio, but are open to any suggestions.

Coming from a Mac Pro, I’d recommend the base model Mac Studio (M2 Max, $1999). The DiCarlo Lab has been moving to these (from 2013 “trash can” Mac Pro’s), and they seem to be working well.

The M2 Mac mini’s are also good machines and fully capable of running MWorks, but the Mac Studio will give you a lot more overhead in terms of CPU and GPU power. There’s no reason to get the current Mac Pro, unless you really, really like the form factor and don’t mind paying $7K+ for it.

Cheers,
Chris

the Mac Studio will give you a lot more overhead in terms of CPU and GPU power

Sorry, I meant to write “a lot more headroom”.

Chris

Hi Chris,

Happy to report that we have still not seen any problems since switching the Arduino to a powered USB hub. Very grateful for that suggestion!

Re: the red bar - we’re running MWorks 10 and macOS Mojave (10.14.6). The red bar in the console doesn’t seem to cause any problems, but just thought I’d ask.

Thank you for all of your help!
Jessica

Hi Jessica,

Happy to report that we have still not seen any problems since switching the Arduino to a powered USB hub.

Great! Thanks for letting me know.

Chris