Jump to content

Component: UART (RS232) (Comms: Interface): 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 Ltd
| Matrix Ltd
|-
|-
| width="20%" style="color: gray;" | Version
| width="20%" style="color:gray;" | Version
| 2.0 (Release)
| 3.0
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| Comms: Interface
| Comms: Interface
|}
|}




==UART (RS232) component==
Low level routines for controlling or interacting with a standard asyncronous serial interface. On a microcontroller the interface will be the onboard UART which will need voltage level shifting using a max2323 to become RS232 compatible. See the EB015 RS232 E-block for details.
==Detailed description==


==[[File:Component Icon c73616d1_7ad0_45d9_aada_69ccfa4c5efc.png|Image]] UART (RS232) component==
Low level routines for controlling or interacting with a standard asyncronous serial interface.
On a microcontroller the interface will be the onboard UART which will need voltage level shifting using a max2323 to become RS232 compatible.
See the EB015 RS232 E-block for details.


==Detailed description==


===Overview===
===Overview===
Line 61: Line 58:


==Examples==
==Examples==
===Transmit===
===Transmit===


Line 113: Line 112:
==Downloadable macro reference==
==Downloadable macro reference==


===<span style="font-weight: normal;"><u><tt>SendString</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Sends out a string of bytes from the UART interface.
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendString'''
|-
| colspan="2" | Sends out a string of bytes from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" | Data
|-
| 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''
|}


'''Parameters'''


:[[Variable Types|<- STRING]] ''Data''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::''This parameter may be returned back to the caller''
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveINTArray'''
|-
| colspan="2" | Receives an array of 16-bit INT/UINT values and returns the number of values received.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Data
|-
| colspan="2" | Array to store the incoming data&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NumValues
|-
| colspan="2" | Maximum number of values to try and receive&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| 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-u8-icon.png]] - BYTE
| 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;" | '''ReceiveNumber'''
|-
| colspan="2" | Attempts to receive a number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | Max time in ms to wait in between bytes&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | IgnoreData
|-
| colspan="2" | 0=Dont ignore any data, 1=Ignore any initial none numeric data&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
| 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;" | '''SendBinary16Bit'''
|-
| colspan="2" | Sends out a 16-bit binary value split across two bytes.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Value
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&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>ReceiveINTArray</tt></u></span>===
Receives an array of 16-bit INT/UINT values and returns the number of values received.


'''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;" | '''SendINTArray'''
|-
| colspan="2" | Transmits an array of 16-bit INT/UINT values via the UART peripheral&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Data
|-
| colspan="2" | Data to transmit&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NumValues
|-
| colspan="2" | Number of 16-bit values to send from the array&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&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''
|}


:[[Variable Types|UINT]] ''Data''
::Array to store the incoming data


:[[Variable Types|BYTE]] ''NumValues''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Maximum number of values to try and receive
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendNumber'''
|-
| colspan="2" | Sends out a number as an ASCII String from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | Number
|-
| 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''
|}


:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first


:[[Variable Types|BYTE]] ''Timeout''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Max amount of time in ms to wait between bytes
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveBinary32Bit'''
|-
| colspan="2" | Receives a binary 32-bit value split across four bytes.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| 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-u32-icon.png]] - ULONG
| 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;" | '''ReceiveBinaryFloat'''
|-
| colspan="2" | Receives a binary 32-bit floating point value split across four bytes.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| 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="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]]


{| 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;" | '''SendChar'''
|-
| colspan="2" | Sends out a single packet from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | Char
|-
| 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><tt>ReceiveNumber</tt></u></span>===
Attempts to receive a number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost.


'''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;" | '''SendByteArray'''
|-
| colspan="2" | Transmits an array of bytes via the UART peripheral&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Data
|-
| colspan="2" | Data to transmit&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NumBytes
|-
| colspan="2" | Number of bytes to send from the array&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''
|}


:[[Variable Types|BYTE]] ''Timeout''
::Max time in ms to wait in between bytes


