HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

17 Appendix B: Harmonica Internals

This chapter summarises some of the Harmonica internals.

The chapter to give some deeper insights. It is not required for the standard Harmonica user.

17.1 Software Structure

The firmware is built from an initialisation block and from a run time block. The run-time block is built by (event) interrupt handlers and by an idle loop.

Most of the motion control routines are performed by a periodic interrupt. The interrupt period is programmable.

The idle loop consumes all the remaining CPU time, polling if there is anything to do (like interpreting host commands or running a user program) and executing whatever found to do.

17.1.1The Initialization block

The initialization block is called immediately after power-on.

The initialization is a linear set of routine, doing the following:

-Complete DSP register programming

-Initializing all the volatile data

-Attempt to read database from a serial flash, or reset data base to factory default if database reading failed

-Initialize the communication.

-Reset all CAN database – PDO mappings etc. and set CAN status to pre- operational.

-If there is an autoexec program defined, launch it (with thread 0).

17.1.2The periodic Interrupt

This interrupt has the cycle time of 50-100usec programmable by the parameter TS. The increased TS are used for high inductance – high user program CPU demand combinations, or High loss motors, or large power applications.

This interrupt does, every cycle, as follows:

-Commutation

-Hazard handling

-Motor current control

-RS232 transmission and receiving

-Data recorder (may be activated only every fourth cycle)

After completing the “every cycle” jobs, the periodic interrupt forks to periodic jobs of lesser frequency. The following jobs are made once per four periods:

-Calculate speed

-Calculate motion reference

-Closed loop speed or position control

-Controller gains scheduling.

-Read digital input, with software de-bouncing

-Manage Homing post-processing (Catching the home event itself is done by hardware)

-Handle high priority CAN actions:

oReact to time stamps

oReact to SYNC message by logging time and sending synchronous PDO's o React to NMT

o React to high-priority motion messages like PT and PVT.

o Route lower priority CAN messages to handling by the idle loop.

The following jobs are made once per 32 sampling periods:

213

Page 215
Image 215
Elmo HARSFEN0602, HARmonica 213, Appendix B Harmonica Internals, Software Structure, 17.1.1The Initialization block