Frequently Asked Questions  -  answers to questions concerning:
polled or scan mode,  what is BOOLEAN,   scan interval,  data rate,  what happens during a RUN, etc.




API Reference
Configuring  -  Initializing  -  Operating
 
Configuration setting - you will need to configure first
There is a  utility which can be used to configure the M201, so that you don't need to worry about the complexities of changing the configuration. You can also change the configuration programmatically.
basic,   misc,   load/save using  config file  M201_SP.INI,   default configuration
 
Initialization and Calibration
The initialization process involves establishing communication with the M201 and setting all the programmable variables to the values stored in the configuration. The last step in initialization is normally a self-calibration.
Initialize,   Calibration - Offset, Full-scale, and System  
 
Run
These functions are provided for simplified scanning mode operation. They combine the initialization and calibration above with a command to begin scanning.
Scanning Functions
 
Digital I/O
Digital I/O is available anytime after initialization.
Read/Write digital I/O


 

!
Do not scroll page beyond this point
  Information further down this page is linked to from above and possibly even other web pages. Scrolling to it may make it appear to be out of context.

























































































































 


Basic Configuration
The function calls below are used to change the configuration under program control. To change a fixed configuration see  IniTool.exe 
see also:
 misc. config,  use default config,  all config options
==========
COM Port ----
==========
BOOLEAN EX_SetCOMport (byte bCOM_Num - zero based)
BOOLEAN EX_GetCOMport (byte* pbCOM_Num - zero based)

===========
DATA RATE ----
===========
BOOLEAN EX_SetRate (double dblRATE)
BOOLEAN EX_GetRate (double* pdblRATE)

======================
CHANNEL Configuration ----
======================
BOOLEAN EX_SetSingleChanScanChanCode (BYTE bChanCode)
BOOLEAN EX_GetSingleChanScanChanCode (BYTE* pbChanCode)
BOOLEAN EX_SetMultiChanScanChanCodes (BYTE bChan0, BYTE bChan1,
                                    BYTE bChan2, BYTE bChan3, BYTE bChan4, BYTE bChan5, BOOLEAN fUpdateIni)
BOOLEAN EX_GetMultiChanScanChanCodes (BYTE* pbChan0, BYTE* pbChan1,
                                    BYTE* pbChan2, BYTE* pbChan3, BYTE* pbChan4, BYTE* pbChan5, BYTE* pbTotalChans)


================
TYPE OF SCAN ------
================
BOOLEAN EX_SetScanType (BYTE bScanType)
BOOLEAN EX_GetScanType (BYTE* pbScanType)

====================================
SCAN INTERVAL INFORMATION RELATED ----
====================================
The following should be called  LAST after all other   "pre-run setup options"
setting of the other options may effect the interval set or returned by this function call.

BOOLEAN EX_GetCurrentScanInterval (double* pdblCurrentInterval)
BOOLEAN EX_GetScanIntervalMinMax (double* pdblMinInterval, double* dblMaxInterval)
BOOLEAN EX_SetToMinScanInterval (void)
BOOLEAN EX_SetToUserScanInterval (double* pdblUserRequestedInterval)


===================
DATA LOG OPTIONS ----
===================
BOOLEAN EX_SetDataLogOptions (UINT uiDataLogMethod, UINT uiLogFileMaxSize, UINT uiMisc)
BOOLEAN EX_GetDataLogOptions (UINT* puiDataLogMethod, UINT* puiLogFileMax, UINT* puiMisc)

======================
SHOW CONFIGURATION ----
======================
BOOLEAN EX_ShowDevSetupInfo_MsgBox (void)
BOOLEAN EX_ShowDevSetupInfo_WriteToFile (void)
BOOLEAN EX_SetDevToDefaultSetup (void)
BOOLEAN EX_SetDevToIniSetup (void)
BOOLEAN EX_WriteCurrentSetupToIniFile (void)

























































































































 


Misc Configuration
Functions below are used for misc device configuration.
see also:
 basic config,  use default config,  all config options
click links to find out more - including prototypes
=============================================
MISC CONFIGURATION - affects both polled and scan mode ----
=============================================
BOOLEAN EX_SetGain (BYTE bGain)
BOOLEAN EX_GetGain (BYTE* pbGain)

BOOLEAN EX_SetRemoteAverage (BYTE bAvg)
BOOLEAN EX_GetRemoteAverage (BYTE* pbAvg)

BOOLEAN EX_SetPolarity (BYTE bPolarity)
BOOLEAN EX_GetPolarity (BYTE* pbPolarity)

BOOLEAN EX_SetFilter (USHORT pusFilter)
BOOLEAN EX_GetFilter (USHORT* pusFilter)



=========================
SCAN MODE MISC OPTIONS ----
=========================
BOOLEAN EX_SetLengthOfRunMs (UINT uiMilliseconds)
BOOLEAN EX_SetLengthOfRunSec (UINT uiSeconds)

BOOLEAN EX_SetRunEndBeepOptions (BOOLEAN _fUseBeep, UINT uiBeepFreqMs,
                                UINT uiBeepDurationMs, UINT uiBeepIntervalSec, UINT uiBeepTimeoutSec)

