Sending commands from Matlab to Duet board
-
Hello everyone,
I am using Duet3 mini5+ and I'm trying to send commands from Matlab to the Duet board for motion control.
I tried to initiate a tcpclient with the ip address of the Duet board. see the commands below:t=tcpclient('192.168.2.1',80); writeline(t,"G1 X100")
I keep getting the same error :
Error using matlabshared.asyncio.internal.MessageHandler/onError
An existing connection was forcibly closed by the remote hostIs my approach correct? If yes, then what could be the issue? If not, please tell me what to do.
-
@Mohamed13 please see this page that tells you how http Comms work https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests
-
I still don't get it. How should I connect matlab to Duet board? I'm new to Duet board and providing the steps is much appreciated.
I read over the provided link, but I didn't know what exactly should be done. -
@Mohamed13 You need to open a session that the Duet firmware understands, then send the Gcode within that session. See https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests#get-rr_gcode for an example. I would expect that example would be written something like this in Matlab (which I have never used, so may be incorrect):
t=tcpclient('192.168.2.1',80); writeline(t,"/rr_connect?password="); writeline(t,"/rr_gcode?gcode=G1 X100")
Ian
-
I was able to connect to the board using Telnet. I created the tcpclient with port number 23 and it worked fine. I just had to enable telnet in my board config file.
Thanks everyone. I will leave it here so maybe someone will need it.
-
@Mohamed13 Thanks. Could you post an example of the code you used in Matlab?
Ian
-
t=tcpclient('192.168.2.1',23);
writeline(t,"G1 X100");Just make sure to enable telnet in the config file. and Telnet client in the program features, you can access it from the Control Panel.