Jump to content

Component: ADC (MCP356X) (Analog Input): Difference between revisions

From Flowcode Help
XML import
 
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{| style="width:50%"
{| width="50%"
|-
|-
| width="20%" style="color: gray;" | Author
| width="20%" style="color:gray;" | Author
| MatrixTSL
| MatrixTSL
|-
|-
| width="20%" style="color: gray;" | Version
| width="20%" style="color:gray;" | Version
| 1.0 (Release)
| 1.0
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| Analog Input
| Analog Input
|}
|}




==ADC (MCP356X) component==
An external ADC featuring 2, 4, or 8 channel 24-bit input. Capable of reading each channel independently or in differential mode. Communication using an SPI bus up to 20MHz.


==[[File:Component Icon 235fd689_bfd1_4c4a_a918_6c3c36e9a49f.png|Image]] ADC (MCP356X) component==
==Detailed description==
An external ADC featuring 2, 4, or 8 channel 24-bit input.
Capable of reading each channel independently or in differential mode.
Communication using an SPI bus up to 20MHz.


==Examples==
''<span style="color:red;">No additional examples</span>''




==Downloadable macro reference==


===<span style="font-weight: normal;"><u><tt>SampleADC</tt></u></span>===
Performs a single ADC sample and returns the result as a 24-bit value


'''Parameters'''


:[[Variable Types|BYTE]] ''PositiveChannel''
::0=CH0 - 7=CH7, 8=GND, 9=VDD, 11=REF+, 12=REF-, 13=TP, 14=TM, 15=VCM


:[[Variable Types|BYTE]] ''NegativeChannel''
::0=CH0 - 7=CH7, 8=GND, 9=VDD, 11=REF+, 12=REF-, 13=TP, 14=TM, 15=VCM




'''Return value'''


:[[Variable Types|LONG]]




===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Confgures the SPI bus ready for communications and initialises the MCP356X device.


Returns true if device is responding to commands.


'''Parameters'''


:''This macro has no parameters''




'''Return value'''
''No detailed description exists yet for this component''


:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
==Examples==






==Simulation macro reference==


''This component does not contain any simulation macros''




==Property reference==
<span style="font-weight: normal;"><u>Device Type</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''DevType''.


''<span style="color:red;">No additional information</span>''






<span style="font-weight: normal;"><u>Device Address</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''DevAddress''.


These bits are fixed from the manufacturer and by default are 01.


Used as Bits 6 and 7 of the command byte.


Alternative bits must be requested from the manufacturer.


<span style="font-weight: normal;"><u>Clock Selection</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''ClockSelection''.
''<span style="color:red;">No additional examples</span>''


''<span style="color:red;">No additional information</span>''






<span style="font-weight: normal;"><u>Sensor Bias Current</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''BiasCurrent''.


''<span style="color:red;">No additional information</span>''






<span style="font-weight: normal;"><u>ADC Bias Current</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''ADCBiasCurrent''.


''<span style="color:red;">No additional information</span>''
==Macro reference==


===Initialise===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
| colspan="2" | Confgures the SPI bus ready for communications and initialises the MCP356X device. Returns true if device is responding to commands.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




<span style="font-weight: normal;"><u>AMCLK Prescaler</u></span>
===SampleADC===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SampleADC'''
|-
| colspan="2" | Performs a single ADC sample and returns the result as a 24-bit value&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | PositiveChannel
|-
| colspan="2" | 0=CH0 - 7=CH7, 8=GND, 9=VDD, 11=REF+, 12=REF-, 13=TP, 14=TM, 15=VCM&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NegativeChannel
|-
| colspan="2" | 0=CH0 - 7=CH7, 8=GND, 9=VDD, 11=REF+, 12=REF-, 13=TP, 14=TM, 15=VCM&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s32-icon.png]] - LONG
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Prescaler''.


''<span style="color:red;">No additional information</span>''
===SetGainCalibration===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SetGainCalibration'''
|-
| colspan="2" | Allows the device offset to be entered allowing for accurate readings.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Gain
|-
| colspan="2" | Default 800000 = Gain of 1X&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




