Jump to content

Component: DAC Dual (MCP48x2) (Analog Output): Difference between revisions

From Flowcode Help
XML import
 
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(21 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
| Matrix TSL
| Matrix TSL
|-
|-
| 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 Output
| Analog Output
|}
|}




==DAC Dual (MCP48x2) component==
Component to drive a dual digital to analogue converter (DAC) IC from Microchip via an SPI interface. Compatible with MCP4802 (8-Bit), MCP4812 (10-Bit) and MCP4822 (12-Bit) devices.


==[[File:Component Icon f484e96a_af4f_434e_a002_70d3f4315dfb.png|Image]] DAC Dual (MCP48x2) component==
==Component Source Code==
Component to drive a dual digital to analogue converter (DAC) IC from Microchip via an SPI interface.
Compatible with MCP4802 (8-Bit), MCP4812 (10-Bit) and MCP4822 (12-Bit) devices.


==Examples==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_DAC_MCP48x2.fcfx FC_Comp_Source_DAC_MCP48x2.fcfx]
''<span style="color:red;">No additional examples</span>''


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_DAC_MCP48x2.fcfx FC_Comp_Source_DAC_MCP48x2.fcfx]


==Downloadable macro reference==
==Detailed description==


===<span style="font-weight: normal;"><u><tt>SetOutput</tt></u></span>===
Sets the output voltage of the DAC


8-Bit: Range 0-255


10-Bit: Range 0-1023


12-Bit: Range 0-4095


'''Parameters'''


:[[Variable Types|BYTE]] ''Channel''
::0=DAC Channel 0 , 1=DAC Channel 1


:[[Variable Types|UINT]] ''DAC_Value''
::The value to output to the DAC




'''Return value'''


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>ControlPins</tt></u></span>===
Allows Shutdown (SHDN) and Latch (LDAC) pins to be controlled directly if enabled.


'''Parameters'''


:[[Variable Types|BOOL]] ''Shutdown''
::0 = Shutdown Device, 1 = Device Active


:[[Variable Types|BOOL]] ''Latch''
::0 = Data output driven from DAC register, 1 = Data output locked




'''Return value'''


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>Disable</tt></u></span>===
Disables the DAC output.


'''Parameters'''


:[[Variable Types|BYTE]] ''Channel''
::0=DAC Channel 0 , 1=DAC Channel 1


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


'''Return value'''
==Examples==


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>Enable</tt></u></span>===
Enables the DAC Output.


'''Parameters'''


:[[Variable Types|BYTE]] ''Channel''
::0=DAC Channel 0 , 1=DAC Channel 1




'''Return value'''


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Configures the SPI peripheral ready for communications and initialises the internal variables. DAC needs to be enabled before any output voltage can be generated.


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


:''This call does not return a value''






==Simulation macro reference==


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




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


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


Selects which DAC IC is connected and therefore the bit depth available.


<span style="font-weight: normal;"><u>Gain Option</u></span>
''<span style="color:red;">No additional examples</span>''


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


Selects the maximum reference value for the DAC


<span style="font-weight: normal;"><u>Vref Voltage</u></span>


This property is of type ''Floating point'' and can be referenced with the variable name ''VrefVol''.


Reference Voltage, Used to calculate the Voltage resolution.


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


This property is of type ''Unsigned integer'' and can be referenced with the variable name ''Steps''.


Number of discrete output states available from the DAC.


<span style="font-weight: normal;"><u>Control Bits</u></span>


This property is of type ''Signed integer'' and can be referenced with the variable name ''BITS''.


Number of digital control bits


<span style="font-weight: normal;"><u>Resolution</u></span>
==Macro reference==


