- BiomechDocs BL Knee PFresearchE
- Biomech Documentation links:
- AKCPU2z BLMD6c BLFT6c PSER1c Imu_2010 Emg_2009 Ric Upd_pcb
- Microchip Tools For Coding, Programming
- Install MPLAB IDE and other Microchip tools
- Plug in the programmer (ICD3), go to windows device manager, right click on the ICD3, update driver software, then find the drivers folder under c:\program files\microchip\mplab ide\icd3\drivers\
- for dsPIC33 and PIC24 (statemachine, motor controller boards on powerfoot) : C30 C compiler V2.05 and then license, then install the C compiler V3.23 (note the lite version is ok)
- for PIC32 (external higher-level control board for muscle models/EMG control), install C32 compiler BCDA-CFGH-WRTA-AUSI
- Install python 2.6.4, then the support modules Python2.6 32 bit version (Python 2.5.4 or 2.7.x may also work)
- Install development support tools (SVN client, win merge, grep, Baregrep, Visual Studio for IDE, editor, etc.) Dev support
- To use the PSERxx wire connections (the USB cable connection to the ankle), install VCP drivers for FTDI CHIP FT2232H
- Top level tools - the above tools and others can be found here
Get the Firmware / Tortoise SVN
The SVN revision control system hosts the firmware and support scripts for the project. (The code was formerly hosted by SVN revision control system (user biomech, password:biomechXXX where XXX is the primary lab room number in E14)).
The project can be obtained from the SVN server with a tool call "Tortoise SVN" PDF DOC using either its "export" or "check out" feature. Both export and checkout make a local copy of the project, however checkout also embeds 'hidden' directories that Tortoise SVN uses to keep track of changes to the files, and the full path to the SVN server.
Most activity's with Tortoise SVN are initialed by right clicking on a folder. In the context menu, options such as "Tortoise SVN" and "SVN Repo-browser" may appear. Start by choosing SVN Repo-browser and pasting this URL: 'https://bmech.media.mit.edu:8443/svn/ric_powerfoot/'
One possible to obtain the project :
- Check out the trunk to c:\src\trunk - this is the location that updates will appear and can be merged into your project.
- Export the trunk to c:\src\my_trunk - this will be your local working copy
- Pick a lab SVN server that you wish to keep the project.
- Using repo brower, create a folder on the lab SVN server that describes your project eg : ".../code/cbarn/thesis_firmware"
- Using repo browser check out that folder to "c:\src\my_trunk" - the directory to which you exported. Allow proceeding though the warning.
- Now use "SVN commit" to submit the project into the lab SVN server. Right click on the folder "my_trunk", navigate to Tortoise SVN, and select "SVN commit". In the following dialog, select all the files that you want to have in the revision control system. (temp files, .o, .exe, etc should usually be ignored)
example directory structure : c:\src\trunk\ support_scripts KneeController MotorController StateController
\my_trunk\ support_scripts KneeController MotorController StateController
The advantage of this layout is that a tool such as "WinMerge" can be used to quickly propagate changes from the "trunk" to "my_trunk".
Configuration of Build Tools
Python support scripts config
- Ctrl click "My Computer" and then select "Properties"
- From the new object, select the "Advanced" tab
- Select "Environment Variables"
- To the "PATH" variable, append "c:\python26;" (semicolons separate entries, do NOT include spaces between entries)
- The path variable may exist under "user variable" and/or "system variables"
- Verify that python is in the system path by starting a command shell trying to run python
A file that describes the directory structure of the project needs to be placed in "support_scripts" (which lives in the "project root directory"
- Edit the file "support_scripts\python_paths.py", so its variables point the root of your project tree (c:\src\my_trunk). Here is the default python_paths.py :
# specifiy the location of the project root directory: FIRMWARE_BASE_PATH = 'C:/src/this_project_root_directory'; # specify the location of critical files in the project EEPROM_KEYS_RELATIVE_FNAME = 'StateController/eeprom_keys.h'; IOCHAN_RELATIVE_FNAME = 'StateController/Infrastructure/io_chan-rev2x0.h'; SC_GLOBAL_H_RELATIVE_FNAME = 'StateController/global.h'
- the string "c:/src/this_project_root_directory" is replaced with your project root,
Finally, the project file for MPLAB IDE must point to the python tools in order for the code to build properly. At the end of the project file you are using (.mcp extension -- open with a text editor), make sure the line near the bottom: "Pre-Build=C:\python27\python ..\common_files\python_update_firmware.py -S" points to the python installation directory on your computer (here it's C:\python27\).
MPLAB IDE config
- This IDE can be used to both edit and compile/build/program
To load a PF project, the default settings of the MPLAB IDE need to be changed:
- open "MPLAB IDE"
- Under Configure -> Settings select the "projects" tab
- Uncheck the "use one-to-one project-workspace model"
Some other suggested changes:
- From the "other" tab, select "automatically reload"
- From the "workspace" tab, select "no", "reload last workspace", and "always show full path"
Some programmer settings could also be changed
- Select Programmer -> settings and then "Program after successful build"
After this works, try to open and compile a workspace/project.
- From MPLAB IDE, select "File, Open Workspace"
- Navigate to "trunk/StateController" and open "sc_workspace_mit.mcw" (or similar)
- Ignore complaint about files having been relocated.
- after it opens, press "Ctrl F10" to do a "make clean" followed by "make all"
- "Couldn't locate build tool": Make sure the correct compiler is properly installed
- "Could not spawn language tool":
- PROBLEM: If you update to a new version of Python after having set up MPLab, you may get the following error: "Executing: C:\python26\python..\common_files\python_update_firmware.py -S Could not spawn language tool. Check command-line options."
- SOLUTION: The build configurations are at the bottom of the ".mcp" files for each project. (h22.mcp for the Statecontroller, and "MC_300.mcp" for the motor controller). Open these files in a text editor and scroll to the bottom to the section labeled " [CUSTOM_BUILD] ". There is a line in this section that runs the python script.
- Change "Pre-Build=C:\python26\python ..\common_files\python_update_firmware.py -S" to whatever python version you want to use, e.g.: "Pre-Build= C:\python27\python ..\common_files\python_update_firmware.py -S"
connect to the target (Pic32 or robot)
All the tools below live in the directory "support_scripts". Open a command shell and CD to that directory. Python is needed to run them and should be in your path.
wifi_fast.py is the primary utility for receiving real-time telemetry from the target. It makes connection to the target via either a standard RS-232 serial port, or via a TCP connection. Once connected it reads telemetry, can log the data to a file, and can send the data via UDP for real-time plotting. It also sends keyboard characters to the target which can then be read via the C function 'getchar'.
do_command.py is used to send 'special' commands to the robot.
robo_config.py is used to read / write the robot's EEPROM and to read some the data structures in RAM.