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

Commit b317f00

Browse files
author
Iordanis Kostelidis
committed
Adds support for EPOS 4
Updated for latest EPOS Studio libraries Removes docx(s) from original library Removes slx(s) from original library Removes test(s) from original library Adds installation guide on README.md Adds support for multiple usb motors (passing the number from class constructor)
1 parent f40fb27 commit b317f00

63 files changed

Lines changed: 903 additions & 924 deletions

Some content is hidden

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

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.mexa64
2+
*.mexa32
3+
*.mexw32
4+
*.mexw64
5+
6+
*.dll
7+
*.lib
8+
9+
.idea

Clean.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
delete *.mexa32
33
delete *.mexw32
44
delete *.mexw64
5+
6+
delete *.dll
7+
delete *.lib

ClearErrorState.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* This a library for communication with Maxon Motors EPOS2 motor controllers
1+
/* This a library for communication with Maxon EPOS4 motor controllers
22
* using MATLAB.
33
*
4-
* Copyright, Eugenio Yime Rodr�guez, 2015
4+
* Copyright, Eugenio Yime Rodriguez, 2015
55
*
66
*/
77

@@ -12,45 +12,43 @@
1212
#include "Win2Linux.h"
1313
#endif
1414

15-
void
16-
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17-
{
18-
DWORD ErrCode = 0;
15+
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
16+
DWORD ErrCode = 0;
1917
HANDLE mHandle;
20-
WORD NodeID;
21-
long lHandle;
22-
char ErrorInfo[255];
18+
WORD NodeID;
19+
long lHandle;
20+
char ErrorInfo[255];
2321

2422
/* Examine input (right-hand-side) arguments. */
2523
if (nrhs != 2) {
2624
mexPrintf("Error: this function should be use with two input arguments\n");
2725
return;
2826
}
2927
/* 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;
28+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1) {
29+
mexPrintf("Error: this function requires two input scalar\n");
30+
return;
3331
}
3432
/* 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;
33+
if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1) {
34+
mexPrintf("Error: this function requires two input scalar\n");
35+
return;
3836
}
3937
/* Examine output (left-hand-side) arguments. */
4038
if (nlhs > 1) {
4139
mexPrintf("Error: this function should be use with only one output argument\n");
4240
return;
4341
}
44-
42+
4543
/* create output matrix */
4644
plhs[0] = mxCreateDoubleScalar(0.0);
4745

4846
/* first input */
4947
lHandle = (long) *mxGetPr(prhs[0]);
5048
mHandle = LongToHandle(lHandle);
5149
/* second input */
52-
NodeID = (WORD) *mxGetPr(prhs[1]);
53-
50+
NodeID = (WORD) * mxGetPr(prhs[1]);
51+
5452
/* Clear error device */
5553
if (!VCS_ClearFault(mHandle, NodeID, &ErrCode)) {
5654
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);

ClearErrorState.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
function res = ClearErrorState(handle, nodeid)
2-
% This function clears the error state for epos2 with number nodeid
2+
% This function clears the error state for epos4 with number nodeid
33
%
44
% Call it as,
55
%
6-
% res = ClearErorrState(handle, nodeid)
6+
% res = ClearErrorState(handle, nodeid)
77
%
88
% Where:
99
%
1010
% res is a number, 0 (zero) if it works, a negative number if not
1111
%
1212
% handle is the handle returned by OpenCommunication
1313
%
14-
% nodeid is the id number for EPOS 2 controller
14+
% nodeid is the id number for EPOS 4 controller
1515
%
1616
% Copyright E. Yime, 2015.
1717
% Colombia

CloseCommunication.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* This a library for communication with Maxon Motors EPOS2 motor controllers
1+
/* This a library for communication with Maxon EPOS4 motor controllers
22
* using MATLAB.
33
*
4-
* Copyright, Eugenio Yime Rodr�guez, 2015
4+
* Copyright, Eugenio Yime Rodriguez, 2015
55
*
66
*/
77

@@ -12,25 +12,23 @@
1212
#include "Win2Linux.h"
1313
#endif
1414

15-
void
16-
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17-
{
18-
DWORD ErrCode = 0;
19-
BOOL Output = FALSE;
15+
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
16+
DWORD ErrCode = 0;
17+
BOOL Output = FALSE;
2018
HANDLE mHandle;
21-
WORD NodeID;
22-
long lHandle;
23-
char ErrorInfo[255];
19+
WORD NodeID;
20+
long lHandle;
21+
char ErrorInfo[255];
2422

2523
/* Examine input (right-hand-side) arguments. */
2624
if (nrhs != 1) {
2725
mexPrintf("Error: this function should be use with one input arguments\n");
2826
return;
2927
}
3028
/* 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;
29+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1) {
30+
mexPrintf("Error: this function requires one input scalar\n");
31+
return;
3432
}
3533

3634
/* create output matrix */
@@ -39,7 +37,7 @@ mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
3937
/* first input */
4038
lHandle = (long) *mxGetPr(prhs[0]);
4139
mHandle = LongToHandle(lHandle);
42-
40+
4341
/* Close Device */
4442
Output = VCS_CloseDevice(mHandle, &ErrCode);
4543
if (ErrCode) {

CloseCommunication.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function res = CloseCommunication(handle)
2-
% This function close the communication with EPOS2 controller through USB
2+
% This function close the communication with EPOS4 controller through USB
33
%
44
% Call it as,
55
%

DemoEpos.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
clc
2+
clear
3+
4+
Motor1 = Epos4(0,0);
5+
6+
Motor1.EnableNode;
7+
Motor1.ClearErrorState;
8+
9+
Motor1.MotionInPosition(0,2,20,1);
10+
Motor1.WaitUntilDone(10000);
11+
12+
Motor1.MotionInPosition(30000,2,20,1);
13+
Motor1.WaitUntilDone(10000);
14+
15+
Motor1.MotionInPosition(-30000,2,20,1);
16+
Motor1.WaitUntilDone(10000);
17+
18+
Motor1.MotionInPosition(0,2,20,1);
19+
Motor1.WaitUntilDone(10000);
20+
21+
delete(Motor1);

DisableNode.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* This a library for communication with Maxon Motors EPOS2 motor controllers
1+
/* This a library for communication with Maxon EPOS4 motor controllers
22
* using MATLAB.
33
*
4-
* Copyright, Eugenio Yime Rodr�guez, 2015
4+
* Copyright, Eugenio Yime Rodriguez, 2015
55
*
66
*/
77

@@ -12,48 +12,46 @@
1212
#include "Win2Linux.h"
1313
#endif
1414

15-
void
16-
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17-
{
18-
DWORD ErrCode = 0;
19-
BOOL Fault = FALSE;
15+
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
16+
DWORD ErrCode = 0;
17+
BOOL Fault = FALSE;
2018
HANDLE mHandle;
21-
WORD NodeID;
22-
long lHandle;
23-
int IdMode;
24-
char ErrorInfo[255];
19+
WORD NodeID;
20+
long lHandle;
21+
int IdMode;
22+
char ErrorInfo[255];
2523

2624
/* Examine input (right-hand-side) arguments. */
2725
if (nrhs != 2) {
2826
mexPrintf("Error: this function should be use with two input arguments\n");
2927
return;
3028
}
3129
/* 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;
30+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1) {
31+
mexPrintf("Error: this function requires two input scalar\n");
32+
return;
3533
}
3634
/* 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;
35+
if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1) {
36+
mexPrintf("Error: this function requires two input scalar\n");
37+
return;
4038
}
4139

4240
/* Examine output (left-hand-side) arguments. */
4341
if (nlhs > 1) {
4442
mexPrintf("Error: this function should be use with only one output argument\n");
4543
return;
4644
}
47-
45+
4846
/* create output matrix */
4947
plhs[0] = mxCreateDoubleScalar(0.0);
5048

5149
/* first input */
5250
lHandle = (long) *mxGetPr(prhs[0]);
5351
mHandle = LongToHandle(lHandle);
5452
/* second input */
55-
NodeID = (WORD) *mxGetPr(prhs[1]);
56-
53+
NodeID = (WORD) * mxGetPr(prhs[1]);
54+
5755
/* Set State to Disable */
5856
if (!VCS_SetDisableState(mHandle, NodeID, &ErrCode)) {
5957
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);

DisableNode.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
%
1313
% handle is the handle returned by OpenCommunication
1414
%
15-
% nodeid is the EPOS 2 node ID
15+
% nodeid is the EPOS 4 node ID
1616
%
1717
% Copyright E. Yime, 2015.
1818
% Colombia

EnableNode.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* This a library for communication with Maxon Motors EPOS2 motor controllers
1+
/* This a library for communication with Maxon EPOS4 motor controllers
22
* using MATLAB.
33
*
4-
* Copyright, Eugenio Yime Rodr�guez, 2015
4+
* Copyright, Eugenio Yime Rodriguez, 2015
55
*
66
*/
77

@@ -12,48 +12,46 @@
1212
#include "Win2Linux.h"
1313
#endif
1414

15-
void
16-
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
17-
{
18-
DWORD ErrCode = 0;
19-
BOOL Fault = FALSE;
15+
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
16+
DWORD ErrCode = 0;
17+
BOOL Fault = FALSE;
2018
HANDLE mHandle;
21-
WORD NodeID;
22-
long lHandle;
23-
int IdMode;
24-
char ErrorInfo[255];
19+
WORD NodeID;
20+
long lHandle;
21+
int IdMode;
22+
char ErrorInfo[255];
2523

2624
/* Examine input (right-hand-side) arguments. */
2725
if (nrhs != 2) {
2826
mexPrintf("Error: this function should be use with two input arguments\n");
2927
return;
3028
}
3129
/* 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;
30+
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1) {
31+
mexPrintf("Error: this function requires two input scalar\n");
32+
return;
3533
}
3634
/* 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;
35+
if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1) {
36+
mexPrintf("Error: this function requires two input scalar\n");
37+
return;
4038
}
4139

4240
/* Examine output (left-hand-side) arguments. */
4341
if (nlhs > 1) {
4442
mexPrintf("Error: this function should be use with only one output argument\n");
4543
return;
4644
}
47-
45+
4846
/* create output matrix */
4947
plhs[0] = mxCreateDoubleScalar(0.0);
5048

5149
/* first input */
5250
lHandle = (long) *mxGetPr(prhs[0]);
5351
mHandle = LongToHandle(lHandle);
5452
/* second input */
55-
NodeID = (WORD) *mxGetPr(prhs[1]);
56-
53+
NodeID = (WORD) * mxGetPr(prhs[1]);
54+
5755
/* Set Node to Enable */
5856
if (!VCS_SetEnableState(mHandle, NodeID, &ErrCode)) {
5957
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);

0 commit comments

Comments
 (0)