- Timestamp:
- 01/17/13 16:54:13 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/ShutterController/ShutterController.ino
r14359 r14778 23 23 // Define MAC and IP addresses 24 24 byte _mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x5C, 0x91 }; 25 25 //byte _mac[] = { 0x80, 0x49, 0x71, 0x0f, 0x80, 0xd0 }; 26 26 #if !defined USE_DHCP_FOR_IP_ADDRESS 27 27 // ip represents the fixed IP address to use if DHCP is disabled. … … 34 34 // pushing coefficient ~100 Kg/A 35 35 const double _ZeroCurrent PROGMEM = 0.25; // [A] 36 const double _CurrentPushingLimit PROGMEM = 0.7 0; // 0.7-0.5 = 0.2 -> 20 +/- 5 kg36 const double _CurrentPushingLimit PROGMEM = 0.75; // 0.7-0.5 = 0.2 -> 20 +/- 5 kg 37 37 const double _OverCurrent PROGMEM = 1.50; // 1.5-0.5 = 1 -> 100 +/- 5 kg 38 38 … … 40 40 const int _StartPointLimit = 70; 41 41 const int _EndPoint = 1024; 42 const int _EndPointLimit = 7 40;42 const int _EndPointLimit = 775; // This must me 740 for the mockup and >770 for the FACT shutter 43 43 44 44 // Define Lid Status levels and labels … … 138 138 "<button name=\"Button6\" value=\"valueButton6\" type=\"submit\">Close Lid</button><p/>" 139 139 "<span id=\"cur1\" value=\"\002\"> Motor Current 1 = \002 A </span><p/><span id=\"cur2\" value=\"\002\"> Motor Current 2 = \002 A </span><p/>" 140 "<span id=\"pos1\" value=\"\002\"> Hall Sensor 1 = \002 ADC ounts </span><p/><span id=\"pos2\" valus=\"\002\"> Hall Sensor 2 = \002 ADC counts</span><p/>"140 "<span id=\"pos1\" value=\"\002\"> Hall Sensor 1 = \002 ADC counts </span><p/><span id=\"pos2\" value=\"\002\"> Hall Sensor 2 = \002 ADC counts</span><p/>" 141 141 "</form></p>"; 142 142 //<br/></body></html> … … 277 277 Serial.println(Ethernet.localIP()); 278 278 279 // Serial.print("Gateway IP address is ");280 // Serial.println(ip_to_str(gatewayAddr));281 282 // Serial.print("DNS IP address is ");283 // Serial.println(ip_to_str(dnsAddr));284 279 285 280 … … 625 620 void sendPage(EthernetClient & client, int nUriIndex, BUFFER & requestContent) 626 621 { 627 622 // Read Sensor values for every page reload 623 ReadSensorM(-1,100); 624 ReadCurrentM(-1,100); 625 628 626 #ifdef DEBUG 629 627 Serial.print("sendPage("); … … 957 955 double travel; 958 956 959 960 961 962 957 // only one reading to define the position is not sufficient 958 // current_position = ReadSensor(motor); 959 960 // Calculate average final position 963 961 double tmp=0; 964 962 double tmpM=0; … … 974 972 tmpS = sqrt(tmpS/SAMPLES - tmpM*tmpM); 975 973 976 Serial.print(" - The current position of the actuator is ");977 Serial.print(tmpM,3);978 Serial.print( " +/- " );979 Serial.println(tmpS,3);980 974 981 975 int tmpS_int = (int) tmpS; … … 991 985 992 986 original_position = current_position; 993 err_original_position = err_current_position; 994 995 Serial.print(" - The corrected position of the actuator is "); 996 Serial.print(current_position); 997 Serial.print( " +/- " ); 998 Serial.println(err_current_position); 999 1000 987 err_original_position = err_current_position; 988 1001 989 // calculate the travel needed to reach the target position 1002 990 travel = target_position - current_position; … … 1009 997 Serial.print(target_position,3); 1010 998 Serial.print(" - Travel distance = "); 1011 Serial.print(travel,3); 999 Serial.println(travel,3); 1000 1001 Serial.print(" - The current position of the actuator is "); 1002 Serial.print(tmpM,3); 1003 Serial.print( " +/- " ); 1004 Serial.println(tmpS,3); 1005 1006 Serial.print(" - The corrected position of the actuator is "); 1007 Serial.print(current_position); 1008 Serial.print( " +/- " ); 1009 Serial.println(err_current_position); 1010 1012 1011 1013 1012 // [IF] the travel is bigger than +2*(absolute position error) try to move out the motor … … 1223 1222 Serial.println(_StatusLabel[_LidStatus[motor]]); 1224 1223 1225 Serial.print(" availableMemory()=");1224 Serial.print("AvailableMemory()="); 1226 1225 Serial.println(availableMemory()); 1227 1226 … … 1266 1265 Serial.println("Action->ReadSensorsM()"); 1267 1266 #endif 1268 _sensorValue[motor]=0;1269 1267 switch (motor){ 1268 case -1: // Read all of them 1269 _sensorValue[0] = 0; 1270 _sensorValue[1] = 0; 1271 for (int j=0;j<samples;j++){ 1272 _sensorValue[0] += analogRead(A2); 1273 _sensorValue[1] += analogRead(A3); 1274 } 1275 _sensorValue[0]/=samples; 1276 _sensorValue[1]/=samples; 1277 return -1; 1278 1270 1279 case 0: 1280 _sensorValue[motor]=0; 1271 1281 for (int j=0;j<samples;j++) 1272 1282 _sensorValue[motor] += analogRead(A2);//*_ADC2V - _Voffset; //*_Compensation; 1283 _sensorValue[motor] /= samples; 1284 return _sensorValue[motor]; // Actuator 1 position 1285 1273 1286 case 1: 1287 _sensorValue[motor]=0; 1274 1288 for (int j=0;j<samples;j++) 1275 1289 _sensorValue[motor] += analogRead(A3);//*_ADC2V - _Voffset;//_Compensation; 1276 }1277 1278 _sensorValue[motor] /= samples;1279 return _sensorValue[motor]; // Actuator 1 position1290 _sensorValue[motor] /= samples; 1291 return _sensorValue[motor]; // Actuator 1 position 1292 } 1293 1280 1294 } 1281 1295 … … 1301 1315 1302 1316 double ReadCurrentM(int motor, int samples){ 1303 _currentValue[motor] = 0;1304 1317 switch (motor){ 1318 case -1: // Read all of them 1319 _currentValue[0] = 0; 1320 _currentValue[1] = 0; 1321 for (int j=0;j<samples;j++){ 1322 _currentValue[0] += analogRead(A4)*_ADC2V/(_V2A*10.); 1323 _currentValue[1] += analogRead(A5)*_ADC2V/(_V2A*10.); 1324 } 1325 _currentValue[0]/=samples; 1326 _currentValue[1]/=samples; 1327 return -1; 1305 1328 case 0: 1329 _currentValue[motor] = 0; 1306 1330 for (int j=0;j<samples;j++) 1307 1331 _currentValue[motor] += analogRead(A4)*_ADC2V/(_V2A*10.); 1332 _currentValue[motor]/=samples; 1333 return _currentValue[motor]; 1308 1334 case 1: 1335 _currentValue[motor] = 0; 1309 1336 for (int j=0;j<samples;j++) 1310 1337 _currentValue[motor] += analogRead(A5)*_ADC2V/(_V2A*10.); 1311 } 1312 _currentValue[motor]/=samples; 1313 return _currentValue[motor]; 1338 _currentValue[motor]/=samples; 1339 return _currentValue[motor]; 1340 1341 } 1314 1342 1315 1343 }
Note:
See TracChangeset
for help on using the changeset viewer.