Difference between revisions of "Using the Data Recorder"

From Flowcode Help
Jump to navigationJump to search
Line 5: Line 5:
  
  
===Scope Introduction===
+
===Introduction===
  
  
The '''Data Scope''' allows the user to see the results and values from raw data and components such as dials and measures. This data is displayed during simulation and allows you to monitor the state of the various signals plotted to the various scope channels.  
+
Flowcode includes a data recorder ideal for testing your applications in both hardware and simulation.  
  
 +
It works alongside Ghost Technology to allow users to monitor signals in real time using In-Circuit-Test. It can also be used in simulation mode, though timing of signals is not accurate when using simulation. In simulation, it allows the user to see the results and values from raw data and components such as dials and measures. This data allows you to monitor the state of the various signals plotted to various channels.
  
The Data Scope can read and display data from various different ports simultaneously during simulation and can be adjusted to view the data at various speeds which allowed for increased accuracy or a larger amount of data to be displayed at any time.
+
<!--Image of Data Recorder-->
  
 +
The data recorder is very useful for analyzing data as it can accurately display information to identify patterns in the data as well as the speed data is being displayed at. Components such as the DSP range will automatically create their own Data Recorder channels, allowing for very simple yet powerful means of monitoring and debugging the system.
  
The Scope is very useful for analyzing data as it can accurately display information to identify patterns in the data as well as the speed data is being displayed at. Components such as the DSP range will automatically create their own scope channels allowing for very simple yet powerful means of monitoring and debugging the system.
 
  
 +
===How to use===
  
The Scope window is also used with the ICT (In Circuit Test) which is due to be released early 2014 along with the EB006 version 9 hardware.
+
====Adding streams====
  
 +
Streams are separated via two types: user streams and program streams.
  
[[File:Gen_Data_Scope_Example_01.png]]
+
=====User streams=====
  
 +
User streams are simple streams that allow you to easily monitor the value of a digital or analog pin. They can be added by simply clicking the “Add pin trace” button on the data recorder itself and selecting the appropriate digital or analog pin.
  
===Navigating the scope===
+
This method of adding streams is recommended if you are using Ghost technology (link) to view live pin data from your Matrix hardware.
  
To navigate around the scope there are two key bars which you need to be aware of:
+
<!--Image here of Add pin trace button.-->
  
[[File:ScopeNav.png]]
+
=====Program streams=====
  
'''Trace Nav Bar:''' This is highlighted by the <span style="color: green">green</span> box in the picture above. Click and holding the '''LMB''' (Left Mouse Button) will allow you to scroll horizontally through the trace.
+
Program streams are added by components or by flowchart icons in your program. For some components, simply adding it to the 2d or 3d panel causes a program stream to appear in the data recorder. These streams are then controlled by the component itself and will be removed automatically when appropriate.
  
'''Trace Zoom Bar:''' This is highlighted by the <span style="color: blue">blue</span> box in the picture above. Click and holding the '''LMB''' (Left Mouse Button) will allow you to zoom the trace.
+
<!-- Image of program streams added by SPI master.-->
  
Hovering your mouse cursor over the trace will show any timings between two points. You can see an example of this in the <span style="color: pink">pink</span> box above.
 
  
 +
Here, we will give an example of creating your own program stream using flowchart icons.
  
===Scope Monitor Component===
+
======Creating a stream group======
  
The scope monitor component is available to allow you to easily add traces to the scope window. The component allows up to 4 digital channels and up to 2 analogue channels to be added. More channels can be added to the scope by adding additional scope monitor components to your program.
+
To create a new stream group you first need to create a global “Handle” type variable to store the reference to the stream group. This is basically a unique number which used to refer to that specific group of streams in the data recorder. To do this, open the [[Project_Explorer|Project Explorer]] window and select the “Globals” tab. Next, right click the “Variables” portion of the tree view and select “Add New” from the menu. In the “Create a New Variable” dialogue that pops up give the variable a meaningful name such as “DRGroupHandle”, then switch the variable type to “Object handle” and click “OK”. You should then get an Object handle variable appearing in the [[Project_Explorer|Project Explorer]] window.  
  
[[Component:_ID_33b1e2c6_5509_40bf_a464_167edcbcf571|Full details of the scope monitor component are available here]].
 
  
 +
[[File:Scope1.jpg]] <!--Created handle variable called DRGroupHandle-->
  
===Creating a scope group===
 
  
 +
Next, we need to assign the handle variable with a value by calling the Flowcode API. To do this we add a Simulation Macro (link) icon to the “Main” flowchart. Then we double-click the icon on the flowchart to edit the icon's properties. Inside the icon property window we first need to ensure that the “Functions” tab is selected and then scroll down to the “DataRecorder” section before clicking the + icon to see all the API calls related to the data recorder’s functionality.
  
