Ignore:
Timestamp:
05/09/09 13:48:12 (15 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/devdrv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/devdrv/dkc.cc

    r9435 r9439  
    2222    fStatus(0), fStatusDKC(0), fStatusPdo3(0xff), fArmed(false),
    2323    fReport(NULL),fLabel(NULL),fUpdPos(0)
    24 {
    25 }
    26 
    27 Dkc::~Dkc()
    2824{
    2925}
     
    165161    {
    166162    case 0x1000:
    167         if (subidx==1)
    168         {
    169             gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl;
    170             fArmed = val==1;
    171         }
     163        gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl;
     164        fArmed = val==1;
    172165        return;
    173166
    174167    case 0x1003:
    175168        // FIXME, see Init
    176         if (subidx!=2)
    177             return;
    178169        gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << hex << val << dec << endl;
    179170        CheckErrorDKC(val);
     
    196187
    197188    case 0x6004:
    198         if (subidx==0)
    199         {
    200             fPdoPos1 = (LWORDS_t)val;
    201             fPdoTime1.Set(tv);
    202             fHasChangedPos1 = true;
    203         }
    204         if (subidx==1)
    205         {
    206             fPdoPos2 = (LWORDS_t)val;
    207             fPdoTime2.Set(tv);
    208             fHasChangedPos2 = true;
    209         }
     189        fPdoPos1 = (LWORDS_t)val;
     190        fPdoTime1.Set(tv);
     191        fHasChangedPos1 = true;
     192        return;
     193
     194    case 0x6005:
     195        fPdoPos2 = (LWORDS_t)val;
     196        fPdoTime2.Set(tv);
     197        fHasChangedPos2 = true;
    210198        return;
    211199
     
    246234    {
    247235    case 0x1000:
    248         switch (subidx)
    249         {
    250         case 1:
    251             //lout << ddev(MLog::eGui);
    252             gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl;
    253             //lout << edev(MLog::eGui);
    254             return;
    255         }
    256         break;
     236        gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl;
     237        return;
     238
     239    case 0x1001:
     240        gLog << inf2 << "- " << GetNodeName() << ": PDOs requested." << endl;
     241        return;
    257242
    258243    case 0x2002:
    259         //lout << ddev(MLog::eGui);
    260244        gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl;
    261         //lout << edev(MLog::eGui);
    262245        return;
    263246
    264247    case 0x2003:
    265         //lout << ddev(MLog::eGui);
    266248        gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl;
    267         //lout << edev(MLog::eGui);
    268249        return;
    269250
    270251    case 0x3006:
    271         switch (subidx)
    272         {
    273         case 0:
    274             //lout << ddev(MLog::eGui);
    275             gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl;
    276             //lout << edev(MLog::eGui);
    277             return;
    278 
    279         case 1:
    280             /*
    281              lout << ddev(MLog::eGui);
    282              lout << "- Velocity set (" << GetNodeName() << ")" << endl;
    283              lout << edev(MLog::eGui);
    284              */
    285             return;
    286         }
    287         break;
     252        gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl;
     253        return;
     254
     255    case 0x3007:
     256        //gLog << inf2 << "- Velocity set (" << GetNodeName() << ")" << endl;
     257        return;
    288258
    289259    case 0x4000:
     
    292262
    293263    case 0x6000:
    294         //lout << ddev(MLog::eGui);
    295264        gLog << inf2 << "- " << GetNodeName() << ": Rotation direction set." << endl;
    296         //lout << edev(MLog::eGui);
    297265        return;
    298266
    299267    case 0x6002:
    300         //lout << ddev(MLog::eGui);
    301         gLog << inf2 << "- " << GetNodeName() << ": Velocitz resolution set." << endl;
    302         //lout << edev(MLog::eGui);
     268        gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution set." << endl;
    303269        return;
    304270
    305271    case 0x6004:
    306         switch (subidx)
    307         {
    308         case 0:
    309             //lout << ddev(MLog::eGui);
    310             gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;
    311             fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    312             //lout << edev(MLog::eGui);
    313             return;
    314 
    315         case 1:
    316             //lout << ddev(MLog::eGui);
    317             gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;
    318             fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    319             //lout << edev(MLog::eGui);
    320             return;
    321         }
    322         break;
    323 
    324 
    325     }
     272        gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;
     273        fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
     274        return;
     275
     276    case 0x6005:
     277        gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;
     278        fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
     279        return;
     280    }
     281
    326282    NodeDrv::HandleSDOOK(idx, subidx, data, tv);
    327283}
     
    348304}
    349305
    350 void Dkc::StartNode()
    351 {
    352     //
    353     // Switch node from pre-operational state to operational state
    354     // (This is not CANOpen compatible)
    355     // After this the MACS will react on real movement commands.
    356     //
    357     gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl;
    358     SendSDO(0x1000, 1, (LWORD_t)1);
    359     WaitForSdo(0x1000, 1);
    360 }
    361 
    362306void Dkc::Arm()
    363307{
    364     StartNode();
     308    gLog << inf2 << "- " << GetNodeName() << ": Arming node." << endl;
     309    SendSDO(0x1000, (LWORD_t)1);
     310    WaitForSdo(0x1000);
    365311}
    366312
    367313void Dkc::Disarm()
    368314{
    369     gLog << inf2 << "- " << GetNodeName() << ": Stopping Node." << endl;
    370     SendSDO(0x1000, 1, (LWORD_t)0);
    371     WaitForSdo(0x1000, 1);
     315    gLog << inf2 << "- " << GetNodeName() << ": Disarming Node." << endl;
     316    SendSDO(0x1000, (LWORD_t)0);
     317    WaitForSdo(0x1000);
    372318}
    373319
     
    385331    //
    386332    gLog << inf2 << "- " << GetNodeName() << ": Requesting Error[0]." << endl;
    387     RequestSDO(0x1003, 2);
    388     WaitForSdo(0x1003, 2);
     333    RequestSDO(0x1003);
     334    WaitForSdo(0x1003);
    389335
    390336    /*
     
    404350    ReqVelMax(); // Init fVelMax
    405351
     352    // Request to send all PDOs at least once
     353    ReqPDOs();
     354
    406355#ifdef EXPERT
    407     StartNode();
     356    Arm();
    408357#endif
    409358
    410359    gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl;
    411     RequestSDO(0x1000, 1);
    412     WaitForSdo(0x1000, 1);
     360    RequestSDO(0x1000);
     361    WaitForSdo(0x1000);
    413362}
    414363
     
    422371}
    423372
     373void Dkc::ReqPDOs()
     374{
     375    gLog << inf2 << "- " << GetNodeName() << ": Requesting all PDOs." << endl;
     376
     377    SendSDO(0x1001, (LWORD_t)1);
     378    WaitForSdo(0x1001);
     379}
     380
    424381void Dkc::ReqPos1()
    425382{
    426383    gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 1." << endl;
    427     RequestSDO(0x6004, 0);
    428     WaitForSdo(0x6004, 0);
     384    RequestSDO(0x6004);
     385    WaitForSdo(0x6004);
    429386}
    430387
     
    432389{
    433390    gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 2." << endl;
    434     RequestSDO(0x6004, 1);
    435     WaitForSdo(0x6004, 1);
     391    RequestSDO(0x6005);
     392    WaitForSdo(0x6005);
    436393}
    437394
     
    460417{
    461418    gLog << dbg << "- Setting acceleration to: " << acc << endl;
    462     SendSDO(0x2003, 0, acc);  // acceleration
    463     WaitForSdo(0x2003, 0);
    464 }
    465 /*
    466 void Dkc::SetDeceleration(LWORD_t dec)
    467 {
    468     gLog << dbg << "- Setting deceleration to: " << dec << endl;
    469     SendSDO(0x2003, 1, dec);
    470     WaitForSdo(0x2003, 1);
    471 }
    472 */
     419    SendSDO(0x2003, acc);  // acceleration
     420    WaitForSdo(0x2003);
     421}
     422
    473423void Dkc::SetRpmMode(BYTE_t mode)
    474424{
     
    476426    // SetRpmMode(FALSE) stop the motor, but lets the position control unit on
    477427    //
    478     SendSDO(0x3006, 0, mode ? string('s','t','r','t') : string('s','t','o','p'));
    479     WaitForSdo(0x3006, 0);
     428    SendSDO(0x3006, mode ? string('s','t','r','t') : string('s','t','o','p'));
     429    WaitForSdo(0x3006);
    480430}
    481431
    482432void Dkc::SetRpmVelocity(LWORDS_t cvel)
    483433{
    484     SendSDO(0x3006, 1, (LWORD_t)cvel);
    485     WaitForSdo(0x3006, 1);
     434    SendSDO(0x3007, (LWORD_t)cvel);
     435    WaitForSdo(0x3007);
    486436}
    487437
     
    496446
    497447    gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORDS_t)pos << " ticks." << endl;
    498     SendSDO(0x6004, 1, (LWORD_t)pos);
     448    SendSDO(0x6005, (LWORD_t)pos);
    499449    fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    500450}
     
    510460
    511461    gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << (LWORDS_t)pos << " ticks." << endl;
    512     SendSDO(0x6004, 0, (LWORD_t)pos);
     462    SendSDO(0x6004, (LWORD_t)pos);
    513463    fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    514464}
     
    526476
    527477    gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << p << " ticks." << endl;
    528     SendSDO(0x6004, 0, p);
     478    SendSDO(0x6004, p);
    529479    fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    530 }
    531 
    532 void Dkc::StartVelSync()
    533 {
    534     //
    535     // The syncronization mode is disabled by a 'MOTOR STOP'
    536     // or by a positioning command (POSA, ...)
    537     //
    538     gLog << inf2 << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;
    539     SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));
    540     WaitForSdo(0x3007, 0);
    541 }
    542 
    543 void Dkc::StartPosSync()
    544 {
    545     //
    546     // The syncronization mode is disabled by a 'MOTOR STOP'
    547     // or by a positioning command (POSA, ...)
    548     //
    549     gLog << inf2 << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl;
    550     SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));
    551     WaitForSdo(0x3007, 1);
    552480}
    553481
  • trunk/MagicSoft/Cosy/devdrv/dkc.h

    r9132 r9439  
    7373public:
    7474    Dkc(const BYTE_t nodeid, const char *name=NULL);
    75     virtual ~Dkc();
     75    virtual ~Dkc() { }
    7676
    7777    static LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
     
    8484                 BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0);
    8585
     86    void ReqPDOs();
    8687    void ReqPos1();
    8788    void ReqPos2();
     
    9192    void ReqVelMax();
    9293    void SetAcceleration(LWORD_t acc);
    93     void SetDeceleration(LWORD_t dec);
     94//    void SetDeceleration(LWORD_t dec);
    9495    void SetVelocity(LWORD_t vel);
    9596    void SetVelocityRel(Double_t vel);
    9697    void SetRpmMode(BYTE_t mode=TRUE);
    9798    void SetRpmVelocity(LWORDS_t cvel);
    98     void SetPDO1On(BYTE_t flag=TRUE);
    99 
    100     void StartVelSync();
    101     void StartPosSync();
    10299
    103100    void StartRelPos(LWORDS_t pos);
    104101    void StartAbsPos(LWORDS_t pos);
    105102    void StartAbsPosRev(Double_t pos);
    106 
    107     void StartNode();
    108103
    109104    bool IsArmed() const { return fArmed; }
Note: See TracChangeset for help on using the changeset viewer.