BOOLEAN EX_StopRunEndBeep (void)




  The following is a way to get back to a safe starting
point with device set to default configuration.

BOOLEAN EX_Reset (void)























































































































 


Initialize
The function call below is used to establish communication with the device and to set all the programmable variables to the values stored in the configuration.
to configure, use one or more of the following:
 basic config,  misc. config,  use default config,  all config options
click link shown below to find out more - including prototype

BOOLEAN   EX_InitDev (void)

























































































































 


Calibration
The function calls below are used for calibration
click links shown below to find out more - including prototype

BOOLEAN   EX_SystemCalibration (void)

BOOLEAN   EX_OffsetCalibration (void)

BOOLEAN   EX_FullScaleCalibration (void)

























































































































 


Scanning
The function calls below are used for scanning
click links shown below to find out more - including prototype

BOOLEAN   EX_Run (void)

BOOLEAN   EX_Stop (void)

BOOLEAN   EX_CheckRun (void)

























































































































 


Digital I/O
Two function calls to write/read digital I/O
click links shown below to find out more - including prototype

BOOLEAN   EX_SendDigout ( uchar bDigOut )

BOOLEAN   EX_GetDigin ( uchar* bDigIn )























































































































 


Calibration
Three function calls for calibration
click links shown below to find out more - including prototypes

BOOLEAN   EX_SystemCalibration ( void )

BOOLEAN   EX_OffsetCalibration ( void )

BOOLEAN   EX_FullScaleCalibration ( void )




























































































































===========================
== Configuration ====================
===========================
 
EX_SetCOMport ( byte bCOMport )
      Sets COM port. This is zero based - for COM1=0, COM2=1, etc.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetCOMport ( byte* bCOMport )
      Gets COM port. This is zero based - for example COM1=0, COM2=1, etc.

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetRate ( double Rate )
      Sets data rate
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetRate ( double* Rate )
      Gets current data rate

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetPolledModeChan ( BYTE bMainChan, BYTE bSubChan )
      Sets current main and sub-channel to be used while in polled mode.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetPolledModeChan ( BYTE* pbMainChan, BYTE* pbSubChan )
      Gets current main and sub-channel that would be used while in polled mode.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetSingleChanScanChanCode ( BYTE bChanCode )
      Sets current main and sub-channel to be used in single-channel scanning.
      IMPORTANT: see   Channel Setup (single )   for proper usage.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetSingleChanScanChanCode (BYTE* pbChanCode )
      Gets current main and sub-channel to be used in single-channel scanning.

      IMPORTANT: see   Channel Setup (single )   for proper usage.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetMultiChanScanChanCodes ( BYTE bChan0, BYTE bChan1, BYTE bChan2,
                          BYTE bChan3, BYTE bChan4, BYTE bChan5, BOOLEAN fUpdateIni
)
      Sets current scan channels (and sub-channels if any) to be used for multi-channel scanning.
      IMPORTANT: see   Channel Setup   for proper usage.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetMultiChanScanChanCodes ( BYTE* bChan0, BYTE* bChan1, BYTE* bChan2,
                          BYTE* bChan3, BYTE* bChan4, BYTE* bChan5, BYTE* bTotalChans
)
      Gets current scan channels (and sub-channels if any) to be used for multi-channel scanning.

      IMPORTANT: see   Channel Setup   for proper usage.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetScanType ( BYTE bScanType )
      Sets scan type - 0=SingleChannel 1=Normal 2=NormalWithCalibration (normal is "multi-channel").
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetScanType ( BYTE* bScanType )
      Gets current scan type - 0=SingleChannel 1=Normal 2=NormalWithCalibration (normal is "multi-channel")

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetDataLogOptions ( UINT uiDataLogMethod, UINT uiLogFileMaxSize, UINT uiMisc )
      Sets data logging options. uiDataLogMethod is a controlled by various bit settings, referred to as flag bits. See Data Log BITS  for a detailed explanation of each BIT. uiLogFileMaxSize can be used to control the "approximate" size of the data log file. If that parameter is set to zero, the DLL will continue to write data to the log file regardless of the size it becomes. If the option for writing data to a disk log file isn't used (the default is for it to be the only form of data logging) the second parameter will be ignored. The third option is a placeholder for the possibitlity of a third parameter to be added in the future. If the disk file log option is chosen, the DLL will create a log file using the format, "ScanLog_x.txt", where, "x" is a number that is either zero if there are no other log files already created, or a number larger than the largest number of an existing log file. We've given the log file the ".txt" extension so it can be easily opened in most editors, and it has a format which is also easily imported into most spreadsheets for analysis.