:[[Variable Types|BOOL]] ''IgnoreData''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::0=Dont ignore any data, 1=Ignore any initial none numeric data
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveBinary16Bit'''
|-
| colspan="2" | Receives a binary 16-bit value split across two bytes.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| 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-u16-icon.png]] - UINT
| 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;" | '''ChangeHWBaud'''
|-
| colspan="2" | Changes the hardware UART baud rate allowing for dynamic speed changes. &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NewBaud
|-
| colspan="2" | 0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200, 8=250000&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''
|}


:[[Variable Types|LONG]]


{| 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;" | '''ReceiveFloat'''
|-
| colspan="2" | Attempts to receive a floating point number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | Max time in ms to wait in between bytes&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | IgnoreData
|-
| colspan="2" | 0=Dont ignore any data, 1=Ignore any initial none numeric data&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


===<span style="font-weight: normal;"><u><tt>SendBinary16Bit</tt></u></span>===
Sends out a 16-bit binary value split across two bytes.


'''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;" | '''SendFloat'''
|-
| colspan="2" | Sends out a floating point number as an ASCII String from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | Number
|-
| 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''
|}


:[[Variable Types|UINT]] ''Value''


:[[Variable Types|BOOL]] ''MSBfirst''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::0=Least significant byte first, 1=Most significant byte first
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendHexNumber'''
|-
| colspan="2" | Sends out a number as an ASCII hexadecimal String from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Number
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NumChars
|-
| colspan="2" | Number of characters in the string data, 0 for auto, 2 for 0x00, 4 for 0x0000&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | Prefix
|-
| colspan="2" | Generate hexadecimal prefix 0x e.g. 1= 0xFF, 0= FF&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;" | '''ReceiveHexNumber'''
|-
| colspan="2" | Attempts to receive a hex number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none hexadecimal char is received, the none numeric char will be lost.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | Max time in ms to wait in between bytes&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | IgnoreData
|-
| colspan="2" | 0=Dont ignore any data, 1=Ignore any initial none numeric data&nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | Prefix
|-
| colspan="2" | Look for prefix before receiving, 1=0xFF, 0=FF&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''
|}


:''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;" | '''SendBinary32Bit'''
|-
| colspan="2" | Sends out a 32-bit binary value split across four bytes.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Value
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&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>SendINTArray</tt></u></span>===
Transmits an array of 16-bit INT/UINT values via the UART peripheral


'''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;" | '''SendBinaryFloat'''
|-
| colspan="2" | Sends out a 32-bit binary floating point value split across four bytes.&nbsp;
|-
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | Value
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:]] -
| width="90%" | MSBfirst
|-
| colspan="2" | 0=Least significant byte first, 1=Most significant byte first&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''
|}


:[[Variable Types|UINT]] ''Data''
::Data to transmit


:[[Variable Types|BYTE]] ''NumValues''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Number of 16-bit values to send from the array
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveByteArray'''
|-
| colspan="2" | Receives an array of bytes and returns the number of bytes received.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Data
|-
| colspan="2" | Array to store the incoming data&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| 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="90%" | Timeout
|-
| 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-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first


{| 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;" | '''ReceiveString'''
|-
| colspan="2" | Attempts to receive a string of bytes from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | Time to wait in milliseconds for valid data before returning, 0=Dont wait, 255=Wait forever.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | NumBytes
|-
| colspan="2" | The number of bytes to try and receive, ideally your string variable should have at least 1 more byte to store the null termination byte&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Return value'''


:''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;" | '''Initialise'''
|-
| colspan="2" | Sets up the RS232 peripheral, must be called at the start of your program or at least before you start calling any other RS232 macros.&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>SendNumber</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Sends out a number as an ASCII String from the UART interface.
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveChar'''
|-
| colspan="2" | Attempts to receive a single packet from the UART interface.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | Time to wait in milliseconds for valid data before returning, 0=Dont wait, 255=Wait forever.&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Parameters'''


:[[Variable Types|LONG]] ''Number''
{| 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;" | '''ReceiveString'''
|-
| colspan="2" | Puts the RF module in data mode and attempts to receive a string of bytes from the RF connection.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Length
|-
| colspan="2" | Specifies the maximum number of bytes to try and receive&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | Specifies how many milliseconds to wait for valid data before returning.&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| 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;" | '''Initialise'''
|-
| colspan="2" | Starts up and configures the RF module ready for use. The macro will return a value greater then 0 if the module has been started correctly, otherwise the macro will return a 0.&nbsp;
|-
|-
| 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''
|}


:''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;" | '''Initialise'''
|-
| colspan="2" | Sets up the 1-Wire output pin 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''
|}


