challenges of implementing timed models on timed platforms...reference clock integrated through the...

27
Challenges of Implementing Timed Models on Timed Platforms Patricia Derler, Hugo Andrade, Arkadeb Ghosal, Rhishikesh Limaye, Jacob Kornerup, Ankita Prasad, Trung Tran, Kaushik Ravindran Ptolemy Miniconference Oct 16, 2015

Upload: others

Post on 17-Mar-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Challenges of Implementing Timed Models on Timed

PlatformsPatricia Derler, Hugo Andrade, Arkadeb Ghosal,

Rhishikesh Limaye, Jacob Kornerup, Ankita Prasad, Trung Tran, Kaushik Ravindran

Ptolemy Miniconference Oct 16, 2015

Page 2: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

What we do

• Graphical software • Heterogeneous hardware • To build measurement and control systems

Measurementand Control Hardware

Development Tools System Platforms

Page 3: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Application AreasHistorically focus on Test and Measurement

• Acquiring data, instrument control

New Application areas

• Embedded Systems, Cyber-Physical Systems, Internet of Things, …

Commercial Technology

Models of Computation, User Interface

Math and Analysis

Measurement and Control I/O

Timing

Applications

Deployable Targets

With new application areas come new requirements.

Page 4: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

ftp://ftp.ni.com/pub/branches/asean/140331_lv_brochure_2013.pdf

Page 5: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

ApplicationsReal-time optical coherent tomography (OCT)  imaging system to enable early cancer detection

• combines 320 simultaneous channels at 10 MS/s, LabVIEW performs >700,000 FFT/sec.

European Extremely large telescope (E-ELT)

• 1.87 teraflops of data, 64 compute notes at 512 cores, and 14,000 samples every 2 ms

The Large Hadron Collider (LHC) at CERN • requires precise synchronization

• LabVIEW FPGA serves as the timekeeper for more than 100 collimators, control for approximately 600 stepper motors with millisecond synchronization over the 27 km of the LHC.

https://decibel.ni.com/content/blogs/labview-news-english/2015/04/07/point-of-view-why-you-just-need-time

Page 6: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Challenges

• Time representation • Precision

• Coercion, rounding

• Phase alignment • Jitter • Hardware clock

• Clock edge, clock domain, clock rate

• Multiple timescales, relation to global/TAI time • Clock synchronization • Programming with time

LabVIEW timestamp: 128-bit data type that represents absolute time

The most significant 64 bits should be interpreted as a 64-bit signed two's complement integer. (number of whole seconds after Epoch 01/01/1904 00:00:00.00 UTC). The least significant 64 bits should be interpreted as a 64-bit unsigned integer. (number of 2-64 seconds after the whole seconds specified in the most significant 64-bits)

Page 7: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Time in LabVIEW• Timing Source

• 1kHz, 1MHz, software triggered, … • Create/Clear/Instantiate timing

source • Create timing source hierarchies

• Timing Structure • Timed Loop • Timed

Sequence • Single Cycle

Time Loop (SCTL)

• Precise timing, execution feedback, timing characteristics that

• Programming with Time • Wait until time or tick • Measure elapsed time • Get current time • Create timestamp • Get time difference • Convert time to value/string and the

reverse • Format timestamp

Page 8: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Programming with TimeConfiguration: • Period • Offset • Priority • Processor • Timing Source • What to do if timing

is not met

Runtime status • When did the execution

actually start • How long did the

execution actually take

Configuration for next iteration

executes all functions inside within one tick of the FPGA clock

Page 9: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

LabVIEW Timing Engine• Nanosecond engine to keep track of time within a program

• Interfaces to the OS to manage time

• Can use a local real-time clock (RTC) or can be driven by an external reference clock integrated through the NI Time Sync Framework (NI-TimeSync)

• Functions and structures (Wait, Timed Loop) in LabVIEW use the nanosecond engine for time keeping

Page 10: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

An example: PWM Generation and Current Sampling for Brushless Motor Control

