Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit 30cb868

Browse files
author
Iordanis Kostelidis
committed
Initial commit
0 parents  commit 30cb868

63 files changed

Lines changed: 3731 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Clean.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
delete *.mexa64
2+
delete *.mexa32
3+
delete *.mexw32
4+
delete *.mexw64

ClearErrorState.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* This a library for communication with Maxon Motors EPOS2 motor controllers
2+
* using MATLAB.
3+
*
4+
* Copyright, Eugenio Yime Rodr�guez, 2015
5+
*
6+
*/
7+
8+
#include "mex.h"
9+
#include "Definitions.h"
10+
11+
#ifdef _LINUX_
12+
#include "Win2Linux.h"
13+
#endif
14+
15+
void
16+
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17+
{
18+
DWORD ErrCode = 0;
19+
HANDLE mHandle;
20+
WORD NodeID;
21+
long lHandle;
22+
char ErrorInfo[255];
23+
24+
/* Examine input (right-hand-side) arguments. */
25+
if (nrhs != 2) {
26+
mexPrintf("Error: this function should be use with two input arguments\n");
27+
return;
28+
}
29+
/* Check first input */
30+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1 ) {
31+
mexPrintf("Error: this function requires two input scalar\n");
32+
return;
33+
}
34+
/* Check second input */
35+
if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1 ) {
36+
mexPrintf("Error: this function requires two input scalar\n");
37+
return;
38+
}
39+
/* Examine output (left-hand-side) arguments. */
40+
if (nlhs > 1) {
41+
mexPrintf("Error: this function should be use with only one output argument\n");
42+
return;
43+
}
44+
45+
/* create output matrix */
46+
plhs[0] = mxCreateDoubleScalar(0.0);
47+
48+
/* first input */
49+
lHandle = (long) *mxGetPr(prhs[0]);
50+
mHandle = LongToHandle(lHandle);
51+
/* second input */
52+
NodeID = (WORD) *mxGetPr(prhs[1]);
53+
54+
/* Clear error device */
55+
if (!VCS_ClearFault(mHandle, NodeID, &ErrCode)) {
56+
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);
57+
mexPrintf("Error: %s \n", ErrorInfo);
58+
*mxGetPr(plhs[0]) = 1;
59+
}
60+
}

ClearErrorState.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function res = ClearErrorState(handle, nodeid)
2+
% This function clears the error state for epos2 with number nodeid
3+
%
4+
% Call it as,
5+
%
6+
% res = ClearErorrState(handle, nodeid)
7+
%
8+
% Where:
9+
%
10+
% res is a number, 0 (zero) if it works, a negative number if not
11+
%
12+
% handle is the handle returned by OpenCommunication
13+
%
14+
% nodeid is the id number for EPOS 2 controller
15+
%
16+
% Copyright E. Yime, 2015.
17+
% Colombia
18+
%

CloseCommunication.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* This a library for communication with Maxon Motors EPOS2 motor controllers
2+
* using MATLAB.
3+
*
4+
* Copyright, Eugenio Yime Rodr�guez, 2015
5+
*
6+
*/
7+
8+
#include "mex.h"
9+
#include "Definitions.h"
10+
11+
#ifdef _LINUX_
12+
#include "Win2Linux.h"
13+
#endif
14+
15+
void
16+
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17+
{
18+
DWORD ErrCode = 0;
19+
BOOL Output = FALSE;
20+
HANDLE mHandle;
21+
WORD NodeID;
22+
long lHandle;
23+
char ErrorInfo[255];
24+
25+
/* Examine input (right-hand-side) arguments. */
26+
if (nrhs != 1) {
27+
mexPrintf("Error: this function should be use with one input arguments\n");
28+
return;
29+
}
30+
/* Check first input */
31+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1 ) {
32+
mexPrintf("Error: this function requires one input scalar\n");
33+
return;
34+
}
35+
36+
/* create output matrix */
37+
plhs[0] = mxCreateDoubleScalar(0.0);
38+
39+
/* first input */
40+
lHandle = (long) *mxGetPr(prhs[0]);
41+
mHandle = LongToHandle(lHandle);
42+
43+
/* Close Device */
44+
Output = VCS_CloseDevice(mHandle, &ErrCode);
45+
if (ErrCode) {
46+
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);
47+
mexPrintf("Error: %s \n", ErrorInfo);
48+
*mxGetPr(plhs[0]) = 1;
49+
}
50+
}

CloseCommunication.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function res = CloseCommunication(handle)
2+
% This function close the communication with EPOS2 controller through USB
3+
%
4+
% Call it as,
5+
%
6+
% res = CloseCommunication(handle)
7+
%
8+
% Where:
9+
%
10+
% res is a number, 0 (zero) if it works, a negative number if not
11+
%
12+
% handle is the handle returned by OpenCommunication
13+
%
14+
% Copyright E. Yime, 2015.
15+
% Colombia
16+
%

