2
$\begingroup$

I am using Mathematica 10.3 and Windows 10 Pro 64-Bit.

I would like to test a stepper motor by simply sending strings over the serial interface.

Is the code below the right way to open the serial interface, adjust the baud rate etc., send a string, and close the interface. In my case I have only COM3, and the setting parameters required for the motor are given below.

dev = DeviceOpen[
  "Serial", {"COM3", "BaudRate" -> 9600, "DataBits" -> 8, 
   "Parity" -> None, "StopBits" -> 1}]

DeviceWrite[dev, "SEND STRING"];

DeviceClose[dev];

DeviceConfigure does not work for the serial interface (DeviceConfigure::noop: "DeviceConfigure not supported for "Serial".)

$\endgroup$
  • $\begingroup$ Well, it would seem to me that the most expedient way to check whether your code works would be to simply try it out. What happens when you try to execute it? $\endgroup$ – MarcoB Nov 6 '15 at 17:19
4
$\begingroup$

I have successfully tested your code, it does work.

piratebus = 
  DeviceOpen[
   "Serial", {"COM8", "BaudRate" -> 115200, "DataBits" -> 8, 
    "Parity" -> None, "StopBits" -> 1}];

Leave some time before this

DeviceWrite[piratebus, "?\n"];

FromCharacterCode@DeviceReadBuffer[piratebus]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.