===<span style="font-weight: normal;"><u><tt>ReceiveBinary32Bit</tt></u></span>===
Receives a binary 32-bit value split across four bytes.


'''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 UART to allow communications and initialises the states of the various  Modbus Coils, Inputs and Registers to 0.&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''
|}


:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first


:[[Variable Types|BYTE]] ''Timeout''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Max amount of time in ms to wait between bytes
|-
| 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" | Initialises the MIDI component and sets up the UART.&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;" | '''CommsBaud'''
|-
| colspan="2" | Sets the Baud rate of the alt communications channel&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Baud
|-
| colspan="2" | Range: 0-7 : 0=1200 / 7=115200&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''
|}


:[[Variable Types|ULONG]]


{| 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;" | '''LCDOptions'''
|-
| colspan="2" | Controls some of the LCD options&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Foreground
|-
| colspan="2" | Range: 0-1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Background
|-
| colspan="2" | Range: 0-1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Transparent
|-
| colspan="2" | Range: 0-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><tt>ReceiveBinaryFloat</tt></u></span>===
Receives a binary 32-bit floating point value split across four bytes.


'''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;" | '''LCDVerbose'''
|-
| colspan="2" | Controls the Verbose mode.  When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Mode
|-
| colspan="2" | Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode&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''
|}


:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first


:[[Variable Types|BYTE]] ''Timeout''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Max amount of time in ms to wait between bytes
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInput'''
|-
| colspan="2" | Reads a single digital input.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| 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''
|}




'''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;" | '''PWMConfig'''
|-
| colspan="2" | Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 :  0=1:1 1=1:8 2=1:64 3=1:256&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Range 0-1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Period
|-
| colspan="2" | Range: 0-65535&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Scaler
|-
| colspan="2" | Range: 0-3&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''
|}


:[[Variable Types|FLOAT]]