NOTE: If this function is never called, the DLL will use it's default setting of writing the data ONLY to a disk file which it will create and will continue to write to the disk file until the RUN is stopped. The DLL will not write data to RAM memory for the application to retrieve unless this function is called with that option specified.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetDataLogOptions(UINT* uiDataLogMethod, UINT* uiLogFileMaxSize, UINT* uiMisc)
      Gets data logging options that are currently set. See EX_SetDataLogOptions(....) for more information.

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================




 
EX_SetToMinScanInterval(void)
      Sets device to the minimum scan interval  -  data will be returned as quickly as possible with current configuration.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_SetToUserScanInterval(double* dblUserRequestedInterval)
      Attempts to set the device to your requested interval (returns false if it can't)  -   you should call   EX_GetScanIntervalMinMax( ) to get limits first.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_GetCurrentScanInterval(double* dblCurrentInterval)
      Gets the current scan interval. This lets you know how often data will be ready for you to read  -  based on rate, channel count, remote averaging, etc.
Prototypes:   C/C++,   VisualBASIC,   LabView

 
EX_GetScanIntervalMinMax(double* dblMinInterval, double* dblMaxIntervall)
      Gets the min/max scan interval. You should do this after setting all other configuration parameters. You are then free to use any interval that falls within
      the min/max range using a call to  EX_SetToUserScanInterval  mentioned above. If you want the shortest interval, it's easiest to not make this call, but
      instead call directly to   EX_SetToMinScanInterval  after setting all other configuration parameters.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================







 
===========================
== Show, Load, Save, Configuration ============
===========================
 
EX_ShowDevSetupInfo_MsgBox(void)
      Shows current configuration used for running (COMport, data rate, etc.) using Windows style message box. You can use the related function call,  "EX_ShowDevSetupInfo_WriteToFile()"  to write the informatoin to a disk file as described below.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_ShowDevSetupInfo_WriteToFile(void)
      Writes current configuration used for running (COMport, data rate, etc.) to text file,   "DevInfo.txt"  in current directory. This is especially useful if you would like to view this information but your application (for whatever reason) may have a problem interracting with the Windows style message box like which would be used in the related call,  "EX_ShowDevSetupInfo_MsgBox()"
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_SetDevToDefaultSetup(void)
      Sets configuration to   default,   parameters. If uncertain how to configure, use this first and then use other functions to set individual configuration parameters.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_SetDevToIniSetup(void)
      Sets configuration to default parameters and then resets them to the values set in   "M201_SP.INI"  which should be in your Windows directory.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_WriteCurrentSetupToIniFile(void)
      Writes current configuration to   "M201_SP.INI"   in your Windows directory.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================









=========================
== Misc Config ==================
=========================
 

EX_SetGain( ) EX_SetGain(byte bGain)
      Sets gain value. Changes take effect  next signon.  Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetGain(byte* bGain)
      Gets gain value. Follow prototype link for more info.

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================


 
EX_SetRemoteAverage(byte bAvg)
      Sets remote average. Changes take effect  next signon.  Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetRemoteAverage(byte* bAvg)
      Gets remote average. Follow prototype link for more info.

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================


 
EX_SetPolarity(byte bPolarity)
      Sets polarity. Changes take effect  next signon.  Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetPolarity(byte* bPolarity)
      Gets polarity. Follow prototype link for more info.

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================


 
EX_SetFilter(USHORT usFilter)
      Sets filter value. Changes take effect  next signon.  Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView
========================================
 
EX_GetFilter(USHORT* usFilter)
      Gets filter value. Follow prototype link for more info.

Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================


 
EX_SetLengthOfRunMs ( UINT uiMilliseconds )
      Sets length of run using milliseconds. If parameter is zero or if this function is never called, run will continue until stopped by calling,  EX_Stop(),   EX_Reset(),   or other similar action..
Prototypes:   C/C++,   VisualBASIC,   LabView

 
EX_SetLengthOfRunSec ( UINT uiSeconds )
      Sets length of run using seconds. This is best for long runs. If parameter is zero or if this function is never called, run will continue until stopped by calling,  EX_Stop(),   EX_Reset(),   or other similar action..
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================



 
EX_SetRunEndBeepOptions(BOOLEAN fUseBeep, UINT uiBeepFreqMs, UINT uiBeepDurationMs, UINT uiBeepIntervalSec, UINT uiBeepTimeoutSec)
      Sets various parameters to create a BEEP sound through your PCs speaker when the RUN is completed.
Prototypes:   C/C++,   VisualBASIC,   LabView

 
EX_StopRunEndBeep(void)
      Turns off the BEEP at the end of a run -- if you set it up using the  EX_SetRunEndBeepOptions(...),   function.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================








===========================
== Initialization ====================
===========================
 
EX_InitDev ( void )
      Initializes - signs on and configures device. If no configuration parameters have been specified prior to this call,  default  parameters built into the DLL will be used.


      See special notes included with language prototypes at the links below.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================



 





===========================
== Calibration =====================
===========================

  A complete system calibration is performed with each signon.
A new signon occurs whenever a new run is started.

 

EX_OffsetCalibration( )
      Performs an offset calibration. You must call  EX_SetPolledModeChan  with the main and
the sub-channel before making this call. Always make this call before making a call to  EX_FullScaleCalibration.

The M201 will force the channel to read zero volts. Zero offsets are possible up to 1/2 of full scale.

Follow prototype link for more info.

Prototypes:   C/C++,   VisualBASIC,   LabView


 

EX_FullScaleCalibration( )
      Performs a full-scale calibration. You must call  EX_SetPolledModeChan  with the main and
the sub-channel before making this call. Always make this call after making a call to  EX_OffsetCalibration.

The M201 will force the channel to read 5 volts. The M201 can increase the gain by 15% or decrease the gain by 5% from the nominal value. Remember that the actual input voltage should not exceed +/- 5 volts. Also if your offset calibration voltage was not zero volts, you will shift the available calibration range. The offset calibration should be done before the full-scale calibration.

NOTE:  If the gain is not 1, the desired full scale voltage should be applied to the input channel (or sub-channel) that was set by a prior call to EX_SetPolledModeChan(). The nominal full-scale voltages are
x1=5;   x2=2.5;   x4=1.24;   x8=.0625;   x16=.03125;   x32=.015625;   x64=.0078125;   x129=.00390625

Follow prototype link for more info.

Prototypes:   C/C++,   VisualBASIC,   LabView


 

EX_SystemCalibration( )
      Performs both offset, and full-scale calibration. This does the channel selection and both calibrations and then reselects the original channel. Settling times are accounted for.

Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================



 





===========================
== Runtime Data Handling ================
===========================

  Use for reading the data into your application

 
EX_GetScanDataDbl( double* pdblDataBuff, UINT uiNumScansToReturn, UINT* puiNumScansReturned, UINT* puiNumScansInBuff, BOOLEAN* pfStillScanning)
      Retrieves the scan data, already converted into a voltage format. The first parameter must point to a buffer of "double" data type large enough to hold all the data points for as many "scans" as is requested by the second parameter. One scan is comprised of one set of all the channels (and sub-channels if any) that were setup using a call to one of the following two functions:
  EX_SetSingleChanScanChanCode (...)
  EX_SetMultiChanScanChanCodes (...)
or retrieved by a call to one of the following two functions:
  EX_GetSingleChanScanChanCode (...)
  EX_GetMultiChanScanChanCodes (...)
See the "FAQ" documentaion for explanation of what one "SCAN" consists of.:
  What is a SCAN
If you set this parameter a greater value than what is available, only the available number of scans will be returned and that number will be reflected in the fourth parameter.

The DLL uses the fourth parameter to let you know how many scans it put into your buffer.

The fifth and final parameter is used to let you know if the RUN is still active. For an unknown reason (power outage for example) the RUN may have stopped, and checking this parameter is one of the ways for you to find out. Please refer to ChanSetup for information about setting up the channels (and sub-channels if any).
IMPORTANT: When using any of the "self-calibration" type scans, each "packet" of SCAN DATA is followed by first the "Offset voltage" and then the "Full-Scale voltage".
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_GetScanDataInt( INT* piDataBuff, UINT uiNumScansToReturn, UINT* puiNumScansReturned, UINT* puiNumScansInBuff, BOOLEAN* pfStillScanning)
      Retrieves the scan data, in "signed integer" type format.
Please look for information about how to convert the "unsigned integer" value into a voltage. The first parameter must point to a buffer of "signed integer" data type large enough to hold as many "scans" as is requested by the second parameter.One scan is comprised of one set of all the channels (and sub-channels if any) that were setup using a call to:
  EX_SetSingleChanScanChanCode (...)
  EX_SetMultiChanScanChanCodes (...)
or retrieved by a call to one of the follwoing two functions:
  EX_GetSingleChanScanChanCode (...)
  EX_GetMultiChanScanChanCodes (...)
See the "FAQ" documentaion for explanation of what one "SCAN" consists of.:
  What is a SCAN
If you set this parameter to a greater value than what is available, only the available number of scans will be returned and that number will be reflected in the fourth parameter.

The DLL uses the fourth parameter to let you know how many scans it put into your buffer.

The fifth and final parameter is used to let you know if the RUN is still active. For an unknown reason (power outage for example) the RUN may have stopped, and checking this parameter is one of the ways for you to find out. Please refer to ChanSetup for information about setting up the channels (and sub-channels if any).
IMPORTANT: When using any of the "self-calibration" type scans, each "packet" of SCAN DATA is followed by first the "signed integer" value representing the "Offset voltage" and then the "signed integer" value representing the "Full-Scale voltage".
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================








 
===========================
== Digital I/O Handling =================
===========================
 

 
EX_SendDigout(byte bDigIn)
      Sends digital output byte. The digital output can only be issued while in polled mode. Digital output is a value from 0 to 255.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_GetDigin(byte* pbDigIn)
      Gets digital input byte. The digital input can be read anytime after initialization. Digital input is a value from 0 to 255. The host should wait for the response to a data request command before sending another command. Data requests with extensive averaging can take minutes to complete.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================








 
===========================
== Scan Run/Stop/Check ================
===========================
EX_Run( )
      Initializes and starts scan based on current configuration. A complete system calibration  ( offset and full-scale )
is performed at the start of each run. See   Configuration Setup Options   to view or change configuration.
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_Stop( )
      Stops scanning. Device then becomes idle - referred to as "Polled Mode"
Prototypes:   C/C++,   VisualBASIC,   LabView


 
EX_CheckRun( )
      Just checks to see if currently running.
Prototypes:   C/C++,   VisualBASIC,   LabView
===================================================================







 
===========================
== Polled mode data read ================
===========================
 

EX_GetOneConversion( double* dblMilliVolts )
      POLLED MODE - Retrieves the scan data as millivolts, in floating point type format. Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView







 
===========================
== Misc Functions ===================
===========================
 

EX_Standby( BYTE bStandby )
      Puts device into standby mode to assist in battery conservation. Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView



 
EX_Sleep( BYTE bSleep )
      Puts device into sleep mode for good battery conservation. Follow prototype link for more info.
Prototypes:   C/C++,   VisualBASIC,   LabView



 
 
EX_Reset( )
      Resets everything to  default   values stored within the DLL. This is always a good starting point if you think you have inadvertently misconfigured anything. When this function is called, there is no resetting of the hardware as may be assumed, since the state of the hardware or even the proper serial port could quite likely be in an unknown state.

After a call to this function be sure to take the required steps to properly configure for the RUN, based on your needs. A good place to start is to go back to the   top of this document  for information on how to do that.



























































 

Channel Setup
for Multi-Channel Scanning

Channels (and sub-channels if any) are setup in a rather unique way in order to achieve the simplest configuration of the many channel possibilities with the least amount of parameter usage.

Due to the ability to use a multiplexer to scan multiple "sub-channels" for each channel, the BYTE parameter used when setting the channels (and sub-channels if any) is represented by two "nibbles" (one nibble = 4-bits) within the individual BYTE (one byte = 8 bits or 2 nibbles) parameter. To make it easier to configure the two-nibble value, it's often easier to think of it in it's "HEX" format. With that in mind, below are some examples of valid channel configurations and how they are used. As may already be obvious, when you pass the code to the DLL with function calls, you must use the decimal values - in other words, "think" HEX and "pass" DEC. For example, look at the following call (using hard-coded values) showing only the first two channels:
      EX_SetMultiChanScanChanCodes(18, 90, ...)
In the example above, 18 decimal is being passed to channel zero. 18 decimal is equal to 12 hex (note the 1 and 2) so channel 1 and 2 are the ones that will be scanned.
In the example above, 90 decimal is being passed to channel one. 90 decimal is equal to 5A hex (note the 5 and A) so sub-channel 5 through 10   (10 = A hex)
  are the ones that will be scanned. In both examples, the channels are "inclusive" which means that both the first and last sub-channel represented by the code will be scanned which for channel zero above, means that both sub-channel 1 and sub-channel 2 will be scanned.

Also note that if usng the  M201_SP.INI  file to load your configuration, the channel values must be presented in decimal format, as is explained when using either the  "IniTool.exe"  software or special function calls into the DLL  (explained elsewhere)  to create that file for you.

 
CHAN-0   ChanCode = 18 dec = 12 hex means start sub-chan 1, end sub-chan 2  (for channel 0) 1 = start sub-chan 2 = end sub-channel
CHAN-1   ChanCode = 16 dec = 10 hex
  special:   means don't scan this channel -
  because start chan is greater than end chan
  note:  start=1, end=0
 -----------------  -----------------
CHAN-2   ChanCode = 31 dec = 1F hex means start sub-chan 1, end sub-chan 15  (for channel 2) 1 = start sub-chan F = 15 = end sub-channel
CHAN-3   ChanCode = 15 dec = F hex means start sub-chan 0, end sub-chan 15  (for channel 3) 0 = start sub-chan F = 15 = end sub-channel
CHAN-4   ChanCode = 51 dec = 33 hex means start sub-chan 3, end sub-chan 3  (for channel 4) 3 = start sub-chan 3 = end sub-channel
CHAN-5   ChanCode = 90 dec = 5A hex means start sub-chan 5, end sub-chan 10  (for channel 5) 5 = start sub-chan A = 10 = end sub-channel
  40 total channels and sub-channels




























































 

Channel Setup
for Single-Channel Scanning

Channels (and sub-channels if any) are setup in a rather unique way in order to achieve the simplest configuration of the many channel possibilities with the least amount of parameter usage.

Due to the ability to use a multiplexer to scan multiple "sub-channels" for each channel, the BYTE parameter used when setting the channels (and sub-channels if any) is represented by two "nibbles" (4-bits) within the individual BYTE parameter. To make it easier to configure the two-nibble value, it's often easier to think of it in it's "HEX" format. With that in mind, below are some examples of valid channel configurations and how they are used.

 
ChanCode = 12 (hex) means use main channel 1, sub-channel 2 1 = main channel 2 = sub-channel
ChanCode = 1F (hex) means use main channel 1, sub-channel 15 1 = main channel F = 15 = sub-channel
ChanCode = F (hex) means use main channel 0, sub-channel 15 0 = main channel F = 15 = sub-channel
ChanCode = 33 (hex) means use main channel 3, sub-channel 3 3 = main channel 3 = sub-channel
ChanCode = 5A (hex) means use main channel 5, sub-channel 10 5 = main channel A = 10 = sub-channel
ChanCode = 10 (hex) means use main channel 1, sub-channel 0 1 = main channel 0 = sub-channel
ChanCode = 1 (hex) means use main channel 0, sub-channel 1 0 = main channel 1 = sub-channel




























































 

Default configuration

 
COM port   ( zero based )0   ( COM 1 )
Serial port transmit buffer size 16
Serial port receive buffer size 32000
BAUD rate 9600
Data Rate 60Hz.
Scan Interval 0.167 sec.
Scan Type Normal   (multi-chan)
Channel 0 code 0x01
Channel 1 code 0x10
Channel 2 code 0x10
Channel 3 code 0x10
Channel 4 code 0x10
Channel 5 code 0x10
Number of channels (and sub-channels if any) for multi-channel scanning 2
Channel used for single-channel scanning 0
Sub-channel used for single-channel scanning 0
Remote Average 1
Polarity Bi-Polar
Filter 400Hz




























































 

Data Log Option - BIT settings

DEFINITION Flag Bit What it means
USE_SCAN_DATA_LOG_FILE 0x1 Write data to disk log file
USE_SCAN_DATA_ARRAY 0x2 Write data to memory to be read by application.
SCAN_STOP_ON_DATA_ARRAY_WRAP 0x4 Stop run if memory data buffer wraps (also known as "buffer overflow" or "buffer overrun")
See  reasons for wrap   just below.
SCAN_LIMIT_LOG_FILE_SIZE 0x8 Limit size of disk file. Size of disk file is based on another parameter used in function call.
FOR EXAMPLE
To test and set flags using C style language:
UINT uiFlags = uiFlagsToTestAndSet;
if(uiFlags & 0x1)   printf("USE_SCAN_DATA_LOG_FILE flag is set");
if(uiFlags & 0x2)   printf("USE_SCAN_DATA_ARRAY flag is set");
/* clear all but last flag */
uiFlags = uiFlags & 0x1;     uiFlagsToTestAndSet = uiFlags;
/* clear all but   "SCAN_STOP_ON_DATA_ARRAY_WRAP"   flag */
uiFlags = uiFlags & 0x4;     uiFlagsToTestAndSet = uiFlags;
/* set all four of the flags shown */
uiFlags = 0xF;


 


 Reasons for data buffer wrap


The data buffer is a circular buffer placed in RAM memory. The default size is 8640 bytes. One data conversion requires 3 bytes. A multi-channel scan of all available channels and sub channels available with the normal hardware plus multiplexer, would require 288 bytes (96 channels (and sub-channels if any) x 3 bytes each) of that space.

When the RAM memory buffer is used for storing data, the application should call one of the data-read DLL functions:
      EX_GetScanDataDbl(...)
      EX_GetScanDataInt(...)
to retrieve the data and remove it from RAM memory at an approximate interval which can be determined by a call to the following DLL function prior to starting a run and after setting all other configuration options:
      EX_GetCurrentScanInterval ().  

When the option is set to use the RAM memory buffer, the threads running within the DLL will place the data into a RAM memory circular data buffer at the specified scan rate, and will continue to do so. It's important to know that if the data isn't removed from memory by the running application, the DLL will overwrite previous data as the buffer fills and wraps in the normal way that a circular buffer does. The DLL maintains a HEAD and TAIL pointer into the buffer and increments the head pointer whenever the buffer is written to and increments the tail pointer whenever the buffer is read. The TAIL pointer follows the HEAD pointer fairly closely if the application is diligent about keeping the buffer read and due to it's size a wrapping of the buffer should never occur.

It should also be noted that before starting the run (scan) you have the option to cause the scan to stop in the event of a possible data buffer wrap in order to prevent data corruption by calling:
      EX_SetDataLogOptions ()
and setting the  SCAN_STOP_ON_DATA_ARRAY_WRAP  flag as discussed above.



























































 

Scan Termination

Under error conditions, a scan may terminate. This is obviously not the best way to end a scan since data collection does not end smoothly and data-logging files aren't usually ended and closed in the usual manner. A scan can be terminated automatically if certain function calls such as   EX_SystemCalibration( )  are made while scanning. A scan can also terminate if serial communication is lost. If device is currently running, please be sure to call  EX_Stop( )  before making function calls that may cause the scan to terminate as is explained elsewhere within the documentation. If in doubt whether a scan is running, you can use  EX_CheckRun(...) to find out.



























































 

Signon - what it means

Before any interraction with the device can take place, serial communication must be established and configuration parameters need to be passed to the device. We call this process "SignOn" which is a term used in various places within this documentation. A signon may also be performed at other times in order to pass new configuration parameters to the device or even as a part of error recovery - for example, whenever a new scan is started we do a new signon automatically. Anytime you change configuration parameters the DLL sets a flag and will perform a new signon, using the new configuration, next time any type of I/O is performed.





























































 



Frequently Asked Questions
this will be added to as required


  Q: What is the difference between POLLED and SCAN mode? A: After initialization, the M201 is in polled mode until a start scan command is issued.

In polled mode, the M201 will respond to any command including digital I/O, channel change, get conversion, etc. Digital I/O commands can still be used after a scan is started, with some limitaions. When scanning, a pre-defined data sequence is sent continuously until a stop scan command is sent.
  Q: What's the easiest way to start running? A: Use the  configuration utility provided at the preceding link to configure the M201, then call  EX_Run ().  The M201 will start scanning and continue to scan until stopped with a call to  EX_Stop (). The data will be written to a log file, memory, or both depending on the settings chosen using the IniTool configuration utility.
  Q: What is meant by   "BOOLEAN" A: This data type is confusing to some - especially to non-C++ programmers.

The BOOLEAN data type represents TRUE or FALSE but is ONLY an 8-bit data type which is the same as a BYTE, Byte, unsigned char, uInt8, and other such names associated with 8-bits of data.

Unlike the "bool", "Bool", "BOOL", "Boolean", (note the case) or other such names used to represent "TRUE" or "FALSE", this data type requires only 8-bits rather than the 16 or 32 of some of the other types.

When prototyping the function calls, you can use any naming condusive to your programming language to represent the 8-bit return type. For example, in this documentation there is reference using a C++ language prototype to the function call:
     BOOLEAN  EX_Run(void)

Although C++ programmers can use the same prototype as shown here,
VisualBASIC programmers should prototype like this:
     Declare Function  EX_Run Lib "M201_SP.dll" () As Byte

LabView programmers would have something like:
     uInt8  EX_Run(void);

C programmers would have something like:
     unsigned char  EX_Run(void);
  Q: What is meant by  " Scan Interval" A: The M201 has the ability to scan at a specified interval within a particular range as described below.

The  minimum scan interval  is dependent on various configuration parameters such as the internal data rate, number of channels (and sub-channels if any) being scanned, filtering, in-device averaging, etc.

The  maximum scan interval  is the maximum amount of time that can expire between each time that the M201 performs a scan, and is limited only by limitations on the size of the M201 onboard counters. The M201 is only able to count within a certain limit in order to create a delay between scans which is the reason for a maximum scan interval. It's unlikely that the maximum scan interval would not be sufficient for most needs.

You can set the scan interval to any value that falls between the "minimum and maximum" scan interval returned by a call to,  EX_GetScanIntervalMinMax(...).
  Q: What is meant by   "Data Rate" A: The internal data rate can be set to any value between 10Hz and 1000Hz. The internal data rate determines the frequency response. The cutoff frequency is 1/4 of the data rate.
  Q: What is meant by  "RUN?" A: The  "RUN"   function combines initialization, calibration, and a start scan command. It may be the easiest way to use the M201 in scanning mode, especially, combined with the initool.exe for setting the configuration.
  Q: Where will the data go during a scan? A: The data will be sent to a disk file, "ScanLog_x.txt" with the "x" being a numeric value which is incremented with each new RUN. Each time the run begins, the numeric value will be one greater than that of the greatest value of any existing file in the working directory. It is up to you to remove any log files you are no longer interested in. Failure to do so could result in many such files accumulating within the application directory. The writing of that log file is the default functionlaity, but the handling of the scanned data can be manipulated in a number of ways. There are function calls which can be used to write the data to a memory buffer, which the application can access in order to, for example, graph the data in real-time. Functionality is provided to use a combination of both the disk file and memory buffer or just one or the other.
  Q: What is meant by   "one SCAN worth of data" A: One SCAN is one reading for each selected channel.

In scanning mode, all seleced channels are read, in sequence, at the start of a scan. The M201 then waits until the scan interval has elapsed to begin the next scan.

In single-channel scanning, one scan is simply one data point.

When a "self calibration" scan is performed, the full scale and offset calibration values are also returned along with the SCAN data so for a 96 channel scan, there would be 98 voltages returned. See the multi-channel selection guide for information concerning proper channel selection for doing a multi-channel scan, and single-channel selection guide for information concerning proper channel selection for performing a single-channel type of scan. See the following documentation for channel selection related prototyping information:
     EX_GetMultiChanScanChanCodes(...)
     EX_SetMultiChanScanChanCodes(...)
     EX_GetSingleChanScanChanCode(...)
     EX_SetSingleChanScanChanCode(...)


  Q: I've somehow configured things in such a way that I can no longer run. Can I  get back to a default configuration  so I can try again?
A: Sometimes you may find that you've configured things in such a way that you can no longer run and are not sure what you've done, or how to fix it. If you've saved a previous configuration that was working correctly and saved it to the "M201_SP.INI" file, then it's just a matter of reloading the configuration with a call to,
        EX_SetDevToIniSetup ( ).
If you haven't yet run, or suspect that the .ini configuration file may have invalid values, all that is required is that you make a call to
        EX_Reset ( )
followed by whatever you need to reconfigure everything to fit your needs. In other words, after calling   EX_Reset ( ),   just follow the instructions starting at the top of this html document or go to the beginning of the frequently asked questions HERE. When you finally configure everything the way you want, you can save it for easy reloading next time with a call to:
        EX_WriteCurrentSetupToIniFile ( )
anytime before you exit, and then next time you load your application make a call to:
        EX_SetDevToIniSetup ( )
An alternative to trying to configure everything using the function calls provided and discussed in this documentation, is to use the   IniTool.exe  configuration utility provided at our website . The   "IniTool.exe"   tool will allow you to easily setup a configuration that can be saved to the   M201_SP.INI  file and then loaded as previously explained. The utility has the ability to make an entirely new   M201_SP.INI  file even if one does not currently exist, or change any one of the parameters within that file.





























































 

Converting "signed integer" ( 32-bit ) data to voltage

 
The following variables are used in the calcualtion that follows them
iRawCount "signed integer" returned by call to the DLL
iRawCountTemp temporary holder for the "signed integer" value to be converted to voltage
dblVoltage floating point "double" value to represent voltage
bWordCnt this is almost always 3 which means 24-bits
bBiPolar this is almost always 1 which means use +- scaling for voltage.
Shown below is the calculation
iRawCountTemp = iRawCount;
dblVoltage = iRawCountTemp * .0002980232;
if (bWordCnt == 3) dblVoltage = dblVoltage * 256;
if (bBiPolar) dblVoltage = (dblVoltage * 2) - 5000;
dblVoltage = dblVoltage / 1000.0;








































 

Sample of   M201_SP.INI   configuration file

;========================================
;========================================
;THIS FILE MUST BE PLACED IN WINDOWS DIRECTORY
;This file is used by file, "M201_SP.DLL"  but
; may also be used by  any  application  file. 
;The DLL uses the contents of this file only if 
; and after a call has been made to the DLL 
; function  EX_SetDevToIniSetup().
;If you use it for your own  application avoid
; removing any of the following  entries since
; doing so may create  erroneous  behaviour of
; the the DLL.  Feel  free to add some of your 
; own entries or modify the values of the ones
; shown below to fit your needs.
;========================================
;========================================



[MAIN]
TXQUEUESIZE=16
RXQUEUESIZE=32000
;serial buffer sizes. Best to leave these
;as they are. (TX=16 RX=32000)


BAUD=0
;0 = 9600
;1 = 4800
;2 = 2400
;3 = 1200
;4 = 600
;5 = 300


comPort=0
;0 = COM1
;1 = COM2
;2 = COM3
;3 = COM4
;add 1 to value entered to get COM port number


remoteAvg=1
;remote averaging, in powers of 2
;valid entries limited to: 1, 2, 4, 8, 16, 32, 64, or 128


tScan=1
;type of scan 0 = single channel, 1 = normal, 2 = normal with calibration


singleChanScanMainChan=0
;main channel to use when in single-channel scan mode

singleChanScanSubChan=0
;sub channel to use when in single-channel scan mode


Rate=60
;internal data rate

ScanInterval=0
;Interval between scans.
;A value of zero will cause scanInterval to be set
; to minimum value by the DLL next time a scan is run.


channel=0
;Polled mode main channel  (0,1,2,3,4,5)

subChan=0
;Polled mode subChannel


wordCnt=3
;3 for 24 bit resolution, 2 for 16 bits


biPolar=1
;1= bipolar or 0= unipolar


filter=2
; =0 for 4 Hz filter
; =1 for 40 Hz filter
; =2 for 400 Hz filter, recommended for faster operation


gain=1
;gain factor (power of 2)
;valid entries limited to: 1, 2, 4, 8, 16, 32, 64, or 128


LogScans=1
;1 = Log scan data to disk only
;2 = Log scan data to memory only
;3 = Log scan data to memory and disk
;NOTE: the log file can become awkwardly large depending on scan rate & duration.


[SubChannels]
; Sub-Channels to scan are defined for each A/D channel.
; The sub channel values are 8-bit codes, also known as "external control codes".
; The upper nibble names the starting subchannel and the lower nibble names
;  the ending subchannel. An entry of 16 causes the channel to be skipped.
; For example, to scan sub-channels 2 through 4 first you set the low
;  channel 2 by multiplying it by 16 which causes it to shift over and
;  become the upper nibble of the channel code. Next you add on the high
;  channel 4 which sets it into the low nibble. The result of that process
;  would then be 24 HEX (note the "2 and 4"), 36 DECIMAL (hard to tell which
;  channels are set when shown in decimal format), or in binary  "0010 0100"
;  (note the "2" bit set in the upper nibble and "4" bit set in low nibble).
;  The process is the same for any channel combination - first you multiply 
;  the low channel by 16 and then add the high to it.

0 = 21	    ;equals 15 HEX so scan sub channels 1-5	
1 = 55      ;equals 37 HEX so scan sub channels 3-7
2 = 34      ;equals 22 HEX so scan sub channels 2-2  (ONLY 2 in other words)
3 = 16      ;equals 10 HEX code indicating this channel is inactive
4 = 16      ;equals 10 HEX code indicating this channel is inactive
5 = 16      ;equals 10 HEX code indicating this channel is inactive


[MISC]
IsEMF=1		; The channel labeling for the M201 is for programmers, and is 0 based
		; The labeling for the EMF16 is for users, so the first channel is #1
		; set to 0 for 0-based labeling.







Contact us for sales or technical assistance
lawsnlab@lawsonlabs.com

on the web
www.lawsonlabs.com

© Lawson Labs Inc. All rights reserved
Last modified 3-23-06 Tim Van Dusen