PID PID PID PID

CurrentLoopPeriod(50us)

time

Complex, brittle code

SCTL for PWM, requires precise timing

While Loop for PID which is difficult to write in SCTL

Shared Variable for communication

Page 11: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

LabVIEW Communications

Page 12: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Time in NI Hardware

• FPGA vs RT Processor

• Synchronization supported for various platforms • GPS,

• IEEE 1588-2008 (IEC 61588:2009),

• PPS or

• IRIG-B

• NI EtherCAT RIO • deterministic Ethernet-based communication protocol

Page 13: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Real-time OS

LV Execution System

Timing of a Virtual Instrument (VI)

Compilation, Clumping

Clumps: Nodes that

can be executed together

LabVIEW VI• LabVIEW Execution Systems

• preemptive, cooperative multithreading

• schedule execution of clumps in threads nondeterministically

• Special case: Timed Loop. All code enclosed in a timed loop is executed in a single thread

• Operating system • schedule threads on cores

• #Threads = #Cores * 4 Priority Levels * 5 Non-UI Execution Systems + 1 UI Execution System

Page 14: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Timing of a VI

• Timing statistics: Number of runs, average, shortest, longest time spent for diagram, display, draw, tracking, r/w local variables

• Profile memory usage—number of bytes and independent memory blocks used by a VI. However, memory profiling substantially slows down the execution speed.

• Measured execution time contains VI execution as well as runtime system overhead

Page 15: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Achieving precise timing behavior with LabVIEW and NI hardware is possible …

… but it is not easy to get it right

Now: Future:

Page 16: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Research Challenges• Time Representation

• Logical vs. Real time

• Timing Analysis

• WCET

• Mapping functionality onto distributed, heterogeneous hardware

• Design-space exploration

• PRET Machines

• NIST Cyber-Physical Systems Public Working Group, Timing and Synchronization Subgroup http://www.nist.gov/cps/cpspwg_timing.cfm

• Time-Aware Applications, Computers, and Communication Systems (TAACCS)http://www.taaccs.org/

• IEEE 802 standards group and the AVnu Alliance

• Industrial Internet Consortiumhttp://www.industrialinternetconsortium.org/

Page 17: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Date and Time Extensions to Ptolemy II

Patricia Derler

Page 18: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

How does Ptolemy model time?

• Every director has a local clock that keeps track of model time/simulated time

Page 19: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

How does Ptolemy model real time?

• Some directors have a synchronizeToRealTime property, others can use the SynchronizeToRealTime attribute

• 1 time unit corresponds to 1 second

• The system time at simulation start time is recorded

Page 20: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

ptolemy.data.type.BaseType.DateType

Page 21: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Actors to create and handle DateTokens

• Create DateTokens

• Modify DateTokens

• Convert DateTokens

• Relate model time to real time

Page 22: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Relate model time to real time

model time0 1 2 4 5

Page 23: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Relate model time to real time

model time0 1 2 4 5

10/16/2015 4:00pm 10/16/2015 4:05pmreal time

Page 24: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Relate model time to real time

model time0 1 2 4 5synchronizeToRealTime = true

output the model time value that

corresponds to the date

10/16/2015 4:00pm 10/16/2015 4:05pm

Page 25: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Relate model time to real time

model time0 1 2 4 5synchronizeToRealTime = true

output the model time value that

corresponds to the date output the

date token at the

specified date

10/16/2015 4:00pm 10/16/2015 4:05pm

Page 26: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Relate model time to real time

model time0 1 2 4 5synchronizeToRealTime = true

output the model time value that

corresponds to the date output the

date token at the

specified date

output the date at real time

corresponding to the model time of the

input event

10/16/2015 4:00pm 10/16/2015 4:05pm

Page 27: Challenges of Implementing Timed Models on Timed Platforms...reference clock integrated through the NI Time Sync Framework (NI-TimeSync) • Functions and structures (Wait, Timed Loop)

Thanks