{| 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;" | '''PWMEnable'''
|-
| colspan="2" | Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | EnableMask
|-
| colspan="2" | Range 0-63 or 0b00000 to 0b111111&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>SendChar</tt></u></span>===
Sends out a single packet from the UART interface.


'''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;" | '''PWMDuty'''
|-
| colspan="2" | Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Range 0-5&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Duty
|-
| 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''
|}


:[[Variable Types|INT]] ''Char''


{| 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;" | '''LCDCursor'''
|-
| colspan="2" | Sets the cursor position for the MIAC display&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | X
|-
| colspan="2" | Range: 0-21&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Y
|-
| colspan="2" | Range: 0-4&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''
{| 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;" | '''WriteTran'''
|-
| colspan="2" | Allows a single transistor output to be switched on or off.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Range 1-4&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Value
|-
| colspan="2" | 0 = Off, 1 = 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>SendByteArray</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Transmits an array of bytes via the UART peripheral
|-
| 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" | &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|BYTE]] ''Data''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Data to transmit
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
:[[Variable Types|BYTE]] ''NumBytes''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDClear'''
::Number of bytes to send from the array
|-
 
| colspan="2" | Clears the MIAC display&nbsp;
 
|-
'''Return value'''
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
:''This call does not return a value''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
===<span style="font-weight: normal;"><u><tt>ReceiveBinary16Bit</tt></u></span>===
Receives a binary 16-bit value split across two bytes.
 
'''Parameters'''
 
:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first
 
:[[Variable Types|BYTE]] ''Timeout''
::Max amount of time in ms to wait between bytes
 
 
'''Return value'''
 
:[[Variable Types|UINT]]
 
 
===<span style="font-weight: normal;"><u><tt>ChangeHWBaud</tt></u></span>===
Changes the hardware UART baud rate allowing for dynamic speed changes.
 
'''Parameters'''
 
:[[Variable Types|BYTE]] ''NewBaud''
::0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200, 8=250000
 
 
'''Return value'''
 
:''This call does not return a value''
 
 
===<span style="font-weight: normal;"><u><tt>ReceiveFloat</tt></u></span>===
Attempts to receive a floating point number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost.
 
'''Parameters'''
 
:[[Variable Types|BYTE]] ''Timeout''
::Max time in ms to wait in between bytes
 
:[[Variable Types|BOOL]] ''IgnoreData''
::0=Dont ignore any data, 1=Ignore any initial none numeric data
 
 
'''Return value'''
 
:[[Variable Types|FLOAT]]
 
 
===<span style="font-weight: normal;"><u><tt>SendFloat</tt></u></span>===
Sends out a floating point number as an ASCII String from the UART interface.
 
'''Parameters'''
 
:[[Variable Types|FLOAT]] ''Number''
 
 
'''Return value'''
 
:''This call does not return a value''
 
 
===<span style="font-weight: normal;"><u><tt>SendHexNumber</tt></u></span>===
Sends out a number as an ASCII hexadecimal String from the UART interface.


'''Parameters'''


:[[Variable Types|ULONG]] ''Number''
:[[Variable Types|BYTE]] ''NumChars''
::Number of characters in the string data, 0 for auto, 2 for 0x00, 4 for 0x0000
:[[Variable Types|BOOL]] ''Prefix''
::Generate hexadecimal prefix 0x e.g. 1= 0xFF, 0= FF
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>ReceiveHexNumber</tt></u></span>===
Attempts to receive a hex number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none hexadecimal char is received, the none numeric char will be lost.
'''Parameters'''
:[[Variable Types|BYTE]] ''Timeout''
::Max time in ms to wait in between bytes
:[[Variable Types|BOOL]] ''IgnoreData''
::0=Dont ignore any data, 1=Ignore any initial none numeric data
:[[Variable Types|BOOL]] ''Prefix''
::Look for prefix before receiving, 1=0xFF, 0=FF
'''Return value'''
:[[Variable Types|ULONG]]
===<span style="font-weight: normal;"><u><tt>SendBinary32Bit</tt></u></span>===
Sends out a 32-bit binary value split across four bytes.
'''Parameters'''
:[[Variable Types|ULONG]] ''Value''
:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>SendBinaryFloat</tt></u></span>===
Sends out a 32-bit binary floating point value split across four bytes.
'''Parameters'''
:[[Variable Types|FLOAT]] ''Value''
:[[Variable Types|BOOL]] ''MSBfirst''
::0=Least significant byte first, 1=Most significant byte first
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>ReceiveByteArray</tt></u></span>===
Receives an array of bytes and returns the number of bytes received.
'''Parameters'''
:[[Variable Types|BYTE]] ''Data''
::Array to store the incoming data
:[[Variable Types|BYTE]] ''NumBytes''
::Maximum number of bytes to try and receive
:[[Variable Types|BYTE]] ''Timeout''
::Max amount of time in ms to wait between bytes
'''Return value'''
:[[Variable Types|BYTE]]
===<span style="font-weight: normal;"><u><tt>ReceiveString</tt></u></span>===
Attempts to receive a string of bytes from the UART interface.
'''Parameters'''
:[[Variable Types|BYTE]] ''Timeout''
::Time to wait in milliseconds for valid data before returning, 0=Dont wait, 255=Wait forever.
:[[Variable Types|UINT]] ''NumBytes''
::The number of bytes to try and receive, ideally your string variable should have at least 1 more byte to store the null termination byte
'''Return value'''
:[[Variable Types|STRING]]
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Sets up the RS232 peripheral, must be called at the start of your program or at least before you start calling any other RS232 macros.
'''Parameters'''
:''This macro has no parameters''
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>ReceiveChar</tt></u></span>===
Attempts to receive a single packet from the UART interface.
'''Parameters'''
:[[Variable Types|BYTE]] ''Timeout''
::Time to wait in milliseconds for valid data before returning, 0=Dont wait, 255=Wait forever.
'''Return value'''
:[[Variable Types|INT]]
==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_uart::CHANNEL''.
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
UART Channel selector
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels.
|-
 
|-
Hardware channels use the selected peripheral on-board the target microcontroller.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Channel
<span style="font-weight: normal;"><u>Baud Options</u></span>
|-
 
| colspan="2" | UART Channel selector Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels. Hardware channels use the selected peripheral on-board the target microcontroller.&nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::BAUD_LIST''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Baud rate option selector
| width="90%" | Baud Options
 
|-
<span style="font-weight: normal;"><u>Baud Rate</u></span>
| colspan="2" | Baud rate option selector&nbsp;
 
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_uart::BAUD''.
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
| width="90%" | Baud Rate
''<span style="color:red;">No additional information</span>''
|-
 
| colspan="2" | &nbsp;
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Data Bits</u></span>
| width="90%" | Data Bits
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::DBITS''.
| colspan="2" | Number of data bits&nbsp;
 
|-
Number of data bits
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Return
<span style="font-weight: normal;"><u>Return</u></span>
|-
 
| colspan="2" | Return data width from Receive macro. 8-bit data mode always returns a byte ranging from 0-255, 255 could mean a timeout or could be a valid data. 16-bit data mode rereturns 0-255 for valid data, 256 for a timeout, return data must be stored into an INT or UINT variable.&nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::RETURN''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Return data width from Receive macro.
| width="90%" | Echo
 
|-
8-bit data mode always returns a byte ranging from 0-255, 255 could mean a timeout or could be a valid data.
| colspan="2" | Automatically echoes back any received data when enabled by re-transmitting the received byte.&nbsp;
 
|-
16-bit data mode rereturns 0-255 for valid data, 256 for a timeout, return data must be stored into an INT or UINT variable.
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
<span style="font-weight: normal;"><u>Echo</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::ECHO''.
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Use TX
Automatically echoes back any received data when enabled by re-transmitting the received byte.
|-
 
| colspan="2" | Selects if the Transmit pin is used by the component. Yes: The TX pin is active and used to transmit data for the UART. No: The TX pin is disabled and free to be used as general I/O.&nbsp;
<span style="font-weight: normal;"><u>Use TX</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_uart::UseTX''.
| width="90%" | TX
 
|-
Selects if the Transmit pin is used by the component.  
| colspan="2" | Pin to be used for Transmit data&nbsp;
 
|-
Yes: The TX pin is active and used to transmit data for the UART.
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | TX Alt Pin
No: The TX pin is disabled and free to be used as general I/O.
|-
 
| colspan="2" | Allows the TX pin to be allocated to an alternate I/O pin.&nbsp;
<span style="font-weight: normal;"><u>TX</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::TX''.
| width="90%" | Use RX
 
|-
Pin to be used for Transmit data
| colspan="2" | Selects if the Receive pin is used by the component. Yes: The RX pin is active and used to receive data for the UART. No: The RX pin is disabled and free to be used as general I/O.&nbsp;
 
|-
<span style="font-weight: normal;"><u>TX Alt Pin</u></span>
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | RX
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::TXAlt''.
|-
 
| colspan="2" | Pin to be used for Receive data&nbsp;
Allows the TX pin to be allocated to an alternate I/O pin.
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
<span style="font-weight: normal;"><u>Use RX</u></span>
| width="90%" | RX Alt Pin
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::UseRX''.
| colspan="2" | Allows the RX pin to be allocated to an alternate I/O pin.&nbsp;
 
|-
Selects if the Receive pin is used by the component.  
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Use Flow Control
Yes: The RX pin is active and used to receive data for the UART.
|-
 
| colspan="2" | Flow Control (Handshake) enable or disable.    On: Two I/O pins are used to control the flow of data in and out of the device.    Off: Flow control is disabled.&nbsp;
No: The RX pin is disabled and free to be used as general I/O.
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
<span style="font-weight: normal;"><u>RX</u></span>
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::RX''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
Pin to be used for Receive data
| width="90%" | Label
 
|-
<span style="font-weight: normal;"><u>RX Alt Pin</u></span>
| colspan="2" | Textual label shown on the component I/O flasher&nbsp;
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::RXAlt''.
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Scope Traces
Allows the RX pin to be allocated to an alternate I/O pin.
|-
 
| colspan="2" | Selects if the scope traces are automatically added to the data recorder window or not.    Simulation - draws an approximation of the UART data onto the scope trace.    ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.&nbsp;
<span style="font-weight: normal;"><u>Use Flow Control</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_uart::FLOWEN''.
| width="90%" | Console Data
 
|-
Flow Control (Handshake) enable or disable.
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
 
|-
     On: Two I/O pins are used to control the flow of data in and out of the device.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Console Format
     Off: Flow control is disabled.
|-
 
| colspan="2" | Controls if the data is shown as a log with time and date stamps or just as raw data&nbsp;
<span style="font-weight: normal;"><u>Label</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
| width="90%" | Console Columns
 
|-
Textual label shown on the component I/O flasher
| colspan="2" | Number of characters that can be displayed on a single line of the console.&nbsp;
 
|-
<span style="font-weight: normal;"><u>Scope Traces</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Data Source
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ScopeTraces''.
|-
 
| colspan="2" | Simulation data source used to allow the component to connect to various remote devices    Nothing - Simulation data is ignored    COM port - Routes the communication data to and from a physical or virtual COM port     API - Routes the communication data via a data API component on the Panel.&nbsp;
Selects if the scope traces are automatically added to the data recorder window or not.
|}
 
     Simulation - draws an approximation of the UART data onto the scope trace.
 
     ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ConsoleData''.
 
