Difference between revisions of "Component: Input ADC (DSP)"

From Flowcode Help
Jump to navigationJump to search
(Created page with "{| style="width:50%" |- | width="20%" style="color:gray;" | Author | Matrix Ltd |- | width="20%" style="color:gray;" | Version | 1.2 |- | width="20%" style="color:gray...")
Line 21: Line 21:
 
==Examples==
 
==Examples==
  
 
+
''<span style="color:red;">No additional examples</span>''
 
 
Some examples containing the Input ADC component.
 
 
 
{{fcfile|On_Off_Control_Sim.fcfx|On Off Control}}
 
 
 
{{fcfile|PID_Control_Sim.fcfx|PID Control}}
 
  
 
==Downloadable macro reference==
 
==Downloadable macro reference==
Line 78: Line 72:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Send'''
 
|-
 
|-
| colspan="2" | Configures the UART serial interface.&nbsp;
+
| colspan="2" | Send the Character &nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
+
| width="90%" | Char
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
 
|-
 
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
+
| colspan="2" | The Character to send&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetError'''
 
 
|-
 
|-
| colspan="2" | Checks for any errors and returns the error code. 1=ModuleBusy, 2=SleepMode, 3=SerialError, 4=ChecksumError, 5=TrackOutOfScope, 6=TrackNotFound, 7=InsertionError, 8=SDFail, 10=Sleep&nbsp;
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
Line 104: Line 90:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WhilePlaying'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetConsoleHandle'''
 
|-
 
|-
| colspan="2" | Blocking function that waits for module to stop being busy. Returns true if the module is still busy and the timeout period has passed.&nbsp;
+
| colspan="2" | &nbsp;
 
|-
 
|-
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | Timeout
 
|-
 
| colspan="2" | Number of milliseconds to wait, 0=WaitForever&nbsp;
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -  
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -  
Line 122: Line 103:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''IsPlaying'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendByteArray'''
 
|-
 
|-
| colspan="2" | Checks to see if the last played track is still playing&nbsp;
+
| colspan="2" | Transmits an array of bytes via the UART peripheral&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
+
| width="90%" | Data
|}
 
 
 
 
 
{| 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;" | '''GetReplyByte'''
 
 
|-
 
|-
| colspan="2" | Reads a single byte from the last reply. Each reply contains 4 bytes starting with the command code.&nbsp;
+
| colspan="2" | Data to transmit&nbsp;
 
|-
 
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | NumBytes
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| colspan="2" | Number of bytes to send from the array&nbsp;
| width="90%" | Index
 
 
|-
 
|-
| colspan="2" | Range: 0-3 / 0=Command, 1=Feedback, 2=Data MSB, 3=Data LSB&nbsp;
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
Line 153: Line 126:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SkipTrack'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Init'''
 
|-
 
|-
| colspan="2" | Jump to the next or previous track&nbsp;
+
| colspan="2" | Initialize the component with the specified properties&nbsp;
 
|-
 
|-
|-
 
| width="10%" align="center" | [[File:]] -
 
| width="90%" | Direction
 
|-
 
| colspan="2" | 0=Next, 1=Previous&nbsp;
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 171: Line 139:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PlayTrack'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Uninit'''
|-
 
| colspan="2" | Plays track from the selected folder. MP3 & Advert folder track numbers should be 4 characters long e.g. 0001 any name.mp3, Other folder track numbers should be 3 characters long e.g. 001 Any name.mp3, Root the Track played in placement order.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Directory
 
|-
 
| colspan="2" | 0=Root, 1=Folder "01" - 99=Folder "99", 100=MP3, 101=Advert&nbsp;
 
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
+
| colspan="2" | Un-initialize the UART and release the resources&nbsp;
| width="90%" | Track
 
 
|-
 
|-
| colspan="2" | Track number 1="001*.MP3" / "0001*.MP3", 100="100*.MP3" / "0100*.MP3"&nbsp;
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 194: Line 152:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveByteArray'''
 
|-
 
|-
| colspan="2" | Sets up the UART and does some housekeeping. Must be called before calling any of the other component macros.&nbsp;
+
| colspan="2" | Receives an array of bytes and returns the number of bytes received.&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
+
| width="90%" | Data
|}
 
 
 
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
 
|-
 
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
+
| colspan="2" | A byte array variable to hold the received data&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAnalogAsInt'''
 
 
|-
 
|-
| colspan="2" | Reads one of the analogue components as an Integer value&nbsp;
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | NumBytes
 
|-
 
|-
 +
| colspan="2" | Maximum number of bytes to try and receive&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Channel
+
| width="90%" | Timeout
 
|-
 
|-
| colspan="2" | 0 = LDR, 1 = POT&nbsp;
+
| colspan="2" | Max amount of time in ms to wait between bytes&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -  
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
Line 225: Line 180:
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RemapCharacter'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveString'''
 
|-
 
|-
| colspan="2" | Assigns a remap character allowing the PrintString function to automatically swap between pre-defined characters.  The characters can be custom (in the range 0-9) or can point to an existing character in the LCD character map.&nbsp;
+
| colspan="2" | Receives a string of bytes and returns the number of bytes received.&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" | RemapIdx
+
| width="90%" | StringData
 
|-
 
|-
| colspan="2" | Remap Index, Range: 0 to (Remap Characters - 1)&nbsp;
+
| colspan="2" | &nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | SearchCharacter
+
| width="90%" | NumBytes
 
|-
 
|-
| colspan="2" | Character to look for a replace&nbsp;
+
| colspan="2" | Maximum number of bytes to try and receive&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | ReplacementCharacter
+
| width="90%" | Timeout
 
|-
 
|-
| colspan="2" | New character value to use in place of the search character.&nbsp;
+
| colspan="2" | Max amount of time in ms to wait between bytes&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
Line 287: Line 242:
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| 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''
 +
|}
 +
 +
 +
{| 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;" | '''GetRxIdent'''
 +
|-
 +
| colspan="2" | Gets the Rx ID as a Integer Standard and Extended IDs.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}

