Ignore:
Timestamp:
02/20/08 19:39:13 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/devdrv
Files:
2 edited

Legend:

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

    r8864 r8865  
    3434    : NodeDrv(nodeid, name), fMacId(2*nodeid+1),
    3535    fPos(0), fPdoPos(0), fPosActive(0), fRpmActive(0),
    36     fStatusPdo3(0xff)
     36    fStatusPdo3(0xff), fArmed(false)
    3737{
    3838//    fTimeout = new TTimer(this, 100); //, kFALSE); // 100ms, asynchronous
     
    7272    case 0xa149: return "Drive controlled interpolated relative positioning lagless with encoder 2";
    7373    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";
    7575    case 0xa208: return "Jog mode positive";
    7676    case 0xa218: return "Jog mode negative";
     
    9191    case 0xe264: return "Target position out of numerical range";
    9292    case 0xe834: return "Emergency-Stop";
     93    case 0xe842: return "Both end-switches activated";
    9394    case 0xe843: return "Positive end-switch activated";
    9495    case 0xe844: return "Negative end-switch activated";
     
    150151    switch (idx)
    151152    {
     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
    152161    case 0x1003:
    153162        // FIXME, see Init
     
    382391            //lout << ddev(MLog::eGui);
    383392            gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;
     393            fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    384394            //lout << edev(MLog::eGui);
    385395            return;
     
    388398            //lout << ddev(MLog::eGui);
    389399            gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;
     400            fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
    390401            //lout << edev(MLog::eGui);
    391402            return;
     
    428439    gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl;
    429440    SendSDO(0x1000, 1, (LWORD_t)1);
     441    WaitForSdo(0x1000, 1);
     442}
     443
     444void Macs::Arm()
     445{
     446    StartNode();
     447}
     448
     449void Macs::Disarm()
     450{
     451    gLog << inf2 << "- " << GetNodeName() << ": Stopping Node." << endl;
     452    SendSDO(0x1000, 1, (LWORD_t)0);
    430453    WaitForSdo(0x1000, 1);
    431454}
     
    490513    //StartHostGuarding();
    491514
    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);
    493521}
    494522/*
     
    571599void Macs::SetVelocity(LWORD_t vel)
    572600{
     601    gLog << dbg << "- Setting velocity to: " << vel << endl;
    573602    SendSDO(0x2002, vel);     // velocity
    574603    WaitForSdo(0x2002, 0);
    575     cout << "SET VEL: " << vel << endl;
    576604}
    577605
    578606void Macs::SetAcceleration(LWORD_t acc)
    579607{
     608    gLog << dbg << "- Setting acceleration to: " << vel << endl;
    580609    SendSDO(0x2003, 0, acc);  // acceleration
    581610    WaitForSdo(0x2003, 0);
    582     cout << "SET ACC: " << acc << endl;
    583611}
    584612
    585613void Macs::SetDeceleration(LWORD_t dec)
    586614{
    587     SendSDO(0x2003, 1, dec);  // acceleration
     615    gLog << dbg << "- Setting deceleration to: " << vel << endl;
     616    SendSDO(0x2003, 1, dec);
    588617    WaitForSdo(0x2003, 1);
    589     cout << "SET DEC: " << dec << endl;
    590618}
    591619
     
    607635void Macs::StartRelPos(LWORDS_t pos)
    608636{
     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;
    609644    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
    611646}
    612647
    613648void Macs::StartAbsPos(LWORDS_t pos)
    614649{
     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;
    615656    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
    617658}
    618659
     
    681722    fInControl = data[3]&0x40; // motor uncontrolled
    682723              // data[3]&0x80; // axis resetted (after errclr, motor stop, motor on)
     724
     725    fArmed     = data[2]&kIsArmed==kIsArmed;
    683726
    684727    fStatus = data[3];
  • trunk/MagicSoft/Cosy/devdrv/macs.h

    r8864 r8865  
    3434
    3535    BYTE_t   fStatusPdo3;
     36
     37    bool fArmed;
    3638
    3739    void Init();
     
    7375    enum
    7476    {
     77        kIsArmed   = BIT(0),    // Macs will accept movement commands
    7578        kNotMoving = BIT(0),    // motor not moving
    7679        kPosActive = BIT(1),    // positioning active
     
    121124    void StartNode();
    122125
     126    bool IsArmed() const { return fArmed; }
     127    void Arm();
     128    void Disarm();
     129
    123130    int IsPositioning() const { return fPosActive; }
    124131    BYTE_t GetStatus() const { return fStatus; }
Note: See TracChangeset for help on using the changeset viewer.