Jump to content

Component: DAC (AD5662) (Analog Output): Difference between revisions

From Flowcode Help
No edit summary
No edit summary
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 (AD5662) component==
==[[File:Component Icon 3d87ffe9_97c1_4013_a2cd_82c24d0ccb48.png|Image]] DAC (AD5662) component==
16-bit external DAC connected to the microcontroller using SPI.
16-bit external DAC connected to the microcontroller using SPI.


==Detailed description==
==Detailed description==


===Overview===
===Overview===
Line 36: Line 35:


==Examples==
==Examples==


This example reads a potentiometer that is connected across the supply voltage.
This example reads a potentiometer that is connected across the supply voltage.
Line 44: Line 45:
==Downloadable macro reference==
==Downloadable macro reference==


===<span style="font-weight: normal;"><u><tt>OutputDAC</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Outputs a value to the DAC,
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OutputDAC'''
|-
| colspan="2" | Outputs a value to the DAC, &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Output
|-
| colspan="2" | Range: 0-65535 / 0=0V / 65535=VCC&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''
|}


'''Parameters'''


:[[Variable Types|UINT]] ''Output''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Range: 0-65535 / 0=0V / 65535=VCC
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Initialise the SPI bus ready for communications,&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''
|}




'''Return value'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''BuzzerOn'''
|-
| colspan="2" | Switch On the Buzzer&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 call does not return a value''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''BuzzerOnDelay'''
|-
| colspan="2" | Switch the Buzzer on for a fixed amount of time&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Time
|-
| colspan="2" | Time in milliseconds to keep the buzzer on&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><tt>Initialise</tt></u></span>===
Initialise the SPI bus ready for communications,


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteLEDs'''
|-
| colspan="2" | Allows control of all 8-LEDs on the front of the Formula Flowcode.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | LED_Byte
|-
| 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''
|}


:''This macro has no parameters''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Starts up the formula flowcode PWM for motor control and performs the wait for button press&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''
|}


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


==Simulation macro reference==
''This component does not contain any simulation macros''




==Property reference==
==Property reference==
<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''.
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
SPI Channel selector
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
<span style="font-weight: normal;"><u>Prescale</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::PR_SCALE''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Channel
Prescale option selector
|-
 
| colspan="2" | SPI Channel selector&nbsp;
<span style="font-weight: normal;"><u>MOSI</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::MOSI''.
| width="90%" | Prescale
 
|-
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
| colspan="2" | Prescale option selector&nbsp;
 
|-
<span style="font-weight: normal;"><u>MISO</u></span>
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | MOSI
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::MISO''.
|-
 
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.&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-5-icon.png]]
<span style="font-weight: normal;"><u>CLK</u></span>
| width="90%" | MISO
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi1::CLK''.
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.&nbsp;
 
|-
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | CLK
<span style="font-weight: normal;"><u>CS / SS</u></span>
|-
 
| colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.&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-5-icon.png]]
Chip Select / Slave Select Pin  
| width="90%" | CS / SS
 
|-
Master Mode: General purpose output pin used to select the remote SPI device.
| 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;
 
|-
Slave Mode: Hardware chip select pin input used to select the SPI device.
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Console Data
<span style="font-weight: normal;"><u>Simulate Comms</u></span>
|-
 
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
This property is of type ''True or false'' and can be referenced with the variable name ''SimulateComms''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
''<span style="color:red;">No additional information</span>''
| width="90%" | Scope Traces
 
|-
 
| colspan="2" | Selects if the scope traces are automatically generated or not&nbsp;
 
|-
<span style="font-weight: normal;"><u>Console Data</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | API
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi1::ConsoleData''.
|-
 
| colspan="2" | &nbsp;
Selects if the console data is automatically generated or not
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
<span style="font-weight: normal;"><u>Scope Traces</u></span>
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi1::ScopeTraces''.
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
Selects if the scope traces are automatically generated or not
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
 
|-
<span style="font-weight: normal;"><u>Injector</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi1::Injector''.
| width="90%" | Data Recorder Trace
 
|-
''<span style="color:red;">No additional information</span>''
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Simulate Comms
|-
| colspan="2" | &nbsp;
|}

Revision as of 21:05, 16 November 2021

Author Matrix TSL
Version 1.0
Category Analog Output


DAC (AD5662) component

16-bit external DAC connected to the microcontroller using SPI.

Detailed description

Overview

The AD5662 is a 3V/5V general purpose SPI compatible, high-resolution digital to analog converter (DAC), capable of generating a rail-to-rail voltage output.

With 16-Bit resolution, the AD5662 is capable of finely tuning the voltage output across 65,536 steps, with an individual step voltage of 5/65536 = 0.0000763 volts DC.

The AD5662 requires an external reference voltage to set the output range of the DAC.


Pin reference from the datasheet:

Circuit Diagram

Examples

This example reads a potentiometer that is connected across the supply voltage. The output from the DAC should mimic the voltage that's across ADC pin & GND.

AD5662_Demo

Downloadable macro reference

OutputDAC
Outputs a value to the DAC,  
- UINT Output
Range: 0-65535 / 0=0V / 65535=VCC 
- VOID Return


Initialise
Initialise the SPI bus ready for communications, 
- VOID Return


BuzzerOn
Switch On the Buzzer 
- VOID Return


BuzzerOnDelay
Switch the Buzzer on for a fixed amount of time 
- UINT Time
Time in milliseconds to keep the buzzer on 
- VOID Return


WriteLEDs
Allows control of all 8-LEDs on the front of the Formula Flowcode. 
- BYTE LED_Byte
 
- VOID Return


Initialise
Starts up the formula flowcode PWM for motor control and performs the wait for button press 
- VOID Return



Property reference

Properties
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. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
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.  
Console Data
Selects if the console data is automatically generated or not 
Scope Traces
Selects if the scope traces are automatically generated or not 
API
 
Connections
Simulations
Data Recorder Trace
 
Simulate Comms