Selects if the console data is automatically generated or not
 
<span style="font-weight: normal;"><u>Console Format</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::ConsoleFormat''.
 
Controls if the data is shown as a log with time and date stamps or just as raw data
 
<span style="font-weight: normal;"><u>Console Columns</u></span>
 
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''cal_uart::ConsoleColumns''.
 
Number of characters that can be displayed on a single line of the console.
 
<span style="font-weight: normal;"><u>Data Source</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::DataSource''.
 
Simulation data source used to allow the component to connect to various remote devices
 
     Nothing - Simulation data is ignored
 
     COM port - Routes the communication data to and from a physical or virtual COM port  
 
    Injector - Routes the communication data via a data injector component on the Panel.

Revision as of 20:35, 16 November 2021

Author Matrix Ltd
Version 3.0
Category Comms: Interface


UART (RS232) component

Low level routines for controlling or interacting with a standard asyncronous serial interface. On a microcontroller the interface will be the onboard UART which will need voltage level shifting using a max2323 to become RS232 compatible. See the EB015 RS232 E-block for details.

Detailed description

Overview

The RS232 component is in fact nothing more than a TTL level asynchronous serial communications bus which basically means that there is no clock signal. Instead the data is sent out at a precise data rate specified by the Baud which is represented in bits per second. Both devices need to be set to the same rate to allow communications to work correctly.


