Difference between revisions of "Component: RF 2.4GHz (Wireless)"

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
(XML import BR)
 
(3 intermediate revisions by the same user not shown)
Line 19: Line 19:
  
 
==Examples==
 
==Examples==
''<span style="color:red;">No additional examples</span>''
+
Transmit - Reads a EB014 keypad, when a key is pressed and released the chosen key is transmitted as an ASCII value to the receiver.
 
+
{{Fcfile|NRF24L01_TX_Example1.fcfx|Transmit Example}}
 +
Receive - Sets up the receiver ready to receive messages, when a message is received the byte value is printed to the LCD.
 +
{{Fcfile|NRF24L01_RX_Example1.fcfx|Receive Example}}
  
 
==Downloadable macro reference==
 
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>StartListening</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>ReadRxByte</tt></u></span>===
Starts listening for incoming data
+
Reads a single byte back from the local Rx buffer.
  
 
'''Parameters'''
 
'''Parameters'''
  
:''This macro has no parameters''
+
:[[Variable Types|BYTE]] ''Index''
 +
::Byte to read, range 0 - 31
  
  
 
'''Return value'''
 
'''Return value'''
  
:''This call does not return a value''
+
:[[Variable Types|BYTE]]
  
  
===<span style="font-weight: normal;"><u><tt>OpenReadingPipe</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>WriteTxByte</tt></u></span>===
Opens a data pipe for receiving data at the pipe address specified
+
Reads a single byte to the local Tx buffer.
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''child''
+
:[[Variable Types|BYTE]] ''Index''
::Range 0-5
+
::Byte to read, range 0 - 31
 +
 
 +
:[[Variable Types|BYTE]] ''Value''
  
  
Line 51: Line 56:
  
  
===<span style="font-weight: normal;"><u><tt>Read</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>FlushRx</tt></u></span>===
Attempts to read received data from the RF module.
+
Tells the RF module to flush the contents of the receive buffer.
 
 
Returns 0 to indicate that there is still data to follow.
 
  
Returns 1 to indicate this is the last of the incoming data.
+
Returns the status from sending the command.
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''buffer''
+
:''This macro has no parameters''
 
 
:[[Variable Types|BYTE]] ''length''
 
  
  
Line 70: Line 71:
  
  
===<span style="font-weight: normal;"><u><tt>StopListening</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>ReadRxFifo</tt></u></span>===
Stops listening for incoming data
+
Reads the Rx FIFO buffer into a local buffer.
 +
 
 +
Use the ReadBuffer macro to collect the individual data bytes.
  
 
'''Parameters'''
 
'''Parameters'''
  
:''This macro has no parameters''
+
:[[Variable Types|BYTE]] ''NumBytes''
 +
::Number of bytes to try and read from the FIFO Range 1-32
  
  
Line 83: Line 87:
  
  
===<span style="font-weight: normal;"><u><tt>SetPipeAddress</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>WriteTxFifo</tt></u></span>===
Sets the pipe address based on a 5-byte array.
+
Writes the contents of the local Tx buffer to the Transmit FIFO.
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''Pipe''
+
:[[Variable Types|BYTE]] ''NumBytes''
::Selects the data pipe - range 0-5
+
::Number of bytes to write to the FIFO, Range 1 - 32
 
 
:[[Variable Types|BYTE]] ''PipeAddress''
 
  
  
Line 99: Line 101:
  
  
===<span style="font-weight: normal;"><u><tt>Write</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>FlushTx</tt></u></span>===
Writes data to be transmitted by the RF module.
+
Tells the RF module to flush the contents of the transmit buffer.
 
 
Returns 0 to indicate a timeout
 
  
Returns 1 to indicate a succesful transmission.
+
Returns the status from sending the command.
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''Data''
+
:''This macro has no parameters''
 
 
:[[Variable Types|BYTE]] ''Length''
 
  
  
Line 118: Line 116:
  
  
===<span style="font-weight: normal;"><u><tt>Available</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>CheckRX</tt></u></span>===
Checks for incoming data.
+
Check the Rx FIFO status register for any new data.
  
Returns 0 if no data available.
+
Returns 0 = No data  
  
Returns 1 for data available.
+
Returns 1 = New data available
  
 
'''Parameters'''
 