Revision as of 10:35, 17 November 2021

Author Matrix Ltd
Version 1.2
Category DSP


Input ADC component

Allows the values from a buffer to be assigned driectly from an analog enabled pin. Either a single sample at a time or a number of samples. Auto scales the digital value to fill the entire range of the specified buffer type.

Detailed description

No detailed description exists yet for this component

Examples

No additional examples

Downloadable macro reference

Fc9-comp-macro.png AddSample
Adds a single ADC sample to the current location in the specified buffer. If Auto Scale is enabled then the sample will be scaled to correctly fit inside the buffer. Auto increments current location. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png AddSampleArray
Adds a single ADC sample to the current location in the specified buffer. If Auto Scale is enabled then the sample will be scaled to correctly fit inside the buffer. Auto increments current location. 
Fc9-u16-icon.png - UINT SampleDelay
Number of us in between each sample. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Configures the UART serial interface. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Send
Send the Character  
Fc9-u16-icon.png - UINT Char
The Character to send 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png GetConsoleHandle
 
[[File:]] - Return


Fc9-comp-macro.png SendByteArray
Transmits an array of bytes via the UART peripheral 
Fc9-u8-icon.png - BYTE Data
Data to transmit 
Fc9-u16-icon.png - UINT NumBytes
Number of bytes to send from the array 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Init
Initialize the component with the specified properties 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Uninit
Un-initialize the UART and release the resources 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReceiveByteArray
Receives an array of bytes and returns the number of bytes received. 
Fc9-u8-icon.png - BYTE Data
A byte array variable to hold the received data 
Fc9-u16-icon.png - UINT NumBytes
Maximum number of bytes to try and receive 
Fc9-u16-icon.png - UINT Timeout
Max amount of time in ms to wait between bytes 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png ReceiveString
Receives a string of bytes and returns the number of bytes received. 
Fc9-string-icon.png - STRING StringData
 
Fc9-u16-icon.png - UINT NumBytes
Maximum number of bytes to try and receive 
Fc9-u16-icon.png - UINT Timeout
Max amount of time in ms to wait between bytes 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png Start
Startup routine required by the hardware device. Automatically clears the display after initialising. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetLEDState
Sets the state of a single LED 
Fc9-u8-icon.png - BYTE Port
0 = PortA, 1 = PortB 
Fc9-u8-icon.png - BYTE LED
0 = LED0, 7 = LED7 
Fc9-u8-icon.png - BYTE State
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png GetRxIdent
Gets the Rx ID as a Integer Standard and Extended IDs. 
Fc9-u8-icon.png - BYTE Buffer
 
Fc9-u32-icon.png - ULONG Return


Fc9-comp-macro.png Initialise
Must be called before any other CAN component macros to enable and initialise the CAN peripheral.  
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-21-icon.png Buffer Size
Number of individual elements the buffer can store, default 1. 
Fc9-type-16-icon.png Buffer Type
Sets the buffer data type, data is automatically scaled to fit and make full use of the data type. 
Fc9-type-16-icon.png VRef option
Defines what is used as the ADC maximum reference. ADC Range = GND to VRef Voltage VDD - Defines the microcontrollers power supply pin as the max reference, VREF+ Pin - Dedicated pin on the microcontroller to allow for a variable reference voltage. 
Fc9-type-16-icon.png Conversion speed
Clock setting to select how fast the ADC peripheral will perform an ADC conversion. The FRC setting is based on a RC time base and so will vary with temperature and pressure. Other settings are generally based on divisions of the master clock. 
Fc9-type-14-icon.png Acquisition cycles
Number of micro seconds to wait for the ADC input to charge before starting the analogue sample. 
Fc9-type-14-icon.png Bit Depth
Maximum number of digital bits the ADC can sample. 8 bit = ADC range 0 - 255 10 bit = ADC range 0 - 1023 12 bit = ADC range 0 - 4095 
Fc9-conn-icon.png Connections
Fc9-type-6-icon.png Channel
Analogue Input Channel - Which pin is the analogue input connected to? 
Fc9-conn-icon.png Simulations