Visible to Intel only — GUID: lgd1629302502266
Ixiasoft
1. About the Time-Sensitive Networking for Drive-on-Chip Design Example
2. Getting Started with the TSN for Drive-on-Chip Design Example
3. Porting the Intel MAX 10 Drive-On-Chip design to the Cyclone V SoC Development Board
4. Running HPS Software for the TSN Drive-on-Chip Design
5. Connecting the Cyclone V SoC Development board to the Tandem 48 V Motion-Power board
6. Running the Program
7. TSN Configuration Example
8. Document Revision History for AN 957: Time-Sensitive Networking for Drive-on-Chip Design Example
A. Example .qsf for Pin Assignments and Attributes
B. Top-level Verilog HDL File Example
C. YOCTO Build Patch File (cvsx_doc_tsn_2_3-rt) for the TSN Drive-on-Chip Design Example
D. Script to read and change MAC addresses from Cyclone V SoC EEPROM
2.1. Hardware Requirements for the TSN for Drive-on-Chip Design Example
2.2. Software Requirements for the TSN for Drive-on-Chip Design Example
2.3. Configuring the Cyclone V SoC Development Board for the TSN for Drive-on-Chip Design Example
2.4. Programming the FPGA for the TSN for Drive-on-Chip Design Example
2.5. Creating an SD Card Image for the TSN for Drive-on-Chip Design Example
2.6. Turning on the Cyclone V SoC Development Board for the TSN for Drive-on-Chip Design Example
2.7. Configuring the TSN IP
3.1. Changing File Names, Revision Name, and Target Device for the TSN Drive-on-Chip Design Example
3.2. Modifying the Drive-On-Chip Qsys System
3.3. Adding the TTTech TSN IP to the Qsys system
3.4. Connecting the TSN and Drive-on-Chip Subsystems
3.5. Compiling the Quartus Prime Design and Top-Level Module
3.6. Generating the Preloader
3.7. Generating a .jic file
3.8. Compiling the Drive-on-Chip Design Software in Nios II Software Build Tools
3.9. Launching a YOCTO Build
3.10. Building an SD Card Image for the TSN Drive-on-Chip Design Example
3.11. Changing MAC Addresses
3.12. Reading and Checking Physical Addresses on the Cyclone V SoC Development Board
Visible to Intel only — GUID: lgd1629302502266
Ixiasoft
4.2. Creating a Basic C Program for Motor Control
Creating a program to talk to the drive-on-chip subsystem from the Linux system uses the shared memory mechanism implemented during the Qsys system build.
- In the C program, set up the memory locations by using defines:
#define DEBUG_RAM_BASE 0xc4001000 #define DEBUG_ADDR_SPACE_PER_AXIS 64 /* Offsets into debug mem */ #define DOC_DBG_SPEED 10 #define DOC_DBG_POSITION 12 #define DOC_DBG_I_PI_KP 18 #define DOC_DBG_I_PI_KI 19 #define DOC_DBG_SPEED_PI_KP 20 #define DOC_DBG_SPEED_PI_KI 21 #define DOC_DBG_SPEED_SETP0 22 #define DOC_DBG_POS_SETP0 25 #define DOC_DBG_WAVE_DEMO_MODE 29 #define DOC_DBG_POS_SPEED_LIMIT 30 #define DOC_DBG_POS_PI_KP 31 #define DOC_DBG_TRACE_DEPTH 58
These parameters are identical to the ones described in the motor control application program (Nios II program)..
- Create functions to read and write to the motor control application:
//Read debug mem unsigned int get_motor_param(unsigned int axis, unsigned int param) { return debug_base[axis * DEBUG_ADDR_SPACE_PER_AXIS + param]; } //Write debug mem void set_motor_param(unsigned int axis, unsigned int param, unsigned int val) { debug_base[axis * DEBUG_ADDR_SPACE_PER_AXIS + param] = val; }
- In the main map the memory by using the following lines:
int _fdmem; const char memDevice[] = "/dev/mem"; _fdmem = open(memDevice, O_RDWR | O_SYNC); if (_fdmem < 0) { printf("Failed to open the /dev/mem !\n"); return 0; } else { printf("open /dev/mem successful!\n"); } /* mmap() debug memory */ int debug_size = 512; printf("Mapping %i bytes for debug_data\n", debug_size); debug_base = (unsigned int *)(mmap(0, debug_size, PROT_READ | PROT_WRITE, MAP_SHARED, _fdmem, DEBUG_RAM_BASE)); if ((void *)debug_base == MAP_FAILED) { printf("Failed to map debug memory\n"); return -1; } else { printf("Debug mem base : %x\n", (unsigned int)debug_base); }
- Test the motor movement by reading and writing to the drive-on-chip subsystem, for example to set the motor to the position 100 degrees:
set_motor_param(0, DOC_DBG_WAVE_DEMO_MODE, 1); //Set the axis 0 to position mode set_motor_param(1, DOC_DBG_WAVE_DEMO_MODE, 1); //Set the axis 1 to position mode set_motor_param(0, DOC_DBG_SPEED_SETP0, 100); //Set axis 0 pos to 100 degrees set_motor_param(1, DOC_DBG_SPEED_SETP0, 100); //Set axis 1 pos to 100 degrees
- In the same way use the function get_motor_param to retrieve information from the drive-on-chip subsystem such as position of the shaft, speed, motor control parameters like Kp, Ki or set the maximum speed limit..
- Compile the C program using the following command:
>> arm-linux-gnueabihf-gcc <program_name>.c -O3 -march=armv7-a
- Copy the program to the development board via scp and test the motor control.