'''Parameters'''
Line 135: Line 133:
  
  
===<span style="font-weight: normal;"><u><tt>OpenWritingPipe</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>ReadRegister</tt></u></span>===
Opens a data pipe for transmitting data at the pipe address specified
+
Reads a single bytes from the selected register.
 +
 
 +
Directly returns the value read back from the register.
 +
 
 +
'''Parameters'''
 +
 
 +
:[[Variable Types|BYTE]] ''Reg''
 +
::Register address to access
 +
 
 +
 
 +
'''Return value'''
 +
 
 +
:[[Variable Types|BYTE]]
 +
 
 +
 
 +
===<span style="font-weight: normal;"><u><tt>SetTxMode</tt></u></span>===
 +
Sets the module up ready to transmit data.
  
 
'''Parameters'''
 
'''Parameters'''
  
:''This macro has no parameters''
+
:[[Variable Types|BYTE]] ''PA0''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA1''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA2''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA3''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA4''
 +
::Pipe Address Bytes
 +
 
 +
 
 +
'''Return value'''
 +
 
 +
:''This call does not return a value''
 +
 
 +
 
 +
===<span style="font-weight: normal;"><u><tt>SetRxMode</tt></u></span>===
 +
Sets the module up ready to receive data.
 +
 
 +
'''Parameters'''
 +
 
 +
:[[Variable Types|BYTE]] ''PA0''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA1''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA2''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA3''
 +
::Pipe Address Bytes
 +
 
 +
:[[Variable Types|BYTE]] ''PA4''
 +
::Pipe Address Bytes
  
  
Line 146: Line 199:
  
 
:''This call does not return a value''
 
:''This call does not return a value''
 +
 +
 +
===<span style="font-weight: normal;"><u><tt>WriteRegister</tt></u></span>===
 +
Writes a single byte to the selected register.
 +
 +
Returns the status of the write command.
 +
 +
'''Parameters'''
 +
 +
:[[Variable Types|BYTE]] ''Reg''
 +
::Register address to access
 +
 +
:[[Variable Types|BYTE]] ''Value''
 +
 +
 +
'''Return value'''
 +
 +
:[[Variable Types|BYTE]]
  
  
Line 170: Line 241:
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>Dynamic Payloads</u></span>
+
<span style="font-weight: normal;"><u>RF Channel</u></span>
  
This property is of type ''True or false'' and can be referenced with the variable name ''DynamicPayloads''.
+
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''RFChannel''.
  
Configures how the data packets are assembled and transmitted.
+
Sets the RF channel from 0 - 127 = 2.4000GHz - 2.525GHz
  
No = Always send out packets of 32 bytes, pad the number of bytes with the value 0.
+
Both the transmitter and receiver should be on the same channel to receive data.
 
 
Yes = Allow variable sized data packets, only transmit valid data.
 
  
 
<span style="font-weight: normal;"><u>SPI Channel</u></span>
 
<span style="font-weight: normal;"><u>SPI Channel</u></span>
Line 186: Line 255:
 
SPI peripheral used to talk to the RF module.
 
SPI peripheral used to talk to the RF module.
  
<span style="font-weight: normal;"><u>FSEL Pin</u></span>
+
<span style="font-weight: normal;"><u>Prescaler</u></span>
 +
 
 +
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.
 +
 
 +
''<span style="color:red;">No additional information</span>''
  
This property is of type ''Single digital pin'' and can be referenced with the variable name ''fsel_pin''.
 
  
RF Mode selection pin
 
  
 
<span style="font-weight: normal;"><u>MOSI Pin</u></span>
 
<span style="font-weight: normal;"><u>MOSI Pin</u></span>
Line 214: Line 285:
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''ce_pin''.
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''ce_pin''.
  
Chip select pin
+
Chip enable, configures RX or TX mode
  
 
<span style="font-weight: normal;"><u>CSN Pin</u></span>
 
<span style="font-weight: normal;"><u>CSN Pin</u></span>
Line 220: Line 291:
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''csn_pin''.
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''csn_pin''.
  
''<span style="color:red;">No additional information</span>''
+
SPI chip select pin - enables the SPI interface when pulled low
 
 
 
 
  
 
<span style="font-weight: normal;"><u>Label</u></span>
 