There are two signals which make up the asynchronous serial connection: RX and TX. The receive RX signal is used for incoming data and the transmit TX signal is used for outgoing data. When connecting two devices together it is important to connect the TX of one device to the RX of the other and visa versa. When inactive the bus defaults to having the TX signal held in the high state. Each data byte sent then starts with a low signal for 1 period of the baud rate to signify that data is to follow.


Each RS232 transaction consists of a start bit (low) for a single clock cycle followed by data made up of 7/8/9 clock cycles followed by a stop bit (high) for a single clock cycle.

TTL

By default the RS232 component will provide TTL asynchronous serial data which is best suited for a single device to single device data connection on the same circuit board. An example might be a GSM modem or GPS module. The TTL signals are normally at VCC when the bus is idle and toggles between VCC and Ground when sending data.


RS232

By adding a driver chip such as a MAX2323 the TTL signals can be upgraded to RS232 which is best suited for single device to single device mid range off board communications. The RS232 signals replace the voltages VCC with +12V and GND with -12V to allow for better noise rejection in noisy environments.


RS485

By adding a driver chip such as a MAX3078 the TTL signals can be upgraded to RS485 which is best suited for master to multiple slave type mid range off board communications.


Auto Baud

Some devices feature an auto baud functionality and is commonly triggered by sending a known data byte to the device before any other data is sent allowing the correct baud to be worked out.


Importing from v5

The RS232 component from Flowcode v6 has a new Initialise macro which will need to be added to your program before any other calls to the component are made.


Examples

Transmit

This example transmits a string "Hello World". RS232_Example1 The Console window shows the data as it is sent and received.


Receive

This example receives a character and outputs it to the LCD, an injector has been added to allow you to type data into the console. RS232_Example2 The Console window has tabs for the human interface data injector allowing you to type in data that will be received by the component.

Again the RS232 console tabs reflect the data as it is sent and received.

LCD showing received data.


Transmit and Receive

This example echoes back any data that is received allowing a nice sanity check when connecting an embedded device to a PC or other source of communications. RS232_Example3 Again the RS232 console tabs reflect the data as it is sent and received.


UART Bridge

This example allows a microcontroller with two UART peripherals to receive data one one UART and transmit on the other and visa versa in a reliable manner using interrupts. Note that this method will only work with hardware UART channels. A software UART could be done in a similar way using a falling edge type interrupt on the UART RX pin to trigger the receive function. RS232_Example4

COM Port

