MATLAB: Do Simulink “Deploy to Hardware” and “External” modes work with Arduino Uno clones

arduino clonesarduino originalarduino unoMATLABsimulinksimulink codersimulink deploy to hardwaresimulink external mode

Hello,
There are two popular clones of original Arduino Uno:
– old clones that use CH340 chip for USB to Serial communication with PC and programming (requires 3rd party Serial to USB driver)
– new clones that use ATmega16u2 for USB to SErial communication with PC and programming (claims to use original Arduino drivers)
My question is, does anybody know, have anybody tried running Arduino Uno clones with Simulink External/Deploy mode? If yes did it work? Which board exactly were you using (new clone with ATmega16u2 or old with CH340)?
I'm asking this question because I'm planning practical demonstration on how to program Arduino with Simulink and unfortunately I can't enforce that every single participant will have original Arduino and I'm trying to find out how severe problem it can be if one tries to use clone.

Best Answer

The "Deploy to Hardware" should work fine with both CH340 and ATmega16u2 clones. For most of the Arduino boards the External mode baud rate is set to 921600. I have observed that CH340 cannot handle baudrate greater than 230400. This is the reason that External mode fails.
There is a hidden API to change the default External mode baudrate. Open the model. Check the default External mode baudrate by executing the below command:
>>codertarget.arduinobase.registry.setBaudRate(gcs)
If you want to change the baudrate to a lower value say 230400 then use: >>codertarget.arduinobase.registry.setBaudRate(gcs,230400)
If you have an issue with External mode even after setting External mode baudrate to 230400 then keep lowering it till External mode works.
Ideally the clones with ATmega16u2 that use original Arduino drivers should work seamlessly in External mode. I have not yet tested though.