Matador Software Tutorial - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Matador Software Tutorial

Description:

Double-Click on Event brings creates function call ... creates an event which triggers the posting of a message packet to the target ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 23
Provided by: Bpar4
Category:

less

Transcript and Presenter's Notes

Title: Matador Software Tutorial


1
Matador Software Tutorial
  • Matador AWave
  • Playing waveform on DACs with host-set parameters

2
AWave SW Tutorial
  • //
  • // AWave.cpp
  • //
  • include "..\HdwLib\HdwLib.h"
  • include "Command.h"
  • using namespace II
  • volatile bool HostAck false

Illustrates use of analog output driver to
generate an arbitrary, user-specified waveform
on all analog output channels. The data buffer
are generated by a SigGen object, on the DSP, but
parameters (shape, amplitude, frequency) will be
received from the host, via unsolicited message.
3
  • DacStream Aout
  • Mutex Generator
  • // Prototypes
  • void InitMessageTransport()
  • void UnsolicitedMsgHandler( const IIMessage
    Msg )
  • // Binder objects for message hander functions
  • FtnIIMessageHandlerltMsgFtnTypegt
    UnsMsgHandler(UnsolicitedMsgHandler)
  • bool OutputSingleChannel false
  • int SingleChannelNumber 0

Instantiate the analog stream object
Arbitrates access to generator in above driver
from multiple threads. The SigGen object is used
to generate data and also must be accessed when
the host sends new parameters. Amutex is necessary
Always required
4
  • //------------------------------------------------
    ---------------------------
  • // IIMain() -- Generate a waveform on all
    analog channels
  • //------------------------------------------------
    ---------------------------
  • void IIMain()
  • volatile bool run true
  • Aout new DacStream
  • BasicTmb Timebase
  • Timebase.Rate(SampleRate)

Instantiate the D/A driver object Named
Aout The class DacStream is derived from the
parent class Stream and includes methods specific
to the analog control, for instance a hook to a
timebase
Construct a continuous timebase for use by D/A
driver Set the clock rate. In this example, the
value of SampleRate was defined in a command.h
file
5
  • Aout-gtDevice().Attach(Timebase)
  • Aout-gtGenerator().Type(wtSine).Frequency(1000.0).A
    mplitude(DefaultAmplitude)
  • InitMessageTransport()
  • for (int i 0 i lt NumChannels i)
  • Aout-gtDevice().Channels().Enabled(i, true)

Associate timebase with D/A driver
Initialize the SigGen with default
parameters Generator is a method to obtain a
reference through which you may access the
internal SigGen object
Establish communication with host
Enable specified analog pairs
6
  • Aout-gtEvents(NumEvents)
  • Aout-gtAttributes().nbufs 8
  • Aout-gtOpen()
  • volatile int _xx 0

Size the stream buffers based on rate, channel
count. The value of 0x10000 is defined in
command.h
Create 8 ring buffers for the DAC stream Open the
analog stream object
7
  • while(run)
  • Generator.Acquire()
  • if (OutputSingleChannel)
  • Aout-gtGenerate(SingleChannelNumber)
  • else
  • Aout-gtGenerate()
  • Generator.Release()
  • Aout-gtPut()
  • Aout-gtClose()
  • Delete Aout

While running, keep generating data buffers on
demand by the DAC stream
Acquire object ownership via Mutex
Check if single channel (instead of default which
groups in pairs)
The Generate method forces the SigGen to
calculate the next block of time series waveform
data and store it into the internal stream
buffercurrently managed by this object.
Release object ownership via Mutex
8
  • while(run)
  • Generator.Acquire()
  • if (OutputSingleChannel)
  • Aout-gtGenerate(SingleChannelNumber)
  • else
  • Aout-gtGenerate()
  • Generator.Release()
  • Aout-gtPut()
  • Aout-gtClose()
  • Delete Aout

The Put method sends the buffer of data to the
device driver associated with the Stream object.
Terminate communications with the Stream device.
Internally, the Close method calls the DSP/BIOS
API SI0_close function. Additionally, Close
relinquishes the internal buffer which is
implicitly allocated when the stream object is
opened
Stream Object destructor
9
  • //------------------------------
  • // InitMessageTransport()
  • //------------------------------
  • void InitMessageTransport()
  • InstallUnsolicitedHandler( UnsMsgHandler )
  • IIMessage msg
  • msg.TypeCode(kChannelInitMsg)
  • Post(msg)

Initialize message channel interface
Install handler for unchannelized messages
Create a message object, type a command as target
login notification and send it to host
10
  • void UnsolicitedMsgHandler( const IIMessage
    Msg )
  • switch (Msg.TypeCode())
  • case kSetParameters
  • Generator.Acquire()
  • Aout-gtGenerator().Type((IIWaveType)Msg.Data(
    0))
  • Aout-gtGenerator().Device().Frequency(Msg.AsF
    loat(1)1000.0)
  • Aout-gtGenerator().Device().Amplitude(Msg.AsFloat(
    2)32767.0/10000.0)
  • Aout-gtGenerator().Device().Asymmetry(Msg.AsFloat(
    3))
  • OutputSingleChannel (Msg.Data(4)0) ?
    true false
  • SingleChannelNumber Msg.Data(5)
  • Generator.Release()
  • break
  • default
  • break

Process unsolicited messages
Decipher message from host by checking first word
of packet
If kSetParameters, it indicates a waveform change
command Acquire ownership of SigGen, Then read
data in packet and load the values in the SigGen
11
Matador Software Tutorial
  • Host Side Program

12
Host Message Equivalent
The SendParameters event, associated to each
button click, will trigger a message packet and
send it
  • // TMainFormSendParameters()
  • void __fastcall TMainFormSendParameters(TObject
    Sender)
  • TIIMessage cmd
  • cmd.TypeCode kSetParameters
  • cmd.Data0 WaveTypeSwitch-gtPosition
  • cmd.AsFloat1 FrequencySlider-gtPosition
  • cmd.AsFloat2 AmplitudeKnob-gtPosition
  • cmd.AsFloat3 AsymmetrySlider-gtPosition
  • cmd.Data4 (OutputAllCheck-gtChecked) ? 1
    0
  • cmd.Data5 SingleChannelSel-gtItemIndex
  • Matador-gtPost(cmd)

Create a message cmd
Define the command associated with key words.
Header file containing these words enumeration is
shared between target and host.
Read the different knob positions And load in
data array that will constitute the message
Send the message to target
13
IOComp Components Graph, Buttons, Sliders,....
14
Slider Button Properties and Event
15
Double-Click on Event brings creates function
call Developer writes code to be executed when
this event fires
16
In our case, read control buttons values,
assemble data in the message data array and send
the message to the target
17
Matador Software Tutorial
  • Run Time Execution

18
Launch of Wave.exe on Host
19
After clicking on Download Button
20
Download is completed
21
User Screen with waveform controls
22
User Screen with waveform controls Clicking on
any button creates an event which triggers the
posting of a message packet to the target A
scope is used to visualize the D/A signals
Write a Comment
User Comments (0)
About PowerShow.com