The COM port property allows you to attach the RS232 component to a COM port on your PC during simulation allowing real world hardware such as RS232, Bluetooth, GPS to work with the simulation.


Injector

The Injector property allows you to select an injector component on the panel for use in the simulation. The human interface injector can be used to inject typed in data via the console window and can be seen in examples 2 and 3 above.

There are other pre-made injectors to allow you to do various aspects from simulating a generic AT terminal to simulating a specific remote device.

Downloadable macro reference

SendString
Sends out a string of bytes from the UART interface. 
- STRING Data
 
- VOID Return


ReceiveINTArray
Receives an array of 16-bit INT/UINT values and returns the number of values received. 
- UINT Data
Array to store the incoming data 
- BYTE NumValues
Maximum number of values to try and receive 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- BYTE Return


ReceiveNumber
Attempts to receive a number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost. 
- BYTE Timeout
Max time in ms to wait in between bytes 
[[File:]] - IgnoreData
0=Dont ignore any data, 1=Ignore any initial none numeric data 
[[File:]] - Return


SendBinary16Bit
Sends out a 16-bit binary value split across two bytes. 
- UINT Value
 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendINTArray
Transmits an array of 16-bit INT/UINT values via the UART peripheral 
- UINT Data
Data to transmit 
- BYTE NumValues
Number of 16-bit values to send from the array 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendNumber
Sends out a number as an ASCII String from the UART interface. 
[[File:]] - Number
 
- VOID Return


ReceiveBinary32Bit
Receives a binary 32-bit value split across four bytes. 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- ULONG Return


ReceiveBinaryFloat
Receives a binary 32-bit floating point value split across four bytes. 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
[[File:]] - Return


SendChar
Sends out a single packet from the UART interface. 
[[File:]] - Char
 
- VOID Return


SendByteArray
Transmits an array of bytes via the UART peripheral 
- BYTE Data
Data to transmit 
- BYTE NumBytes
Number of bytes to send from the array 
- VOID Return


ReceiveBinary16Bit
Receives a binary 16-bit value split across two bytes. 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- UINT Return


ChangeHWBaud
Changes the hardware UART baud rate allowing for dynamic speed changes.  
- BYTE NewBaud
0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200, 8=250000 
- VOID Return


ReceiveFloat
Attempts to receive a floating point number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost. 
- BYTE Timeout
Max time in ms to wait in between bytes 
[[File:]] - IgnoreData
0=Dont ignore any data, 1=Ignore any initial none numeric data 
[[File:]] - Return


SendFloat
Sends out a floating point number as an ASCII String from the UART interface. 
[[File:]] - Number
 
- VOID Return


SendHexNumber
Sends out a number as an ASCII hexadecimal String from the UART interface. 
- ULONG Number
 
- BYTE NumChars
Number of characters in the string data, 0 for auto, 2 for 0x00, 4 for 0x0000 
[[File:]] - Prefix
Generate hexadecimal prefix 0x e.g. 1= 0xFF, 0= FF 
- VOID Return


ReceiveHexNumber
Attempts to receive a hex number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none hexadecimal char is received, the none numeric char will be lost. 
- BYTE Timeout
Max time in ms to wait in between bytes 
[[File:]] - IgnoreData
0=Dont ignore any data, 1=Ignore any initial none numeric data 
[[File:]] - Prefix
Look for prefix before receiving, 1=0xFF, 0=FF 
- ULONG Return


SendBinary32Bit
Sends out a 32-bit binary value split across four bytes. 
- ULONG Value
 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendBinaryFloat
Sends out a 32-bit binary floating point value split across four bytes. 
[[File:]] - Value
 
[[File:]] - MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


ReceiveByteArray
Receives an array of bytes and returns the number of bytes received. 
- BYTE Data
Array to store the incoming data 
- BYTE NumBytes
Maximum number of bytes to try and receive 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- BYTE Return


ReceiveString
Attempts to receive a string of bytes from the UART interface. 
- BYTE Timeout
Time to wait in milliseconds for valid data before returning, 0=Dont wait, 255=Wait forever. 
- UINT NumBytes
The number of bytes to try and receive, ideally your string variable should have at least 1 more byte to store the null termination byte 
- STRING Return


Initialise
Sets up the RS232 peripheral, must be called at the start of your program or at least before you start calling any other RS232 macros. 
- VOID Return


