Changeset 910 for trunk/MagicSoft/Cosy/devdrv
- Timestamp:
- 08/15/01 12:52:38 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy/devdrv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/macs.cc
r808 r910 188 188 } 189 189 190 void Macs::SetHome(LWORDS_t pos )190 void Macs::SetHome(LWORDS_t pos, WORD_t maxtime) 191 191 { 192 192 lout << "- Driving #" << (int)GetId() << " to home position, Offset=" << dec << pos << endl; … … 195 195 196 196 // home also defines the zero point of the system 197 // maximum time allowd for home drive: 25.000ms 197 198 SendSDO(0x3001, string('h','o','m','e')); // home 198 WaitForSdo(0x3001 );199 WaitForSdo(0x3001, 0, maxtime*1000); 199 200 lout << "- Home position of #" << (int)GetId() << " reached. " << endl; 200 201 … … 253 254 } 254 255 255 void Macs::SetSyncMode() 256 { 257 lout << "- Setting Sync Mode #" << (int)GetId() << endl; 258 SendSDO(0x3007, string('S', 'Y', 'N', 'C')); 259 WaitForSdo(0x3007); 256 void Macs::StartVelSync() 257 { 258 // 259 // The syncronization mode is disabled by a 'MOTOR STOP' 260 // or by a positioning command (POSA, ...) 261 // 262 lout << "- Setting Vel Sync Mode #" << (int)GetId() << endl; 263 SendSDO(0x3007, 0, string('S', 'Y', 'N', 'C')); 264 WaitForSdo(0x3007, 0); 265 } 266 267 void Macs::StartPosSync() 268 { 269 // 270 // The syncronization mode is disabled by a 'MOTOR STOP' 271 // or by a positioning command (POSA, ...) 272 // 273 lout << "- Setting Pos Sync Mode #" << (int)GetId() << endl; 274 SendSDO(0x3007, 1, string('S', 'Y', 'N', 'C')); 275 WaitForSdo(0x3007, 1); 260 276 } 261 277 /* -
trunk/MagicSoft/Cosy/devdrv/macs.h
r808 r910 2 2 #define MACS_H 3 3 4 #include "timer.h"5 4 #include "nodedrv.h" 5 #include "base/timer.h" 6 6 7 7 class Macs : public NodeDrv … … 51 51 void ReqAxEnd(); 52 52 void ReqVelRes(); 53 void SetHome(LWORDS_t pos=0 );53 void SetHome(LWORDS_t pos=0, WORD_t maxtime=25); 54 54 void SetAcceleration(LWORD_t acc); 55 55 void SetDeceleration(LWORD_t dec); 56 56 void SetVelocity(LWORD_t vel); 57 57 void SetNoWait(BYTE_t flag=TRUE); 58 void SetSyncMode();59 58 void SetRpmMode(BYTE_t mode=TRUE); 60 59 void SetRpmVelocity(LWORDS_t cvel); … … 64 63 65 64 void EnableEndswitches(bool neg=true, bool pos=true); 65 66 void StartVelSync(); 67 void StartPosSync(); 66 68 67 69 void StartRelPos(LWORDS_t pos); -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r732 r910 18 18 // Show information 19 19 // 20 pthread_create(&fThread, NULL, MapUpdateThread, this);20 // pthread_create(&fThread, NULL, MapUpdateThread, this); 21 21 22 22 } … … 24 24 ShaftEncoder::~ShaftEncoder() 25 25 { 26 pthread_cancel(fThread);26 // pthread_cancel(fThread); 27 27 } 28 28 … … 91 91 cout << endl; 92 92 } 93 93 /* 94 94 void *ShaftEncoder::MapUpdateThread(void *data) 95 95 { … … 106 106 return NULL; 107 107 } 108 108 */ 109 void ShaftEncoder::DisplayVal() 110 { 111 static LWORDS_t pos; // ticks 112 static WORDS_t vel; // ticks per 5ms 113 static WORDS_t acc; // ticks per 25ms^2 114 115 char text[21]; 116 117 if (fPos!=pos) 118 { 119 sprintf(text, "%ld", fPos); 120 fLabel[0]->SetText(new TGString(text)); 121 } 122 123 if (fVel!=vel) 124 { 125 sprintf(text, "%d", fVel); 126 fLabel[1]->SetText(new TGString(text)); 127 } 128 129 if (fAcc!=acc) 130 { 131 sprintf(text, "%d", fAcc); 132 fLabel[2]->SetText(new TGString(text)); 133 } 134 } 135 /* 109 136 void ShaftEncoder::UpdateThread() 110 137 { 138 return; 111 139 // 112 140 // check for a running thread and lock mutex 113 141 // 114 char text[21];115 142 116 143 // … … 122 149 while (1) 123 150 { 124 WaitForNextPdo1(); 151 usleep(40000); 152 //WaitForNextPdo1(); 125 153 126 154 // 127 155 // Update information 128 156 // 129 sprintf(text, "%ld", fPos); 130 fLabel[0]->SetText(new TGString(text)); 131 132 sprintf(text, "%d", fVel); 133 fLabel[1]->SetText(new TGString(text)); 134 135 sprintf(text, "%d", fAcc); 136 fLabel[2]->SetText(new TGString(text)); 157 137 158 138 159 // 139 160 // make updated information visible 140 161 // 141 gSystem->ProcessEvents();142 } 143 } 144 162 //gSystem->ProcessEvents(); ----> MCosy::GuiThread 163 } 164 } 165 */ 145 166 void ShaftEncoder::HandlePDOType0(BYTE_t *data) 146 167 { -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r732 r910 23 23 Timer fTime; 24 24 25 pthread_t fThread; 26 27 static void *MapUpdateThread(void *se); 28 void UpdateThread(); 25 // pthread_t fThread; 26 // static void *MapUpdateThread(void *se); 27 // void UpdateThread(); 29 28 30 29 void HandlePDOType0(BYTE_t *data); … … 58 57 59 58 void SetPreset(LWORD_t pre=0); 59 60 void DisplayVal(); 60 61 }; 61 62
Note:
See TracChangeset
for help on using the changeset viewer.