<span style="font-weight: normal;"><u>Label</u></span>

Latest revision as of 15:46, 16 February 2017


Author Matrix Ltd.
Version 1.1 (Release)
Category Wireless


Image RF 2.4GHz component

A simple RF communications module based on the 2.4GHz nRF24L01 modules.

Examples

Transmit - Reads a EB014 keypad, when a key is pressed and released the chosen key is transmitted as an ASCII value to the receiver. FC6 Icon.png Transmit Example Receive - Sets up the receiver ready to receive messages, when a message is received the byte value is printed to the LCD. FC6 Icon.png Receive Example

Downloadable macro reference

ReadRxByte

Reads a single byte back from the local Rx buffer.

Parameters

BYTE Index
Byte to read, range 0 - 31


Return value

BYTE


WriteTxByte

Reads a single byte to the local Tx buffer.

Parameters

BYTE Index
Byte to read, range 0 - 31
BYTE Value


Return value

This call does not return a value


FlushRx

Tells the RF module to flush the contents of the receive buffer.

Returns the status from sending the command.

Parameters

This macro has no parameters


Return value

BYTE


ReadRxFifo

Reads the Rx FIFO buffer into a local buffer.

Use the ReadBuffer macro to collect the individual data bytes.

Parameters

BYTE NumBytes
Number of bytes to try and read from the FIFO Range 1-32


Return value

This call does not return a value


WriteTxFifo

Writes the contents of the local Tx buffer to the Transmit FIFO.

Parameters

BYTE NumBytes
Number of bytes to write to the FIFO, Range 1 - 32


Return value

This call does not return a value


FlushTx

Tells the RF module to flush the contents of the transmit buffer.

Returns the status from sending the command.

Parameters

This macro has no parameters


Return value

BYTE


CheckRX

Check the Rx FIFO status register for any new data.

Returns 0 = No data

Returns 1 = New data available

Parameters

This macro has no parameters


Return value

BYTE


ReadRegister

Reads a single bytes from the selected register.

Directly returns the value read back from the register.

Parameters

BYTE Reg
Register address to access


Return value

BYTE


SetTxMode

Sets the module up ready to transmit data.

Parameters

BYTE PA0
Pipe Address Bytes
BYTE PA1
Pipe Address Bytes
BYTE PA2
Pipe Address Bytes
BYTE PA3
Pipe Address Bytes
BYTE PA4
Pipe Address Bytes


Return value

This call does not return a value


SetRxMode

Sets the module up ready to receive data.

Parameters

BYTE PA0
Pipe Address Bytes
BYTE PA1
Pipe Address Bytes
BYTE PA2
Pipe Address Bytes
BYTE PA3
Pipe Address Bytes
BYTE PA4
Pipe Address Bytes


Return value

This call does not return a value


WriteRegister

Writes a single byte to the selected register.

Returns the status of the write command.

Parameters

BYTE Reg
Register address to access
BYTE Value


Return value

BYTE


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.

Parameters

This macro has no parameters


Return value

UINT


Simulation macro reference

This component does not contain any simulation macros


Property reference

RF Channel

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

Sets the RF channel from 0 - 127 = 2.4000GHz - 2.525GHz

Both the transmitter and receiver should be on the same channel to receive data.

SPI Channel

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

SPI peripheral used to talk to the RF module.

Prescaler

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

No additional information


MOSI Pin

This property is of type Single digital pin and can be referenced with the variable name mosi_pin.

SPI Data Out pin - Master Out Slave In

MISO Pin

This property is of type Single digital pin and can be referenced with the variable name miso_pin.

SPI Data In pin - Master In Slave Out

SCK Pin

This property is of type Single digital pin and can be referenced with the variable name sck_pin.

Serial clock pin

CE Pin

This property is of type Single digital pin and can be referenced with the variable name ce_pin.

Chip enable, configures RX or TX mode

CSN Pin

This property is of type Single digital pin and can be referenced with the variable name csn_pin.

SPI chip select pin - enables the SPI interface when pulled low

Label

This property is of type Line of text and can be referenced with the variable name label.

Label used to help identify the component on the panel.