Changeset 890

Show
Ignore:
Timestamp:
09/14/10 01:40:17 (3 years ago)
Author:
atorf
Message:

* Prepared and updated MotorControl for new compiler, introducing version 2.2
* No code changes, just recompiling with new NBC/NXC compiler
* Updated batchfiles…
* Binary still needs to be compiled

Location:
trunk/tools/MotorControl
Files:
1 removed
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/tools/MotorControl/CompileAndTransferMotorControlToNXT.bat

    r776 r890  
    3131 
    3232echo. 
    33 echo   This program compiles and downloads MotorControl21.nxc 
     33echo   This program compiles and downloads MotorControl22.nxc 
    3434echo   to the NXT brick. Please connect a single NXT brick 
    3535echo   via a USB cable and turn it on. 
    36 echo   Make sure Firmware 1.26 (or higher) is installed on the NXT. 
     36echo   Make sure Firmware 1.28 (or higher) is installed on the NXT. 
    3737echo   After a successful download the NXT will beep once... 
    3838echo. 
     
    4444echo. 
    4545 
    46 nbc -d -S=usb -v=126 MotorControl21.nxc 
     46nbc -d -S=usb -v=126 MotorControl22.nxc 
    4747 
    4848 
  • trunk/tools/MotorControl/CompileMotorControlHere.bat

    r777 r890  
    3131echo Compiling... 
    3232 
    33 nbc -v=126 -o=MotorControl21.rxe MotorControl21.nxc 
     33nbc -v=126 -o=MotorControl22.rxe MotorControl22.nxc 
    3434 
    3535 
  • trunk/tools/MotorControl/MotorControl22.nxc

    r889 r890  
    77% this case, MATLAB) to carry on with execution... 
    88% 
     9% See also: http://www.mindstorms.rwth-aachen.de/trac/wiki/MotorControl 
     10% 
     11% CHANGELOG: 
     12% 
     13% * Version 2.2, 2010/09/14 
     14%   First released with toolbox version 4.04 
     15%   - Commented dead code in case compiler optimization doesn't find it 
     16%   - No real code changes 
     17%   - Version to be recompiled with newer NBC/NXC compiler versions, 
     18%     as some multi-threading / optimization bugs were fixed. 
     19%   - Not recommending FW version 1.26 anymore 
     20%   - Updated version numbers 
     21% 
     22%  * Version 2.1, 2009/08/31 
     23%    First released with toolbox version 4.01 
     24%    - Considered to be stable and working 
     25%    - Very occasional freezes with FW 1.26 during 
     26%      massive production use, see also: 
     27%      http://www.mindstorms.rwth-aachen.de/trac/ticket/51 
     28% 
    929% 
    1030% Signature 
    1131%   Author: Linus Atorf (see AUTHORS) 
    12 %   Date: 2009/08/21 
    13 %   Copyright: 2007-2009, RWTH Aachen University 
     32%   Date: 2010/09/14 
     33%   Copyright: 2007-2010, RWTH Aachen University 
    1434% 
    1535% 
     
    3454// important to be before includes, 
    3555// since they might be used inside the includes! 
    36 #define PROGRAM_VERSION "2.1" 
     56#define PROGRAM_VERSION "2.2" 
    3757 
    3858#define INBOX           1 
     
    117137    tmp =         StrCat("MotorControl ", PROGRAM_VERSION); 
    118138    TextOut(0,LCD_LINE1, tmp, true); 
    119     TextOut(0,LCD_LINE2, "for FW 1.26-1.28", false); 
     139    TextOut(0,LCD_LINE2, "for FW 1.28-1.29", false); 
    120140 
    121141    TextOut(3,LCD_LINE4, "(C) RWTH Aachen", false); 
     
    124144    TextOut(4,LCD_LINE7, "Press ORANGE to", false); 
    125145    TextOut(4,LCD_LINE8, "stop all motors", false); 
    126      
    127      
     146 
     147 
    128148    #ifdef ENABLEDEBUGGING_LCD_SLOW_ANTIBUG 
    129149        TextOut(0, LCD_LINE8, "SLOW ANTIBUG ON  ", true); 
    130150    #endif// - - - - - - - 
    131      
     151 
    132152}//end void 
    133153 
     
    147167 
    148168    taskArunning = true; 
    149      
     169 
    150170    bool stoppedByDirectCmd; 
    151171    stoppedByDirectCmd = RunMotorA(OUT_A, motorParamsA.power, motorParamsA.tacholimit, motorParamsA.speedreg, motorParamsA.holdbrake, motorParamsA.smoothstart); 
    152      
     172 
    153173    // if we exited from external NXTMotor.Stop command, we might've overwritten 
    154174    // the power value before exiting the main controller loop, so restore defined 
     
    161181        }//end if 
    162182    }//end if 
    163      
     183 
    164184    taskArunning = false; 
    165      
     185 
    166186    //Release(movingA); 
    167187    //TextOut(0,LCD_LINE6, "Task A stopped"); 
     
    208228                TextOut(0,LCD_LINE7, tmp); 
    209229        #endif 
    210      
    211      
     230 
     231 
    212232    taskBrunning = false; 
    213233    //Release(movingB); 
     
    224244    bool stoppedByDirectCmd; 
    225245    stoppedByDirectCmd = RunMotorC(OUT_C, motorParamsC.power, motorParamsC.tacholimit, motorParamsC.speedreg, motorParamsC.holdbrake, motorParamsC.smoothstart); 
    226      
     246 
    227247    // if we exited from external NXTMotor.Stop command, we might've overwritten 
    228248    // the power value before exiting the main controller loop, so restore defined 
     
    235255        }//end if 
    236256    }//end if 
    237      
     257 
    238258    taskCrunning = false; 
    239259 
     
    248268        taskSyncRunning = true; 
    249269    #endif 
    250      
     270 
    251271    bool stoppedByDirectCmd; 
    252272 
     
    303323        //Release(movingC); 
    304324    }//end if 
    305      
     325 
    306326    #ifdef ENABLEDEBUGGING_SHOWTASKS 
    307327        taskSyncRunning = false; 
     
    336356 
    337357 
    338  
     358/* 
    339359task dummyA() { 
    340360    int i = 0; 
     
    386406    }//end while 
    387407}//end task 
    388  
     408*/ 
    389409 
    390410 
     
    396416// main task 
    397417 
    398  
     418/* 
    399419task TESTmain() { 
    400420 
     
    428448    ResetErrorCorrectionAndBlockCount(OUT_B); 
    429449    ResetErrorCorrectionAndBlockCount(OUT_C); 
    430              
     450 
    431451 
    432452    Wait(1100); 
     
    450470    motorParamsB.holdbrake = false; 
    451471    motorParamsB.smoothstart = true; 
    452      
     472 
    453473    motorParamsC.power = 100; 
    454474    motorParamsC.tacholimit = 1000; 
     
    460480    start MoveB; 
    461481    start MoveC; 
    462      
     482 
    463483    //Wait(4000); 
    464484 
     
    467487 
    468488 
    469      
     489 
    470490 
    471491 
    472492}//end task 
    473  
     493*/ 
    474494 
    475495 
     
    493513    byte port1; 
    494514    byte port2; 
    495      
     515 
    496516    const byte bit1 = 1; 
    497517    const byte bit2 = 2; 
    498518    const byte bit3 = 4; 
    499      
     519 
    500520 
    501521    string tmp = ""; 
     
    562582            switch (packetType) { 
    563583            case PROTO_CONTROLLED_MOTORCMD: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    564              
     584 
    565585                // parse... 
    566586                tmp      = SubStr(in,  1, 1);  // pos 1 
     
    575595                tmp      = SubStr(in,  11, 1); // pos 11 
    576596                modebits = StrToNum(tmp); 
    577                  
     597 
    578598 
    579599                // process... 
     
    677697                break; 
    678698            case PROTO_RESET_ERROR_CORRECTION: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    679              
     699 
    680700                tmp      = SubStr(in,  1, 1);  // pos 1 
    681701                port     = StrToNum(tmp); 
    682                  
     702 
    683703                if (port <= 2) { 
    684704                    ResetErrorCorrectionAndBlockCount(port); 
     
    700720                break; 
    701721            case PROTO_ISMOTORREADY:  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    702              
     722 
    703723                tmp      = SubStr(in,  1, 1);  // pos 1 
    704724                port     = StrToNum(tmp); 
    705                  
     725 
    706726                // send answer string: portnum, then if ready or not 
    707727                if (IsMotorReady(port)) { 
     
    711731                }//end if 
    712732                SendMessage(OUTBOX, tmp); 
    713                  
     733 
    714734                break; 
    715735            case PROTO_CLASSIC_MOTORCMD: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    716              
     736 
    717737                // parse... 
    718738                tmp      = SubStr(in,  1, 1);  // pos 1 
     
    744764 
    745765                if (port <= 2) { 
    746                  
     766 
    747767                    // if no current tacholimit and no new one, allow speed change 
    748768                    if ((MotorTachoLimit(port) == 0) && (angle == 0)) { 
     
    803823                           TaskBusySignal(); 
    804824                        }//end if 
    805                          
     825 
    806826                    }//end if 
    807827 
    808828                }//end if 
    809              
    810              
     829 
     830 
    811831                break; 
    812832            }//end switch - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    813              
    814              
     833 
     834 
    815835            // reset message !!!! 
    816836            in = ""; 
     
    827847            PlayTone(440, 500); 
    828848            Wait(100); 
    829              
     849 
    830850            // release all motors again 
    831851            MotorOff(OUT_A); 
    832852            MotorOff(OUT_B); 
    833853            MotorOff(OUT_C); 
    834              
     854 
    835855            TextOut(5,LCD_LINE7, "EMERGENCY STOP    ", false); 
    836856            TextOut(2,LCD_LINE8, "Restart program!  ", false); 
    837857            Wait(2500); 
    838858            StopAllTasks(); 
    839              
     859 
    840860            /* 
    841861            // keep 
     
    847867                Wait(500); 
    848868            }//end while 
    849              
     869 
    850870            // purge incoming queue... 
    851871            in = "..."; 
     
    854874            }//end while 
    855875            in = ""; 
    856              
     876 
    857877            // manually reset task-semaphores 
    858878            // not very clean, but this button is for emergencies anyway... 
     
    860880            taskBrunning = false; 
    861881            taskCrunning = false; 
    862              
     882 
    863883            // reset counters for a nice clean start 
    864884            ResetErrorCorrectionAndBlockCount(OUT_A); 
     
    867887            */ 
    868888        }//end if 
    869          
    870          
     889 
     890 
    871891        // debugging 
    872892        #ifdef ENABLEDEBUGGING_SHOWTASKS 
     
    876896            string tmpC = "_ "; 
    877897            string tmpSync = "____ "; 
    878              
     898 
    879899            if (taskArunning) tmpA = "A "; 
    880900            if (taskBrunning) tmpB = "B "; 
    881901            if (taskCrunning) tmpC = "C "; 
    882902            if (taskSyncRunning) tmpSync = "Sync "; 
    883              
     903 
    884904            taskMsg = StrCat(tmpA, tmpB, tmpC, tmpSync); 
    885905 
     
    888908 
    889909    }//end while 
    890      
     910 
    891911 
    892912    TextOut(0,LCD_LINE1, "MainLoop exit", true); 
    893913    PlayTone(500, 1000); 
    894914    Wait(5000); 
    895      
    896      
     915 
     916 
    897917}//end task 
    898918 
  • trunk/tools/MotorControl/TransferMotorControlBinaryToNXT.bat

    r777 r890  
    77 
    88if not exist NeXTTool.exe goto nexttoolmissing 
    9 if not exist MotorControl21.rxe goto binarymissing 
     9if not exist MotorControl22.rxe goto binarymissing 
    1010 
    1111goto download 
     
    4040 
    4141echo. 
    42 echo   This program downloads MotorControl21.rxe 
     42echo   This program downloads MotorControl22.rxe 
    4343echo   to the NXT brick. Please connect a single NXT brick 
    4444echo   via a USB cable and turn it on. 
    45 echo   Make sure Firmware 1.26 (or higher) is installed on the NXT. 
     45echo   Make sure Firmware 1.28 (or higher) is installed on the NXT. 
    4646echo. 
    4747 
     
    5151echo   Transferring program... 
    5252 
    53 NeXTTool /COM=usb -download=MotorControl21.rxe 
     53NeXTTool /COM=usb -download=MotorControl22.rxe 
    5454 
    5555echo   Verifying download... 
    5656echo. 
    5757echo   If the next paragraph shows 
    58 echo  MotorControl21.rxe=xxxxx 
     58echo  MotorControl22.rxe=xxxxx 
    5959echo   then everything worked. 
    6060echo   A blank line indicates failure! 
    6161echo. 
    6262 
    63 NeXTTool /COM=usb -listfiles=MotorControl21.rxe 
     63NeXTTool /COM=usb -listfiles=MotorControl22.rxe 
    6464 
    6565