This property is of type ''Line of text'' and can be referenced with the variable name ''Res''.
===ControlPins===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''ControlPins'''
|-
| colspan="2" | Allows Shutdown (SHDN) and Latch (LDAC) pins to be controlled directly if enabled.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | Shutdown
|-
| colspan="2" | 0 = Shutdown Device, 1 = Device Active&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | Latch
|-
| colspan="2" | 0 = Data output driven from DAC register, 1 = Data output locked&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''
|}


Maximum output resolution based on number of control bits.


<span style="font-weight: normal;"><u>Voltage Resolution</u></span>
===Disable===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''Disable'''
|-
| colspan="2" | Disables the DAC output.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | 0=DAC Channel 0 , 1=DAC Channel 1&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''
|}


This property is of type ''Floating point'' and can be referenced with the variable name ''VoltRes''.


Specifies the Resolution per digital bit in terms of Voltage.
===Enable===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''Enable'''
|-
| colspan="2" | Enables the DAC Output.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | 0=DAC Channel 0 , 1=DAC Channel 1&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>Channel</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::CHANNEL''.
===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" | Configures the SPI peripheral ready for communications and initialises the internal variables. DAC needs to be enabled before any output voltage can be generated.&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''
|}


SPI Channel selector


<span style="font-weight: normal;"><u>Prescale</u></span>
===SetOutput===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SetOutput'''
|-
| colspan="2" | Sets the output voltage of the DAC 8-Bit: Range 0-255 10-Bit: Range 0-1023 12-Bit: Range 0-4095&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | 0=DAC Channel 0 , 1=DAC Channel 1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | DAC_Value
|-
| colspan="2" | The value to output to the DAC&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''
|}


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


Prescale option selector
==Property reference==


<span style="font-weight: normal;"><u>MOSI</u></span>
{| class="mtx-class-macrotable wikitable"
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::MOSI''.
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
 
| width="90%" class="mtx-class-macrohead" | '''Properties'''
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
|-
 
|-
<span style="font-weight: normal;"><u>MISO</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | DAC IC
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::MISO''.
|-
 
| colspan="2" | Selects which DAC IC is connected and therefore the bit depth available.&nbsp;
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>CLK</u></span>
| width="90%" | Gain Option
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::CLK''.
| colspan="2" | Selects the maximum reference value for the DAC&nbsp;
 
|-
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
 
| width="90%" | Vref Voltage
<span style="font-weight: normal;"><u>CS / SS</u></span>
|-
 
| colspan="2" | Reference Voltage, Used to calculate the Voltage resolution.&nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::SS''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
Chip Select / Slave Select Pin  
| width="90%" | Steps
 
|-
Master Mode: General purpose output pin used to select the remote SPI device.
| colspan="2" | Number of discrete output states available from the DAC.&nbsp;
 
|-
Slave Mode: Hardware chip select pin input used to select the SPI device.
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
| width="90%" | Control Bits
<span style="font-weight: normal;"><u>Use SHDN Pin</u></span>
|-
 
| colspan="2" | Number of digital control bits&nbsp;
This property is of type ''True or false'' and can be referenced with the variable name ''UseSHDN''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
Allows the SHDN pin to be driven from an output pin on the microcontroller.
| width="90%" | Resolution
 
|-
If not used then tie the SHDN pin to VCC to allow the DAC to function.
| colspan="2" | Maximum output resolution based on number of control bits.&nbsp;
 
|-
<span style="font-weight: normal;"><u>Use LDAC Pin</u></span>
| width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
 
| width="90%" | Voltage Resolution
This property is of type ''True or false'' and can be referenced with the variable name ''UseLDAC''.
|-
 
| colspan="2" | Specifies the Resolution per digital bit in terms of Voltage.&nbsp;
Allows the LDAC pin to be driven from an output pin on the microcontroller.
|-
 
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
If not used then tie the LDAC pin to GND to allow the DAC to function.
| width="90%" class="mtx-class-propfolder" | SPI Connections
 
|-
<span style="font-weight: normal;"><u>DAC Output Scope Traces</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''True or false'' and can be referenced with the variable name ''ScopeTraces''.
| width="90%" | Channel
 
|-
Selects if the scope traces are automatically generated or not
| colspan="2" | SPI Channel selector&nbsp;
 
|-
<span style="font-weight: normal;"><u>SPI Scope Traces</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Prescale
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi1::ScopeTraces''.
|-
 
| colspan="2" | Prescale option selector&nbsp;
Selects if the scope traces are automatically generated or not
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
<span style="font-weight: normal;"><u>SPI Console Data</u></span>
| width="90%" | MOSI
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi1::ConsoleData''.
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.&nbsp;
 
|-
Selects if the console data is automatically generated or not
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | MOSI Remap Pin
<span style="font-weight: normal;"><u>Injector</u></span>
|-
 
| colspan="2" | Select which the target pin to assign the MOSI hardware pin functionality.&nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::Injector''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
''<span style="color:red;">No additional information</span>''
| width="90%" | MISO
|-
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | MISO Remap Pin
|-
| colspan="2" | Select which the target pin to assign the MISO hardware pin functionality.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| width="90%" | CLK
|-
| 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 SHDN Pin
|-
| colspan="2" | Allows the SHDN pin to be driven from an output pin on the microcontroller. If not used then tie the SHDN pin to VCC to allow the DAC to function.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Use LDAC Pin
|-
| colspan="2" | Allows the LDAC pin to be driven from an output pin on the microcontroller. If not used then tie the LDAC pin to GND to allow the DAC to function.&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%" | Simulation Comms
|-
| colspan="2" | &nbsp;
|}

