Hello Lhastings,
From the error message it looks like the initial hardware setup is working - the state machine connects and exchanges some metadata, identifying it as a r2+ machine. The error occurs when MATLAB tries to identify the analog serial port.
State Machine r2+ appears to the PC as three separate USB serial devices, each with a COM port number. The first is the primary port for the MATLAB interface. The second is dedicated to streaming analog data (when the FlexIO channels are configured as analog inputs) and the third is for external applications to send byte codes to trigger state changes, etc.
In the Windows device manager, if you expand the "Ports (COM & LPT)" list, there should be three COM ports that appear and disappear when you plug in the device.
Does the machine connect if you omit 'COM20' from the call to Bpod()?
One thing I flagged is the line number - in your error message, the crash occurs on line 126 of SetupHardware.m. In the latest version of Bpod_Gen2, the error is on line 150. Is it possible that you have an older or modified version of the code? Please try re-downloading Bpod_Gen2, and make sure the new version (and no others) are in the MATLAB path.
Please let me know if this helps!
Thanks,
Josh