To create a new scope group you first need to create a global handle type variable to store the reference to the scope group. This is basically a unique number which used to refer to that specific group of the scope window. To do this open the [[Project_Explorer|Project Explorer]] window and select the Globals tab. Next right click the Variables portion of the tree view and select Add New from the menu. In the Create a new variable dialogue that pops up give the variable a meaningful name such as ScopeGroupHandle, then switch the variable type to Object Handle and click OK. You should then get a Object handle variable appearing in the [[Project_Explorer|Project Explorer]] window.
 
  
 +
[[File:Scope2.jpg]] <!-- List of DataRecorder API functions -->
  
[[File:Scope1.jpg]]
 
  
 +
The [[API_Scope.AddGroup|AddGroup]] function call creates a new named group of streams on the data recorder. The return value of the function call requires a handle type variable. You should set this to the name of the variable we have created previously (“DRGroupHandle” in this example). Type a name that you want into the parameter field, (such as “Test Group”).
  
Next we need to assign the handle variable with a value by calling the Simulation API. To do this we add a [[Simulation_Macro_Icon_Properties|simulation macro] icon to the Main flowchart and double click the item on the flowchart to edit the icon's properties. Inside the icon property window we first need to ensure that the Functions tab is selected and then scroll down to the Scope section before clicking the + icon to see all the API calls related to the Scope functionality.
 
  
 +
[[File:Scope3A.jpg]] <!-- Image of AddGroup with variable entered and “Test Group” -->
  
[[File:Scope2.jpg]]
 
  
 +
The [[API_Scope.AddStream|AddStream]] function call adds a new named stream to the group on the data recorder. The return value of the function call is a handle type variable. We will have to create a new global object handle type variable to store this. This handle must be unique for each single stream so you must use a new object handle variable for every program stream that you create on the data recorder.
  
The [[API_Scope.AddGroup|AddGroup]] function call creates a new named group of streams on the Scope window. The return value the function call requires a handle type variable, luckily we have already created this above.
+
[[File:Scope3B.jpg]] <!-- Image of AddStream with DRGroupHandle, DRStreamHandle return -->
  
 +
When we run the simulation the new group will be created on the data recorder ready for data to be streamed in.
  
[[File:Scope3A.jpg]]
 
  
 +
[[File:Scope3.jpg]] <!-- flow icons and created stream image -->
  
The [[API_Scope.AddStream|AddStream]] function call adds a new named stream to the group on the Scope window. The return value the function call requires a handle type variable so we will have to create a new global object handle type variable to store this. This handle must be unique for a single stream so a new object handle variable must exist for every stream on the scope.
 
  
 +
If you are creating your own Flowcode component, you can move these from the Main macro to the [[Event_Components.Initialise|simulation initialise event]] macro so that the group and stream are created automatically when the component is added to a program. This is the way that components such as the DSP based components add their data to the console window.
  
[[File:Scope3B.jpg]]
 
  
 +
[[File:Scope4.jpg]] <!-- Ev_initialise image -->
  
When we run the simulation the new group will be created on the scope window ready for data to be streamed in.  
+
Note that a group with no valid stream handles will not show up on the data recorder window just to try and avoid potential unnecessary clutter.
 +
Setting the handle variable to the value of 0 using a [[Calculation_Icon_Properties|Calculation icon]] or calling the [[API_System.DeleteHandle|System -> DeleteHandle]] API call will remove the group or stream from the data recorder window.  
  
  
[[File:Scope3.jpg]]
+
======Adding a digital pin or port to a program stream======
 
 
 
 
By moving the API call from the Main macro to say the [[Event_Components.Initialise|simulation initialise event]] macro we can create a component which will automatically add our new scope group and stream when the component is added to a program. This is the way that components such as the DSP based components add their data to the console window.
 
 
 
 
 
[[File:Scope4.jpg]]
 
 
 
 
 
Note that a group with no valid stream handles will not show up on the Scope window just to try and avoid potential unnecessary clutter.
 
 
 
Assigning the handle variable with the value of 0 using a [[Calculation_Icon_Properties|Calculation icon]] or calling the [[API_System.DeleteHandle|System -> DeleteHandle]] API call will effectively remove the group or stream from the scope window.
 
 
 
 
 
===Adding a digital pin or port to a stream===
 
  
  

Revision as of 09:40, 16 May 2019

<sidebar>Sidebar: Flowcode Help Overview:ToolsViews</sidebar>



Introduction

Flowcode includes a data recorder ideal for testing your applications in both hardware and simulation.

It works alongside Ghost Technology to allow users to monitor signals in real time using In-Circuit-Test. It can also be used in simulation mode, though timing of signals is not accurate when using simulation. In simulation, it allows the user to see the results and values from raw data and components such as dials and measures. This data allows you to monitor the state of the various signals plotted to various channels.


The data recorder is very useful for analyzing data as it can accurately display information to identify patterns in the data as well as the speed data is being displayed at. Components such as the DSP range will automatically create their own Data Recorder channels, allowing for very simple yet powerful means of monitoring and debugging the system.


How to use

Adding streams

Streams are separated via two types: user streams and program streams.

User streams

User streams are simple streams that allow you to easily monitor the value of a digital or analog pin. They can be added by simply clicking the “Add pin trace” button on the data recorder itself and selecting the appropriate digital or analog pin.

This method of adding streams is recommended if you are using Ghost technology (link) to view live pin data from your Matrix hardware.


Program streams

Program streams are added by components or by flowchart icons in your program. For some components, simply adding it to the 2d or 3d panel causes a program stream to appear in the data recorder. These streams are then controlled by the component itself and will be removed automatically when appropriate.


Here, we will give an example of creating your own program stream using flowchart icons.

Creating a stream group

To create a new stream group you first need to create a global “Handle” type variable to store the reference to the stream group. This is basically a unique number which used to refer to that specific group of streams in the data recorder. To do this, open the Project Explorer window and select the “Globals” tab. Next, right click the “Variables” portion of the tree view and select “Add New” from the menu. In the “Create a New Variable” dialogue that pops up give the variable a meaningful name such as “DRGroupHandle”, then switch the variable type to “Object handle” and click “OK”. You should then get an Object handle variable appearing in the Project Explorer window.


Scope1.jpg


Next, we need to assign the handle variable with a value by calling the Flowcode API. To do this we add a Simulation Macro (link) icon to the “Main” flowchart. Then we double-click the icon on the flowchart to edit the icon's properties. Inside the icon property window we first need to ensure that the “Functions” tab is selected and then scroll down to the “DataRecorder” section before clicking the + icon to see all the API calls related to the data recorder’s functionality.


Scope2.jpg


The AddGroup function call creates a new named group of streams on the data recorder. The return value of the function call requires a handle type variable. You should set this to the name of the variable we have created previously (“DRGroupHandle” in this example). Type a name that you want into the parameter field, (such as “Test Group”).


Scope3A.jpg


The AddStream function call adds a new named stream to the group on the data recorder. The return value of the function call is a handle type variable. We will have to create a new global object handle type variable to store this. This handle must be unique for each single stream so you must use a new object handle variable for every program stream that you create on the data recorder.

Scope3B.jpg

When we run the simulation the new group will be created on the data recorder ready for data to be streamed in.


Scope3.jpg


If you are creating your own Flowcode component, you can move these from the Main macro to the simulation initialise event macro so that the group and stream are created automatically when the component is added to a program. This is the way that components such as the DSP based components add their data to the console window.


Scope4.jpg

Note that a group with no valid stream handles will not show up on the data recorder window just to try and avoid potential unnecessary clutter. Setting the handle variable to the value of 0 using a Calculation icon or calling the System -> DeleteHandle API call will remove the group or stream from the data recorder window.


Adding a digital pin or port to a program stream

A digital pin or port can be assigned to a stream object handle by using the AddPort function call. The function requires the stream object handle, the port index where PORTA is 0, PORTB is 1 etc. The BitMask parameter is a binary AND mask which selects which bits of the port will be available on the scope stream. The PackMask parameter will move all the active bits together if necessary. The merge parameter allows you to add multiple ports or pins to a single stream.

To monitor a single pin with a LED connected to port pin A0 we can simply call the AddPort function like this.


Scope5.jpg


Here is a simple program to toggle the LED with the signal being replicated on the scope trace.


Scope6.jpg


To monitor a full port with a LED Array connected to PortB we can simply call the AddPort function like this.


Scope7.jpg


We then need to scale the scope channel to get the value in the range of 0-1 by calling the AddOp function like this.


Scope8.jpg


Here is a simple program to generate a digital counter on the port with the signal being replicated on the scope trace. The ShowHandle function allows the Scope window to appear automatically without the user having to manually open the Scope window.


Scope14.jpg

Adding an analogue pin to a stream

An analogue pin can be assigned to a stream object handle by using the AddAnalog function call. The function requires the stream object handle, the analogue channel index where AN0 is 0, AN1 is 1 etc. The subtract parameter allows you to add or subtract multiple analogue signals on a single stream.

To monitor a single analogue pin with a potentiometer connected to pin AN0 we can simply call the AddAnalog function like this.


Scope9.jpg


Here is a simple program to track the value of an analogue input signal based on the position of the potentiometer.


Scope10.jpg


Adding an custom value to a stream

A custom value can be assigned to a stream object handle by using the AddCustom function call. The function requires the stream object handle, the custom channel index 0-31 for each stream handle. The subtract parameter allows you to add or subtract multiple signals on a single stream.

To create a single custom stream we can simply call the AddCustom function like this.


Scope11.jpg


The data for a custom channel cannot come from a digital or analogue channel automatically so instead we have to manually pass the data to the custom channel. This is done by using the SetCustom function call. The value passed should be a floating point real number in the range between 0 and 1 so to convert a byte variable we have to divide by the value 255.0.


Scope13.jpg


Here is a simple program to track the values of two analogue input signals and then calculate and plot the average between the two readings.


Scope12.jpg