Microchip tools

From DIDEAS Wiki
Revision as of 15:23, 22 September 2010 by Ceb (talk | contribs) (wifi_fast.py)
Jump to: navigation, search
  • Microchip Tools For Coding, Programming

Edit


Install software

Get the Firmware

Get source code and support scripts from SVN server (user biomech, password:biomechXXX where XXX is the primary lab room number)

  • To do this, launch SVN's repo browser (left click on a directory) find Tortoise SVN and then repo browser
  • Paste the above URL into the browser and supply the user / pass when prompted
  • Locate 'trunk' in the repo browser explorer window, then right click and select export. Use a local directory such as: "c:\src\my_trunk". This directory will be called the "project root" directory.
  • When the export is complete, you'll want to make a copy and check it into a your own revision control system.

example directory structure :

  c:\src\my_trunk\
                  support_scripts
                  KneeController
                  MotorController
                  StateController

Config

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:

  1. open "MPLAB IDE"
  2. Under Configure -> Settings select the "projects" tab
  3. 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 changedLLLLL9

  • Select Programmer -> settings and then "Program after successful build"

After this works, try to open and compile a workspace/project.

  1. From MPLAB IDE, select "File, Open Workspace"
  2. Navigate to "trunk/StateController" and open "sc_workspace_mit.mcw" (or similar)
  3. Ignore complaint about files having been relocated.
  4. after it opens, press "Ctrl F10" to do a "make clean" followed by "make all"

python support scripts config

The python interpreter needs to be added to the system path. Some other's explanation: Win7 Vista XP for Java

My version:

  • 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;"
    • The path variable may exist under "user variable" 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,

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

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'.

  • get help with wifi_fast.py -h

The typical command contains 3 or 4 options as show below. wifi_fast.py -f log_file_name -V dataport3d -F -i IP_ADDRESS

The -V option specififes a "Vlist" or variable list that describes the binary format of the telemetry packet. These vlist files live in "support_scripts\vlist". Some times matching the vlist to the firmware can be a challege - as the two need to be precislty the same length; and the variable types must also match.

The -f option specifies the base name of the log file. As data is received, it converted as specified by the vlist, and stored in a self documenting .txt file that has a time stamp suffix. Several times an hour a new file will be started and the previous one added to a zip file.

The zip file often contains a file called "wifiload.m" that can be used with matlab to read the file and create a data structure with named fields. However, there are now easier to use matlab functions for this purpose.

via a wired connection

A wired ASYNC serial connection with the target requires a minimum of 3 wires : GND, Tx, Rx. The signals are 3.3V logical level. Several USB serial port devices called "PSER" have been made for this purpose. When connected to the PC, they will be assigned a "COMM PORT" number. Under windows you can use the "Device manager" to list the serial ports. You can run the command directly with the command "devmgmt"

via a wireless connection

From the support scripts folder run :

  • FOR S3 : wifi_fast.py -i 216 -F -f xx -V dataport
  • FOR S5 : wifi_fast.py -i 218 -F -f xx -V dataport

do_command.py

do_command.py is used to send 'special' commands to the robot.

do_command.py -h

robo_config.py

robo_config.py is used to read / write the robot's EEPROM and to read some the data structures in RAM.

robo_config.py -h

other tools

dataport

  • in the SC file "dataport.c" there is the statement : switch(sc_dp.dataport_select)
    • for each case, there are a number of assignment of robot variables to variables of the form "pf[n]".
    • the special command "157" is used to set the value of the variable "sc_dp.dataport_select"
    • thus the command "do_command.py -i IP_ADDRESS -s 157 1" sets dataport select to 1.