74 return((
float)qc*3/3700);
87 return((
long int)(dg*3700/3));
100 cout <<
" Velocity: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
102 cout <<
" Velocity Sensor Actual: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
104 cout <<
" Velocity Demand: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
106 cout <<
" Velocity Actual: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
108 cout <<
" Position: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
110 cout <<
" Encoder Counter: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
112 cout <<
" Encoder Counter @ index pulse: " << hex <<
"0x" << li <<
" , " << dec << li << endl;
114 cout <<
" Current: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
116 cout <<
" Current Averaged: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
118 cout <<
" Current Demanded: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
120 cout <<
" StatusWord: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
122 cout <<
" Hall Sensor Pattern: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
124 cout <<
" Following Error: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
126 cout <<
" Version Hardware: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
128 cout <<
" Version Software: " << hex <<
"0x" << i <<
" , " << dec << i << endl;
148 bool opcio_target=
true;
153 cout <<
" ConfigTest Absolute Movement\n\n";
155 cout <<
" ConfigTest Relative Movement\n\n";
159 cout <<
" ConfigTest Profle Velocity\n\n";
163 cout <<
" ConfigTest Velocity\n\n";
167 opcio_target =
false;
172 cout <<
" Is this your desired target? (Y,n) " << value << endl;
176 cout <<
" Type your desired target " << endl;
186 cout <<
" Starting Profile Position to:" << value;
187 if(type ==
'a') mode = epos2->
ABSOLUTE;
188 if(type ==
'r') mode = epos2->
RELATIVE;
197 cout <<
"\n Profile Position Movement Finished" << endl;
204 cout <<
" Starting Profile Velocity to:" << value;
205 cout <<
" during 5 seconds" << endl;
208 cout <<
" TARGET VELOCITY REACHED - Press 's' to stop'" << endl;
214 cout <<
"\n Profile Position Movement Finished" << endl;
221 cout <<
" VELOCITY - Press 's' to stop'" << endl;
223 while(ui_v_stop!=
's'){
228 cout <<
" Velocity Movement Finished" << endl;
275 cout <<
" 4 profile position with change wait without blocking" << endl;
279 cout <<
" Start Relative not blocking not waiting" << endl;
286 cout <<
" Relative blocking waiting" << endl;
295 cout <<
" End Test" << endl;
319 cout <<
" ConfigTest Set Home\n\n";
325 cout <<
" ConfigTest Configure Profile Parameters\n\n";
330 epos2->
getProfileData(prof[0],prof[1],prof[2],prof[3],prof[4],prof[5],prof[6]);
333 <<
" PROFILE DATA" << endl
336 <<
" Velocity: " << prof[0] <<
"[rpm]" << endl
337 <<
" Max Velocity: " << prof[1] <<
"[rpm]" << endl
338 <<
" Acceleration: " << prof[2] <<
"[rpm/s]" << endl
339 <<
" Deceleration: " << prof[3] <<
"[rpm/s]" << endl
340 <<
" QS Decel: " << prof[4] <<
"[rpm/s]" << endl
341 <<
" Max Accel: " << prof[5] <<
"[rpm/s]" << endl
342 <<
" Type: " << prof[6] << endl<<endl;
344 cout <<
" Profile: Do you want to configure? (y,n): " ;
346 while(cs!=
'y' && cs!=
'n')
348 cout << endl <<
" Input Error. press 'y' or 'n': ";
354 cout <<
" Velocity [rpm] " << endl;
355 cin >> prof[0]; cout << endl;
356 cout <<
" Max Velocity [rpm] " << endl;
357 cin >> prof[1]; cout << endl;
358 cout <<
" Acceleration [rpm/s] " << endl;
359 cin >> prof[2]; cout << endl;
360 cout <<
" Deceleration [rpm/s] " << endl;
361 cin >> prof[3]; cout << endl;
362 cout <<
" QS Decel [rpm/s] " << endl;
363 cin >> prof[4]; cout << endl;
364 cout <<
" Max acc [rpm/s] " << endl;
365 cin >> prof[5]; cout << endl;
366 cout <<
" Type " << endl;
367 cin >> prof[6]; cout << endl;
370 epos2->
setProfileData(prof[0],prof[1],prof[2],prof[3],prof[4],prof[5],prof[6]);
375 cout <<
" ConfigTest Configure Control Parameters\n\n";
380 conpar[5],conpar[6],conpar[7],conpar[8],conpar[9]);
383 <<
" CONTROL PARAMETERS DATA" << endl
385 <<
" Current P: " << conpar[0] << endl
386 <<
" Current I: " << conpar[1] << endl
387 <<
" Velocity P: " << conpar[2] << endl
388 <<
" Velocity I: " << conpar[3] << endl
389 <<
" Velocity SPF: " << conpar[4] << endl
390 <<
" Position P: " << conpar[5] << endl
391 <<
" Position I: " << conpar[6] << endl
392 <<
" Position D: " << conpar[7] << endl
393 <<
" Position Vff: " << conpar[8] << endl
394 <<
" Position Aff: " << conpar[9] << endl
397 cout <<
" Profile: Do you want to configure? (y,n): " ;
399 while(cs!=
'y' && cs!=
'n')
401 cout << endl <<
" Input Error. press 'y' or 'n': ";
407 cout <<
" Current P: " << endl;
408 cin >> conpar[0]; cout << endl;
409 cout <<
" Current I: " << endl;
410 cin >> conpar[1]; cout << endl;
411 cout <<
" Velocity P: " << endl;
412 cin >> conpar[2]; cout << endl;
413 cout <<
" Velocity I: " << endl;
414 cin >> conpar[3]; cout << endl;
415 cout <<
" Velocity SPF: " << endl;
416 cin >> conpar[4]; cout << endl;
417 cout <<
" Position P: " << endl;
418 cin >> conpar[5]; cout << endl;
419 cout <<
" Position I: " << endl;
420 cin >> conpar[6]; cout << endl;
421 cout <<
" Position D: " << endl;
422 cin >> conpar[7]; cout << endl;
423 cout <<
" Position Vff: " << endl;
424 cin >> conpar[8]; cout << endl;
425 cout <<
" Position Aff: " << endl;
426 cin >> conpar[9]; cout << endl;
430 conpar[5],conpar[6],conpar[7],conpar[8],conpar[9]);
437 cout <<
" ConfigTest Configure Sensor Parameters\n\n";
441 cout <<
" ConfigTest Configure Motor Parameters\n\n";
445 cout <<
" ConfigTest Configure Position Parameters\n\n";
449 cout <<
" ConfigTest Configure Unit Dimensions\n\n";
453 cout <<
" ConfigTest Configure Communication Parameters\n\n";
457 cout <<
" ConfigTest Saving Parameters\n\n";
458 cout <<
" Are you sure you want to save parameters? (Y,n) " << endl;
463 cout <<
" Parameters Saved" << endl;
465 cout <<
" parameters not saved" << endl;
470 cout <<
" ConfigTest Restore Default Parameters\n\n";
471 cout <<
" Are you sure you want to restore parameters? (Y,n) " <<
477 cout <<
" Parameters Restored" << endl;
479 cout <<
" parameters not restored" << endl;
484 cout <<
" ConfigTest Read Errors\n\n";
492 cout <<
" ConfigTest Read Status Word\n\n";
493 cout <<
" STATUS-WORD: " << hex << epos2->
readStatusWord() << endl;
497 cout <<
" ConfigTest Read Data\n\n";
506 cout <<
" Choose another option" << endl << endl;
520 int main(
int argc,
char **argv)
524 bool verbose =
false;
527 cout <<
"\n EPOS2 CONFIG&TEST \n\n";
531 while ((opt = getopt(argc, argv,
"biphv")) != -1)
552 cout <<
" USAGE" << endl <<
"\n" 553 <<
" " << argv[0] <<
" [options]" << endl << endl
554 <<
" OPTIONS" << endl <<
556 <<
" -i Interrupt Movements" <<
557 "\tin profile position.\n" << endl
559 "\tShows all information\n" << endl << endl;
565 cout <<
" MENU" << endl <<
567 <<
" ▾ Do a movement" << endl
569 "\tProfile Position Absolute\n" 571 "\tProfile Position Relative\n" 573 "\tProfile Velocity\n" 579 "\tSet Home\n" << endl
580 <<
" Configure Parameters" << endl
588 "\tMotor (not done)\n" 590 "\tPosition (not done)\n" 592 "\tUnits dimension (not done)\n" 594 "\tCommunication (not done)\n" 596 "\tSave All Parameters\n" 598 "\tRestore Default\n" << endl
614 cout <<
" ConfigTest init EPOS2\n\n";
627 cout <<
" ConfigTest enable controller\n\n";
630 cout <<
" ConfigTest enable motor\n\n";
633 cout <<
" ConfigTest disable operation\n\n";
648 }
catch(std::exception &exc)
650 cout <<
"EPOS2 Exception: " << exc.what() << endl;
long readStatusWord()
function to read EPOS2 StatusWord
char readError()
function to read an Error information
void disableOperation()
function to reach switch_on and disables power on motor
void startProfilePosition(epos_posmodes mode, bool blocking=true, bool wait=true, bool new_point=true)
function to move the motor to a position in profile position mode
long readCurrentDemanded()
function to read current demanded
void getControlParameters(long &cp, long &ci, long &vp, long &vi, long &vspf, long &pp, long &pi, long &pd, long &pv, long &pa)
function to get all control parameters
void enableMotor(long opmode)
function to facititate transitions from switched on to operation enabled
long readVelocitySensorActual()
function to read velocity sensor actual
long int pdg2mqc(float dg)
platform [°] to motor [qc] It truncates the value
void getProfileData(long &vel, long &maxvel, long &acc, long &dec, long &qsdec, long &maxacc, long &type)
function to GET all data of the velocity profile
long readEncoderCounterAtIndexPulse()
function to read the Encoder Counter at index pulse
void readErrorHistory(long *error[5])
function to read last 5 errors
float mqc2pdg(long int qc)
motor [qc] to platform [°]
long getTargetProfileVelocity()
[OPMODE=profile_velocity] function to get the velocity
void setVerbose(bool verbose)
void setOperationMode(long opmode)
function to set the operation mode
void enableOperation()
function to reach operation_enable state and enables power on motor
long readCurrent()
function to read motor current
long readVersionSoftware()
function to read the software version
void readData()
reads all epos2 data
long readVelocityDemand()
function to read velocity demand
void setTargetProfileVelocity(long velocity)
[OPMODE=profile_velocity] function to set the velocity
long readHallsensorPattern()
function to read the Hall Sensor Pattern
long readCurrentAveraged()
function to read motor averaged current
void startVelocity()
function to move the motor in Velocity mode
void stopProfileVelocity()
[OPMODE=profile_velocity] function to stop the motor
void restoreDefaultParameters()
function to restore default parameters of EPOS2.
void enableController()
function to facititate transitions from the start of the controller to switch it on ...
void saveParameters()
function to save all parameters in EEPROM
void close()
Disconnects hardware.
Implementation of a driver for EPOS2 Motor Controller.
void init()
Connects hardware.
void setHome()
function to set a Home position with user interaction
long getTargetProfilePosition()
function to GET the target position
void throwAction(char action)
throw an action set by user
long readVersionHardware()
function to read the hardware version
long readEncoderCounter()
function to read the Encoder Counter
long readFollowingError()
function to read the Following Error
int32_t readPosition()
function to read motor position
void doMovement(char type)
Starts a motor movement.
void setProfileData(long vel, long maxvel, long acc, long dec, long qsdec, long maxacc, long type)
function to SET all data of the velocity profile
void stopVelocity()
function to stop the motor in velocity mode
void setControlParameters(long cp, long ci, long vp, long vi, long vspf, long pp, long pi, long pd, long pv, long pa)
function to set all control parameters
void setTargetVelocity(long velocity)
function to SET the target velocity
long readVelocity()
function to read motor average velocity
void startProfileVelocity()
[OPMODE=profile_velocity] function to move the motor in a velocity
long getTargetVelocity()
function to GET the target velocity This function gets the target velocity of velocity operation mode...
bool isTargetReached()
function to know if the motor has reached the target position or velocity
long readVelocityActual()
function to read velocity sensor actual
void getMovementInfo()
prints information about movement
int main(int argc, char **argv)
Programa de prova per a obtenir escaneigs i posicions del motor.
void setTargetProfilePosition(long position)
function to SET the target position