Latest revision as of 14:37, 13 July 2026

Author Matrix TSL
Version 1.0
Category Analog Output


DAC Dual (MCP48x2) component

Component to drive a dual digital to analogue converter (DAC) IC from Microchip via an SPI interface. Compatible with MCP4802 (8-Bit), MCP4812 (10-Bit) and MCP4822 (12-Bit) devices.

Component Source Code

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

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

Detailed description

No detailed description exists yet for this component

Examples

No additional examples







Macro reference

ControlPins

ControlPins
Allows Shutdown (SHDN) and Latch (LDAC) pins to be controlled directly if enabled. 
- BOOL Shutdown
0 = Shutdown Device, 1 = Device Active 
- BOOL Latch
0 = Data output driven from DAC register, 1 = Data output locked 
- VOID Return


Disable

Disable
Disables the DAC output. 
- BYTE Channel
0=DAC Channel 0 , 1=DAC Channel 1 
- VOID Return


Enable

Enable
Enables the DAC Output. 
- BYTE Channel
0=DAC Channel 0 , 1=DAC Channel 1 
- VOID Return


Initialise

Initialise
Configures the SPI peripheral ready for communications and initialises the internal variables. DAC needs to be enabled before any output voltage can be generated. 
- VOID Return


SetOutput

SetOutput
Sets the output voltage of the DAC 8-Bit: Range 0-255 10-Bit: Range 0-1023 12-Bit: Range 0-4095 
- BYTE Channel
0=DAC Channel 0 , 1=DAC Channel 1 
- UINT DAC_Value
The value to output to the DAC 
- VOID Return


Property reference

Properties
DAC IC
Selects which DAC IC is connected and therefore the bit depth available. 
Gain Option
Selects the maximum reference value for the DAC 
Vref Voltage
Reference Voltage, Used to calculate the Voltage resolution. 
Steps
Number of discrete output states available from the DAC. 
Control Bits
Number of digital control bits 
Resolution
Maximum output resolution based on number of control bits. 
Voltage Resolution
Specifies the Resolution per digital bit in terms of Voltage. 
SPI 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 SHDN Pin
Allows the SHDN pin to be driven from an output pin on the microcontroller. If not used then tie the SHDN pin to VCC to allow the DAC to function. 
Use LDAC Pin
Allows the LDAC pin to be driven from an output pin on the microcontroller. If not used then tie the LDAC pin to GND to allow the DAC to function. 
Simulation
Simulation Comms