===SetOffsetCalibration===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SetOffsetCalibration'''
|-
| colspan="2" | Allows the device offset to be entered allowing for accurate readings.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-s32-icon.png]] - LONG
| width="90%" | Offset
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


<span style="font-weight: normal;"><u>Oversampling Ratio</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''OversamplingRatio''.
==Property reference==


''<span style="color:red;">No additional information</span>''
{| class="mtx-class-macrotable wikitable"
 
|-
 
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
 
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
<span style="font-weight: normal;"><u>ADC Gain</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''ADCGain''.
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
 
| width="90%" class="mtx-class-propfolder" | Device Configuration
''<span style="color:red;">No additional information</span>''
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Device Type
<span style="font-weight: normal;"><u>IRQ Mode</u></span>
|-
 
| colspan="2" | &nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''IRQMode''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
''<span style="color:red;">No additional information</span>''
| width="90%" | Device Address
 
|-
 
| colspan="2" | These bits are fixed from the manufacturer and by default are 01. Used as Bits 6 and 7 of the command byte. Alternative bits must be requested from the manufacturer.&nbsp;
 
|-
<span style="font-weight: normal;"><u>Channel</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Clock Selection
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::CHANNEL''.
|-
 
| colspan="2" | &nbsp;
SPI Channel selector
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Prescale</u></span>
| width="90%" | Sensor Bias Current
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::PR_SCALE''.
| colspan="2" | &nbsp;
 
|-
Prescale option selector
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | ADC Bias Current
<span style="font-weight: normal;"><u>MOSI</u></span>
|-
 
| colspan="2" | &nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::MOSI''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
| width="90%" | AMCLK Prescaler
 
|-
<span style="font-weight: normal;"><u>MISO</u></span>
| colspan="2" | &nbsp;
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::MISO''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Oversampling Ratio
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
|-
 
| colspan="2" | &nbsp;
<span style="font-weight: normal;"><u>CLK</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::CLK''.
| width="90%" | ADC Gain
 
|-
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| colspan="2" | &nbsp;
 
|-
<span style="font-weight: normal;"><u>CS / SS</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | IRQ Mode
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::SS''.
|-
 
| colspan="2" | &nbsp;
Chip Select / Slave Select Pin  
|-
 
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
Master Mode: General purpose output pin used to select the remote SPI device.
| width="90%" class="mtx-class-propfolder" | Connections
 
|-
Slave Mode: Hardware chip select pin input used to select the SPI device.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Use IRQ</u></span>
| width="90%" | Channel
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''UseIRQ''.
| colspan="2" | SPI Channel selector&nbsp;
 
|-
No: Use polling of the status register to determine when an ADC sample is complete.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Prescale
Yes: Use the IRQ interrupt pin to determine when an ADC sample is complete.
|-
 
| colspan="2" | Prescale option selector&nbsp;
<span style="font-weight: normal;"><u>IRQ Pin</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''Single digital pin'' and can be referenced with the variable name ''IRQPin''.
| width="90%" | MOSI
 
|-
Connected to the IRQ pin of the device, goes low on an interrupt event such as sample complete.
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.&nbsp;
 
|-
<span style="font-weight: normal;"><u>Simulate Comms</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | MOSI Remap Pin
This property is of type ''True or false'' and can be referenced with the variable name ''SimComms''.
|-
 
| colspan="2" | Select which the target pin to assign the MOSI hardware pin functionality.&nbsp;
No: Simulation is done using panel sliders.
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
Yes: Send SPI data via API interface and show real time data using panel sliders.
| width="90%" | MISO
 
|-
<span style="font-weight: normal;"><u>Scope Traces</u></span>
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.&nbsp;
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi1::ScopeTraces''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | MISO Remap Pin
Selects if the scope traces are automatically generated or not
|-
 
| colspan="2" | Select which the target pin to assign the MISO hardware pin functionality.&nbsp;
<span style="font-weight: normal;"><u>Console Data</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi1::ConsoleData''.
| width="90%" | CLK
 
|-
Selects if the console data is automatically generated or not
| colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | CLK Remap Pin
|-
| colspan="2" | Select which the target pin to assign the CLK hardware pin functionality.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| width="90%" | CS / SS
|-
| colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device. &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Use IRQ
|-
| colspan="2" | No: Use polling of the status register to determine when an ADC sample is complete. Yes: Use the IRQ interrupt pin to determine when an ADC sample is complete.&nbsp;
|-
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Simulate Comms
|-
| colspan="2" | No: Simulation is done using panel sliders. Yes: Send SPI data via API interface and show real time data using panel sliders.&nbsp;
|}


<span style="font-weight: normal;"><u>API</u></span>
==Component Source Code==


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::Injector''.
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_ExternalADC_MCP356X.fcfx FC_Comp_Source_ExternalADC_MCP356X.fcfx]


Selects the API Slave to use to send and receive real world SPI data during simulation.
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_ExternalADC_MCP356X.fcfx FC_Comp_Source_ExternalADC_MCP356X.fcfx]

Latest revision as of 14:37, 13 July 2026

Author MatrixTSL
Version 1.0
Category Analog Input


ADC (MCP356X) component

An external ADC featuring 2, 4, or 8 channel 24-bit input. Capable of reading each channel independently or in differential mode. Communication using an SPI bus up to 20MHz.

Detailed description

No detailed description exists yet for this component

Examples

No additional examples






Macro reference

Initialise

Initialise
Confgures the SPI bus ready for communications and initialises the MCP356X device. Returns true if device is responding to commands. 
- BOOL Return


SampleADC

SampleADC
Performs a single ADC sample and returns the result as a 24-bit value 
- BYTE PositiveChannel
0=CH0 - 7=CH7, 8=GND, 9=VDD, 11=REF+, 12=REF-, 13=TP, 14=TM, 15=VCM 
- BYTE NegativeChannel
0=CH0 - 7=CH7, 8=GND, 9=VDD, 11=REF+, 12=REF-, 13=TP, 14=TM, 15=VCM 
- LONG Return


SetGainCalibration

SetGainCalibration
Allows the device offset to be entered allowing for accurate readings. 
- ULONG Gain
Default 800000 = Gain of 1X 
- VOID Return


SetOffsetCalibration

SetOffsetCalibration
Allows the device offset to be entered allowing for accurate readings. 
- LONG Offset
 
- VOID Return


Property reference

Properties
Device Configuration
Device Type
 
Device Address
These bits are fixed from the manufacturer and by default are 01. Used as Bits 6 and 7 of the command byte. Alternative bits must be requested from the manufacturer. 
Clock Selection
 
Sensor Bias Current
 
ADC Bias Current
 
AMCLK Prescaler
 
Oversampling Ratio
 
ADC Gain
 
IRQ Mode
 
Connections
Channel
SPI Channel selector 
Prescale
Prescale option selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MOSI Remap Pin
Select which the target pin to assign the MOSI hardware pin functionality. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
MISO Remap Pin
Select which the target pin to assign the MISO hardware pin functionality. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
CLK Remap Pin
Select which the target pin to assign the CLK hardware pin functionality. 
CS / SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
Use IRQ
No: Use polling of the status register to determine when an ADC sample is complete. Yes: Use the IRQ interrupt pin to determine when an ADC sample is complete. 
Simulation
Simulate Comms
No: Simulation is done using panel sliders. Yes: Send SPI data via API interface and show real time data using panel sliders. 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_ExternalADC_MCP356X.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_ExternalADC_MCP356X.fcfx