Changeset 8865 for trunk/MagicSoft/Cosy/devdrv
- Timestamp:
- 02/20/08 19:39:13 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy/devdrv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/macs.cc
r8864 r8865 34 34 : NodeDrv(nodeid, name), fMacId(2*nodeid+1), 35 35 fPos(0), fPdoPos(0), fPosActive(0), fRpmActive(0), 36 fStatusPdo3(0xff) 36 fStatusPdo3(0xff), fArmed(false) 37 37 { 38 38 // fTimeout = new TTimer(this, 100); //, kFALSE); // 100ms, asynchronous … … 72 72 case 0xa149: return "Drive controlled interpolated relative positioning lagless with encoder 2"; 73 73 case 0xa150: return "Drive controlled positioning with encoder 1"; 74 case 0xa151: return "Drive controlled positioning with encoder 2";74 case 0xa151: return "Drive controlled positioning with encoder 1, lagless"; 75 75 case 0xa208: return "Jog mode positive"; 76 76 case 0xa218: return "Jog mode negative"; … … 91 91 case 0xe264: return "Target position out of numerical range"; 92 92 case 0xe834: return "Emergency-Stop"; 93 case 0xe842: return "Both end-switches activated"; 93 94 case 0xe843: return "Positive end-switch activated"; 94 95 case 0xe844: return "Negative end-switch activated"; … … 150 151 switch (idx) 151 152 { 153 case 0x1000: 154 if (subidx==1) 155 { 156 gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl; 157 fArmed = val==1; 158 } 159 return; 160 152 161 case 0x1003: 153 162 // FIXME, see Init … … 382 391 //lout << ddev(MLog::eGui); 383 392 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 393 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 384 394 //lout << edev(MLog::eGui); 385 395 return; … … 388 398 //lout << ddev(MLog::eGui); 389 399 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 400 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 390 401 //lout << edev(MLog::eGui); 391 402 return; … … 428 439 gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl; 429 440 SendSDO(0x1000, 1, (LWORD_t)1); 441 WaitForSdo(0x1000, 1); 442 } 443 444 void Macs::Arm() 445 { 446 StartNode(); 447 } 448 449 void Macs::Disarm() 450 { 451 gLog << inf2 << "- " << GetNodeName() << ": Stopping Node." << endl; 452 SendSDO(0x1000, 1, (LWORD_t)0); 430 453 WaitForSdo(0x1000, 1); 431 454 } … … 490 513 //StartHostGuarding(); 491 514 492 StartNode(); 515 // REMOVE THIS AND LET CC START THE NODE 516 //StartNode(); 517 518 gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl; 519 RequestSDO(0x1000, 1); 520 WaitForSdo(0x1000, 1); 493 521 } 494 522 /* … … 571 599 void Macs::SetVelocity(LWORD_t vel) 572 600 { 601 gLog << dbg << "- Setting velocity to: " << vel << endl; 573 602 SendSDO(0x2002, vel); // velocity 574 603 WaitForSdo(0x2002, 0); 575 cout << "SET VEL: " << vel << endl;576 604 } 577 605 578 606 void Macs::SetAcceleration(LWORD_t acc) 579 607 { 608 gLog << dbg << "- Setting acceleration to: " << vel << endl; 580 609 SendSDO(0x2003, 0, acc); // acceleration 581 610 WaitForSdo(0x2003, 0); 582 cout << "SET ACC: " << acc << endl;583 611 } 584 612 585 613 void Macs::SetDeceleration(LWORD_t dec) 586 614 { 587 SendSDO(0x2003, 1, dec); // acceleration 615 gLog << dbg << "- Setting deceleration to: " << vel << endl; 616 SendSDO(0x2003, 1, dec); 588 617 WaitForSdo(0x2003, 1); 589 cout << "SET DEC: " << dec << endl;590 618 } 591 619 … … 607 635 void Macs::StartRelPos(LWORDS_t pos) 608 636 { 637 if (!fIsArmed) 638 { 639 gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl; 640 return; 641 } 642 643 gLog << dbg << GetNodeName() << ": Starting abolsute positioning to " << (LWORD_t)pos << " ticks." << endl; 609 644 SendSDO(0x6004, 1, (LWORD_t)pos); 610 cout << "REL POS: " << (LWORD_t)pos << endl;645 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 611 646 } 612 647 613 648 void Macs::StartAbsPos(LWORDS_t pos) 614 649 { 650 if (!fIsArmed) 651 { 652 gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl; 653 return; 654 } 655 gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORD_t)pos << " ticks." << endl; 615 656 SendSDO(0x6004, 0, (LWORD_t)pos); 616 cout << "ABS POS: " << (LWORD_t)pos << endl;657 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 617 658 } 618 659 … … 681 722 fInControl = data[3]&0x40; // motor uncontrolled 682 723 // data[3]&0x80; // axis resetted (after errclr, motor stop, motor on) 724 725 fArmed = data[2]&kIsArmed==kIsArmed; 683 726 684 727 fStatus = data[3]; -
trunk/MagicSoft/Cosy/devdrv/macs.h
r8864 r8865 34 34 35 35 BYTE_t fStatusPdo3; 36 37 bool fArmed; 36 38 37 39 void Init(); … … 73 75 enum 74 76 { 77 kIsArmed = BIT(0), // Macs will accept movement commands 75 78 kNotMoving = BIT(0), // motor not moving 76 79 kPosActive = BIT(1), // positioning active … … 121 124 void StartNode(); 122 125 126 bool IsArmed() const { return fArmed; } 127 void Arm(); 128 void Disarm(); 129 123 130 int IsPositioning() const { return fPosActive; } 124 131 BYTE_t GetStatus() const { return fStatus; }
Note:
See TracChangeset
for help on using the changeset viewer.