DisableNode.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* This a library for communication with Maxon Motors EPOS2 motor controllers
2+
* using MATLAB.
3+
*
4+
* Copyright, Eugenio Yime Rodr�guez, 2015
5+
*
6+
*/
7+
8+
#include "mex.h"
9+
#include "Definitions.h"
10+
11+
#ifdef _LINUX_
12+
#include "Win2Linux.h"
13+
#endif
14+
15+
void
16+
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17+
{
18+
DWORD ErrCode = 0;
19+
BOOL Fault = FALSE;
20+
HANDLE mHandle;
21+
WORD NodeID;
22+
long lHandle;
23+
int IdMode;
24+
char ErrorInfo[255];
25+
26+
/* Examine input (right-hand-side) arguments. */
27+
if (nrhs != 2) {
28+
mexPrintf("Error: this function should be use with two input arguments\n");
29+
return;
30+
}
31+
/* Check first input, handle */
32+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1 ) {
33+
mexPrintf("Error: this function requires two input scalar\n");
34+
return;
35+
}
36+
/* Check second input, nodeID */
37+
if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1 ) {
38+
mexPrintf("Error: this function requires two input scalar\n");
39+
return;
40+
}
41+
42+
/* Examine output (left-hand-side) arguments. */
43+
if (nlhs > 1) {
44+
mexPrintf("Error: this function should be use with only one output argument\n");
45+
return;
46+
}
47+
48+
/* create output matrix */
49+
plhs[0] = mxCreateDoubleScalar(0.0);
50+
51+
/* first input */
52+
lHandle = (long) *mxGetPr(prhs[0]);
53+
mHandle = LongToHandle(lHandle);
54+
/* second input */
55+
NodeID = (WORD) *mxGetPr(prhs[1]);
56+
57+
/* Set State to Disable */
58+
if (!VCS_SetDisableState(mHandle, NodeID, &ErrCode)) {
59+
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);
60+
mexPrintf("Error: %s \n", ErrorInfo);
61+
*mxGetPr(plhs[0]) = 1;
62+
}
63+
}

DisableNode.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function res = DisableNode(handle, nodeid)
2+
% This function disable the node, so the motor will be unpowered and
3+
% uncontrolled.
4+
%
5+
% Call it as,
6+
%
7+
% res = DisableNode(handle, nodeid)
8+
%
9+
% Where:
10+
%
11+
% res is a number, 0 (zero) if it works, a negative number if not
12+
%
13+
% handle is the handle returned by OpenCommunication
14+
%
15+
% nodeid is the EPOS 2 node ID
16+
%
17+
% Copyright E. Yime, 2015.
18+
% Colombia
19+
%

EnableNode.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* This a library for communication with Maxon Motors EPOS2 motor controllers
2+
* using MATLAB.
3+
*
4+
* Copyright, Eugenio Yime Rodr�guez, 2015
5+
*
6+
*/
7+
8+
#include "mex.h"
9+
#include "Definitions.h"
10+
11+
#ifdef _LINUX_
12+
#include "Win2Linux.h"
13+
#endif
14+
15+
void
16+
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17+
{
18+
DWORD ErrCode = 0;
19+
BOOL Fault = FALSE;
20+
HANDLE mHandle;
21+
WORD NodeID;
22+
long lHandle;
23+
int IdMode;
24+
char ErrorInfo[255];
25+
26+
/* Examine input (right-hand-side) arguments. */
27+
if (nrhs != 2) {
28+
mexPrintf("Error: this function should be use with two input arguments\n");
29+
return;
30+
}
31+
/* Check first input, handle */
32+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1 ) {
33+
mexPrintf("Error: this function requires two input scalar\n");
34+
return;
35+
}
36+
/* Check second input, nodeID */
37+
if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1 ) {
38+
mexPrintf("Error: this function requires two input scalar\n");
39+
return;
40+
}
41+
42+
/* Examine output (left-hand-side) arguments. */
43+
if (nlhs > 1) {
44+
mexPrintf("Error: this function should be use with only one output argument\n");
45+
return;
46+
}
47+
48+
/* create output matrix */
49+
plhs[0] = mxCreateDoubleScalar(0.0);
50+
51+
/* first input */
52+
lHandle = (long) *mxGetPr(prhs[0]);
53+
mHandle = LongToHandle(lHandle);
54+
/* second input */
55+
NodeID = (WORD) *mxGetPr(prhs[1]);
56+
57+
/* Set Node to Enable */
58+
if (!VCS_SetEnableState(mHandle, NodeID, &ErrCode)) {
59+
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);
60+
mexPrintf("Error: %s \n", ErrorInfo);
61+
*mxGetPr(plhs[0]) = 1;
62+
}
63+
}

EnableNode.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function res = EnableNode(handle, nodeid)
2+
% This function enable a EPOS 2 node, so the motor will be powered and
3+
% controlled.
4+
%
5+
% Call it as,
6+
%
7+
% res = EnableNode(handle, nodeid)
8+
%
9+
% Where:
10+
%
11+
% res is a number, 0 (zero) if it works, a negative number if not
12+
%
13+
% handle is the handle returned by OpenCommunication
14+
%
15+
% nodeid is the EPOS 2 ID
16+
%
17+
% Copyright E. Yime, 2015.
18+
% Colombia
19+
%

0 commit comments

Comments
 (0)