Wiki

Clone wiki

scl-manips-v2 / neuroarm / LoadingCode

Running Code on NeuroArm

Overview

Applications that are run on the SOMANET motor controller nodes are written in a language called XC which is very similar to C. This page will cover the specifics of running the example programs, but for more information on XC programming, see the next wiki page.

In order to run an application on NeuroArm, two separate programs must be compiled:

  1. The XMOS application (with .xc file extension, .xe for the compiled binary) runs on the SOMANET nodes and interfaces with the motors, sensors, and ethercat communication to the computer. It must be compiled and then flashed or written to be the primary boot application on each of the SOMANET nodes.
  2. The EtherCAT Master application runs on the primary computer and sends commands to the SOMANET nodes over EtherCAT. The master application is independent of the XMOS XDE environment and written in standard C, but certain XC libraries must be compiled in it to allow it to communicate with the program running on the nodes.

Flashing the SOMANET Nodes

In order to demonstrate the process of flashing the SOMANET nodes, there is an example XC application sc_sncn_ctrlproto/app_ctrlproto_test_xmos.

There are two ways to flash this program onto the nodes:

  1. Flash each node individually over the JTAG Adaptor (debugging chip) from the XDE environment
  2. Flash any or all nodes over EtherCAT from the command line

Flashing over the JTAG Adaptor

The JTAG Adaptor provided by Synapticon fits directly between the middle XMOS core chip and top EtherCAT chip on the SOMANET node. Once it is attached, it can be connected via USB to the computer.

  1. In XDE, open the sc_sncn_ctrlproto/app_ctrlproto_test_xmos demo and build the project by selecting: project --> build project
  2. There should now be a compiled ".xe" file in sc_sncn_ctrlproto/app_ctrlproto_test_xmos/bin/Release
  3. In XDE, click on the lightning arrow and select "Flash Configurations"
    1. Double click "XCore Application" in the Flash Configurations window that pops up
    2. Make sure the Project field is "sc_sncn_ctrlproto" and the C/C++ Application Field is "app_ctrlproto_test_xmos/bin/Release/app_ctrlproto_test_xmos.xe" or the equivalent home directories and paths.
    3. Under device options, select "hardware" and click "refresh list". There should be an item in the drop down menu "XMOS XTAG-2 connected to L1[0..3]". If it says '...connected to None', then turn off and on again the SOMANET power supply.
    4. Select "Apply" if any changes were made.
  4. Finally select "Flash". There should be several warning statements printed to the console followed by the message "xflash succeeded"

Flashing over EtherCAT

All three nodes can be flashed simultaneously by running the XMOS application xflash and Synapticon application fw_update (firmware update):

  1. Once the project is built in XDE and a ".xe" file is produced, navigate to the root directory of XDE.
  2. As before, make sure the EtherCAT master program is stopped and that the power supply to the nodes is on and they are connected over ethercat.
  3. From the XDE root directory type source SetEnv . This application loads the xflash command into the current environment (i.e. if you change users to root using 'sudo', xflash will not work)
  4. Run the command
    xflash path/to/your/xe_file.xe --noinq --boot-partition-size BOOT_SIZE_VALUE -o path/for/the/binary/binary_name
    This command creates a binary file (name not important) that must be loaded directly onto the nodes.
    1. In order to find the BOOT_SIZE_VALUE, try using a random value and it should print out the correct value (in hex) in an error message
    2. As long as xflash creates the binary, you can ignore the warning messages that it prints out
  5. Navigate to the directory of the fw_update program ...../sncn_host-install/FWUpdate-Client/src
    1. Make sure the executable fw_update is built. Run make if this is not the case.
  6. Run the command sudo ./fw_update eth0 -all //path//to//your_binary
    1. Replace "eth0" with the ethernet port that the nodes are connected to (list ethernet ports with the command "ifconfig -a"
    2. The program should output something similar to:
Synapticon SOMANET Firmware Update
Updating Firmware of all connected C22 Slaves
ec_init on eth0 succeeded.
3 slaves found and configured.
Slaves mapped, state to SAFE_OP.
[firmware_update] requesting SOMANET slave: 1
..***************************************************....................
 Firmware Update succeeded for SOMANET slave 1
 [firmware_update] requesting SOMANET slave: 2
..******************************************************....................
Firmware Update succeeded for SOMANET slave 2
 [firmware_update] requesting SOMANET slave: 3
..******************************************************....................
Firmware Update succeeded for SOMANET slave 3
Slave reached init state

Once this step is done turn off and on the SOMANET node power supply to begin running the application.

Notes

  • Do not interrupt the flashing process while it is occurring. This could permanetly corrupt the SOMANET nodes and make them unusable.

Updated