ReceiveChar
Attempts to receive a single packet from the UART interface. 
- BYTE Timeout
Time to wait in milliseconds for valid data before returning, 0=Dont wait, 255=Wait forever. 
[[File:]] - Return


ReceiveString
Puts the RF module in data mode and attempts to receive a string of bytes from the RF connection. 
- BYTE Length
Specifies the maximum number of bytes to try and receive 
- BYTE Timeout
Specifies how many milliseconds to wait for valid data before returning. 
- STRING Return


Initialise
Starts up and configures the RF module ready for use. The macro will return a value greater then 0 if the module has been started correctly, otherwise the macro will return a 0. 
- BYTE Return


Initialise
Sets up the 1-Wire output pin ready for communications. 
- VOID Return


Initialise
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. 
- VOID Return


Initialise
Initialises the MIDI component and sets up the UART. 
- VOID Return


CommsBaud
Sets the Baud rate of the alt communications channel 
- BYTE Baud
Range: 0-7 : 0=1200 / 7=115200 
- VOID Return


LCDOptions
Controls some of the LCD options 
- BYTE Foreground
Range: 0-1 
- BYTE Background
Range: 0-1 
- BYTE Transparent
Range: 0-1 
- VOID Return


LCDVerbose
Controls the Verbose mode. When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required. 
- BYTE Mode
Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode 
- VOID Return


ReadDigitalInput
Reads a single digital input. 
- BYTE Channel
 
- BYTE Return


PWMConfig
Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 : 0=1:1 1=1:8 2=1:64 3=1:256 
- BYTE Channel
Range 0-1 
- UINT Period
Range: 0-65535 
- BYTE Scaler
Range: 0-3 
- VOID Return


PWMEnable
Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD 
- BYTE EnableMask
Range 0-63 or 0b00000 to 0b111111 
- VOID Return


PWMDuty
Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535 
- BYTE Channel
Range 0-5 
- UINT Duty
 
- VOID Return


LCDCursor
Sets the cursor position for the MIAC display 
- BYTE X
Range: 0-21 
- BYTE Y
Range: 0-4 
- VOID Return


WriteTran
Allows a single transistor output to be switched on or off. 
- BYTE Channel
Range 1-4 
- BYTE Value
0 = Off, 1 = On 
- VOID Return


Initialise
 
- VOID Return


LCDClear
Clears the MIAC display 
- VOID Return



Property reference

Properties
Channel
UART Channel selector Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels. Hardware channels use the selected peripheral on-board the target microcontroller. 
Baud Options
Baud rate option selector 
Baud Rate
 
Data Bits
Number of data bits 
Return
Return data width from Receive macro. 8-bit data mode always returns a byte ranging from 0-255, 255 could mean a timeout or could be a valid data. 16-bit data mode rereturns 0-255 for valid data, 256 for a timeout, return data must be stored into an INT or UINT variable. 
Echo
Automatically echoes back any received data when enabled by re-transmitting the received byte. 
Connections
Use TX
Selects if the Transmit pin is used by the component. Yes: The TX pin is active and used to transmit data for the UART. No: The TX pin is disabled and free to be used as general I/O. 
TX
Pin to be used for Transmit data 
TX Alt Pin
Allows the TX pin to be allocated to an alternate I/O pin. 
Use RX
Selects if the Receive pin is used by the component. Yes: The RX pin is active and used to receive data for the UART. No: The RX pin is disabled and free to be used as general I/O. 
RX
Pin to be used for Receive data 
RX Alt Pin
Allows the RX pin to be allocated to an alternate I/O pin. 
Use Flow Control
Flow Control (Handshake) enable or disable. On: Two I/O pins are used to control the flow of data in and out of the device. Off: Flow control is disabled. 
Simulations
Label
Textual label shown on the component I/O flasher 
Scope Traces
Selects if the scope traces are automatically added to the data recorder window or not. Simulation - draws an approximation of the UART data onto the scope trace. ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD. 
Console Data
Selects if the console data is automatically generated or not 
Console Format
Controls if the data is shown as a log with time and date stamps or just as raw data 
Console Columns
Number of characters that can be displayed on a single line of the console. 
Data Source
Simulation data source used to allow the component to connect to various remote devices Nothing - Simulation data is ignored COM port - Routes the communication data to and from a physical or virtual COM port API - Routes the communication data via a data API component on the Panel.