Ignore:
Timestamp:
02/15/08 21:42:55 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r8835 r8863  
    44
    55#include "network.h"
     6
    67#include "MLogManip.h"
     8
     9#include "MString.h"
    710
    811ClassImp(Macs);
     
    4245}
    4346
     47TString Macs::EvalStatusDKC(UInt_t stat) const
     48{
     49    switch (stat)
     50    {
     51    case 0: return "offline";
     52    case 0xa000:
     53    case 0xa001:
     54    case 0xa002:
     55    case 0xa003: return MString::Format("Communication phase %d", stat&0xf);
     56    case 0xa010: return "Drive HALT";
     57    case 0xa012: return "Control and power section ready for operation";
     58    case 0xa013: return "Ready for power on";
     59    case 0xa100: return "Drive in Torque mode";
     60    case 0xa101: return "Drive in Velocity mode";
     61    case 0xa102: return "Position control mode with encoder 1";
     62    case 0xa103: return "Position control mode with encoder 2";
     63    case 0xa104: return "Lagless position control mode with encoder 1";
     64    case 0xa105: return "Lagless position control mode with encoder 2";
     65    case 0xa106: return "Drive controlled interpolated positioning with encoder 1";
     66    case 0xa107: return "Drive controlled interpolated positioning with encoder 2";
     67    case 0xa108: return "Drive controlled interpolated absolute positioning lagless with encoder 1";
     68    case 0xa109: return "Drive controlled interpolated absolute positioning lagless with encoder 2";
     69    case 0xa146: return "Drive controlled interpolated relative positioning with encoder 1";
     70    case 0xa147: return "Drive controlled interpolated relative positioning with encoder 2";
     71    case 0xa148: return "Drive controlled interpolated relative positioning lagless with encoder 1";
     72    case 0xa149: return "Drive controlled interpolated relative positioning lagless with encoder 2";
     73    case 0xa208: return "Jog mode positive";
     74    case 0xa218: return "Jog mode negative";
     75    case 0xa400: return "Automatic drive check and adjustment";
     76    case 0xa401: return "Drive decelerating to standstill";
     77    case 0xa800: return "Unknown operation mode";
     78    case 0xc217: return "Motor encoder reading error";
     79    case 0xc218: return "Shaft encoder reading error";
     80    case 0xc220: return "Motor encoder initialization error";
     81    case 0xc221: return "Shaft encoder initialization error";
     82    case 0xc400: return "Switching to parameter mode";
     83    case 0xc500: return "Error reset";
     84    case 0xe225: return "Motor overload";
     85    case 0xe250: return "Drive overtemp warning";
     86    case 0xe251: return "Motor overtemp warning";
     87    case 0xe252: return "Bleeder overtemp warning";
     88    case 0xe834: return "Emergency-Stop";
     89    case 0xe843: return "Positive end-switch activated";
     90    case 0xe844: return "Negative end-switch activated";
     91    case 0xf218: return "Amplifier overtemp shutdown";
     92    case 0xf219: return "Motor overtemp shutdown";
     93    case 0xf220: return "Bleeder overload shutdown";
     94    case 0xf221: return "Motor temperature surveillance defective";
     95    case 0xf224: return "Maximum breaking time exceeded";
     96    case 0xf228: return "Excessive control deviation";
     97    case 0xf269: return "Error during release of the motor holding brake";
     98    case 0xf276: return "Absolute encoder out of allowed window";
     99    case 0xf409: return "Bus error on Profibus interface";
     100    case 0xf434: return "Emergency-Stop";
     101    case 0xf629: return "Positive sw end-switch";
     102    case 0xf630: return "Negative sw end-switch";
     103    case 0xf634: return "Emergency-Stop";
     104    case 0xf643: return "Positive hw end-switch";
     105    case 0xf644: return "Negative hw end-switch";
     106    case 0xf870: return "24V DC error.";
     107    case 0xf878: return "Velocity loop error";
     108    }
     109    return "unknown";
     110}
     111
     112Bool_t Macs::EvalStatus(LWORD_t val) const
     113{
     114    const Int_t errnum = val&0xffff;
     115    const Int_t errinf = val>>16;
     116
     117    if (errnum!=0xff)
     118        return errnum==0;
     119
     120    const Int_t type = errinf&0xf000;
     121
     122    gLog << all << "DKC reports: ";
     123
     124    switch (type)
     125    {
     126    case 0xf000: gLog << "ERROR"; break;
     127    case 0xe000: gLog << "WARNING"; break;
     128    case 0xa000: gLog << "Status"; break;
     129    default:     gLog << "Unknown"; break;
     130    }
     131
     132    gLog << " (" << MString::Format("%X", errinf) << "): " << EvalStatusDKC(errinf);
     133
     134    gLog << (type==0xf000 || type==0xe000 ? "!" : ".") << endl;
     135
     136    return type==0xa000;
     137}
     138
    44139void Macs::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, const timeval_t &tv)
    45140{
     
    52147        if (subidx!=2)
    53148            return;
    54         gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << dec << val << endl;
    55         SetError(val);
     149        gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << hex << val << dec << endl;
     150        SetError(EvalStatus(val) ? 0 : val);
    56151        return;
    57152
     
    122217
    123218    case 0x6002:
    124         gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " ticks/min" << endl;
     219        gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " (100%)" << endl;
    125220        fVelRes = val;
    126221        return;
    127222
    128223    case 0x6501:
    129         gLog << inf2 << "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks/min" << endl;
     224        gLog << inf2 << "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks" << endl;
    130225        fRes = val;
    131226        return;
     
    362457    if (fSoftVersion<0x00000045) // 00.69
    363458    {
    364         gLog << err << GetNodeName() << " - Software Version too old!" << endl;
     459        gLog << err << GetNodeName() << " - Software Version " << 0.01*fSoftVersion << " too old!" << endl;
    365460        SetZombie();
    366461        return;
     
    471566    SendSDO(0x2002, vel);     // velocity
    472567    WaitForSdo(0x2002, 0);
     568    cout << "SET VEL: " << vel << endl;
    473569}
    474570
     
    477573    SendSDO(0x2003, 0, acc);  // acceleration
    478574    WaitForSdo(0x2003, 0);
     575    cout << "SET ACC: " << acc << endl;
    479576}
    480577
     
    483580    SendSDO(0x2003, 1, dec);  // acceleration
    484581    WaitForSdo(0x2003, 1);
     582    cout << "SET DEC: " << dec << endl;
    485583}
    486584
     
    503601{
    504602    SendSDO(0x6004, 1, (LWORD_t)pos);
     603    cout << "REL POS: " << (LWORD_t)pos << endl;
    505604}
    506605
     
    508607{
    509608    SendSDO(0x6004, 0, (LWORD_t)pos);
     609    cout << "ABS POS: " << (LWORD_t)pos << endl;
    510610}
    511611
     
    585685    LWORDS_t errinf = (data[4]<<24) | (data[5]<<16) | (data[6]<<8) | data[7];
    586686
    587     //
     687    // Check if the DKC changed its status message
     688    if (errnum==0xff && (errinf&0xf000)<=0xe000)
     689    {
     690        EvalStatus(errnum, errinf);
     691        SetError(0);
     692        return;
     693    }
     694
     695    // Check if MACS report error occursion.
    588696    // errnum==0 gives a sudden information that something happened. Now the
    589697    // microcontroller is running inside its interrupt procedure which
     
    606714    if (GetError()>0)
    607715    {
    608         gLog << warn << GetNodeName() << ": WARNING! Error #" << GetError() << " unhandled (not cleared) by software." << endl;
     716        gLog << warn << GetNodeName() << ": WARNING! Previous error #" << GetError() << " unhandled (not cleared) by software." << endl;
    609717
    610718        //
     
    724832        return;
    725833
     834    case 0xff:
     835        EvalStatus(errnum, errinf);
     836        return;
     837
    726838    default:
    727         gLog << "Error Nr. " << errnum << ", " << errinf << endl;
     839        gLog << "Error Nr. " << dec << errnum << ", " << errinf << endl;
    728840    }
    729841}
     
    800912        DelError();
    801913        return;
     914
     915    case 0xff:
     916        gLog << err << "DKC error! Go and check what is going on!" << endl;
     917        DelError();
     918        return;
    802919/*
    803920    case 101:
     
    870987    gLog << inf2 << "- " << GetNodeName() << ": Hostguarding stopped." << endl;
    871988}
    872 
Note: See TracChangeset for help on using the changeset viewer.