Difference between revisions of "Component: API (RPI) (API Slave Devices)"
(Created page with "{| style="width:50%" |- | width="20%" style="color:gray;" | Author | Matrix TSL |- | width="20%" style="color:gray;" | Version | 2.0 |- | width="20%" style="color:gray...") |
|||
Line 16: | Line 16: | ||
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
Line 42: | Line 44: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
Line 1,017: | Line 1,021: | ||
|- | |- | ||
| colspan="2" | Initialise the comms to the Arduino board ready for commands to be sent. | | colspan="2" | Initialise the comms to the Arduino board ready for commands to be sent. | ||
+ | |- | ||
+ | |- | ||
+ | | 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;" | '''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 | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | EnableMask | ||
+ | |- | ||
+ | | colspan="2" | Range 0-63 or 0b00000 to 0b111111 | ||
+ | |- | ||
+ | | 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;" | '''Initialise''' | ||
+ | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
|- | |- |
Revision as of 10:38, 17 November 2021
Author | Matrix TSL |
Version | 2.0 |
Category | API Slave Devices |
Contents
API (RPI) component
Connects to a Raspberry Pi running the API Firmware allowing the board to become a slave to the Flowcode Embedded simulation or Flowcode App Developer. Supports: Digital IO / I2C / SPI / PWM / UART See Flowcode Help Wiki for firmware.
Detailed description
The App Developer (RaspberryPi) component allows an Raspberry Pi to be controlled from within the Flowcode simulation runtime.
To allow Flowcode to communicate and control the Raspberry Pi hardware the board must first be pre-programmed with dedicated firmware.
The firmware file and Flowcode source project can be downloaded from here.
More information about the workings of the firmware project can be found on the FiniteStateMachine page.
The IP Address to the Raspberry Pi hardware is selected via the SCADA_RPI component IP Address property.
When building the component into a App Developer project remember to expose the IP Address property to allow the end user to select the correct address for the hardware.
The console window can display data in two modes which is set via a component property.
- fixed statistics showing IO / ADC inputs / PWM
- scrolling log showing all commands and returns
Examples
Pin Mapping
Here is a table showing how the App Developer Slave digital pins are mapped on the device.
App Developer Slave Digital Pin | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
Device Port Pin | G2 | G3 | G4 | G5 | G6 | G7 | G8 | G9 | G10 | G11 | G12 | G13 | G14 | G15 | G16 | G17 | G18 | G19 | G20 | G21 | G22 | G23 | G24 | G25 | G26 | G27 |
Here is a table showing how the App Developer Slave peripheral pins are mapped on the device.
App Developer Slave Peripheral Pin | I2C SDA | I2C SCL | SPI MOSI | SPI MISO | SPI SCK | UART RX | UART TX | PWM 0 | PWM 1 |
Device Port Pin | G2 | G3 | G10 | G9 | G11 | G15 | G14 | G12 | G13 |
Downloadable macro reference
![]() |
I2CInitialise |
Initialsie the I2C module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Baud |
0=100KHz, 1=400KHz, 2=1MHz | |
![]() |
Return |
![]() |
IOGetInputPin |
Sets the selected digital pin to an input and reads the input state. | |
![]() |
Pin |
Range: 0-29 | |
[[File:]] - | Return |
![]() |
ADCSample8 |
Reads the voltage present on an Alanog pin as an 8-bit value range 0-255 | |
![]() |
ADCChannel |
Range: 0-12 | |
![]() |
Return |
![]() |
UARTInitialise |
Initialise the UART module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
![]() |
UARTCheckRX |
Check to see if the UART module has received any data | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
![]() |
I2CRestart |
Put the I2C Module into Restart mode | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
![]() |
PWMDisable |
Disable a PWM output | |
![]() |
Channel |
Range: 0-1 | |
![]() |
Return |
![]() |
I2CStart |
Put the I2C Module into Start mode | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
![]() |
SPITransfer |
Transfer a byte using the SPI bus | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
DataOut |
![]() |
Return |
![]() |
I2CReceive |
Receive a byte using the I2C bus | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
[[File:]] - | Last |
Last byte to receive: Range 0-1 | |
![]() |
Return |
![]() |
I2CStop |
Put the I2C Module into Stop mode | |
![]() |
Channel |
![]() |
Return |
![]() |
SPIPrescaler |
Modify the speed of the SPI bus | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Prescaler |
Range: 0-2 | |
![]() |
Return |
![]() |
PWMSetDuty |
Sets the duty for the PWM output | |
![]() |
Channel |
Range: 0-5 | |
![]() |
Duty |
![]() |
Return |
![]() |
ADCSample10 |
Reads the voltage present on an Alanog pin as an 10-bit value range 0-1023 | |
![]() |
ADCChannel |
Range: 0-12 | |
![]() |
Return |
![]() |
IOSetOutputPin |
Sets the selected digital pin to an output and assigns the output state. | |
![]() |
Pin |
Range: 0-29 | |
[[File:]] - | State |
Range: 0-1 | |
![]() |
Return |
![]() |
UARTReceive |
Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
![]() |
SPIInitialise |
Initialsie the SPI module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Return |
![]() |
I2CSend |
Transmit a byte using the I2C bus | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
DataOut |
[[File:]] - | Return |
![]() |
UARTSend |
Send a byte via the UART module | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Data |
Data Byte to send. Range: 0-255 | |
![]() |
Return |
![]() |
PWMSetPrescaler |
Sets the prescaler for the PWM output | |
![]() |
Channel |
![]() |
Prescaler |
![]() |
Period |
![]() |
Return |
![]() |
PWMEnable |
Enable a PWM output | |
![]() |
Channel |
Range: 0-1 | |
![]() |
Return |
![]() |
Initialise |
Initialise the comms to the Arduino board ready for commands to be sent. | |
![]() |
Return |
![]() |
IOSetOutputPin |
Sets the selected digital pin to an output and assigns the output state. | |
![]() |
Pin |
Range: 0-29 | |
[[File:]] - | State |
Range: 0-1 | |
![]() |
Return |
![]() |
UARTReceive |
Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
![]() |
OneWireScanBus |
Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
![]() |
SPIInitialise |
Initialsie the SPI module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Return |
![]() |
OneWireReceiveByte |
Receives a byte from the one wire bus a bit at a time | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
![]() |
I2CSend |
Transmit a byte using the I2C bus | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
DataOut |
[[File:]] - | Return |
![]() |
UARTSend |
Send a byte via the UART module | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Data |
Data Byte to send. Range: 0-255 | |
![]() |
Return |
![]() |
OneWireGetDeviceCount |
Returns the number of devices found by the last ScanBus operation. | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
![]() |
PWMSetPrescaler |
Sets the prescaler for the PWM output | |
![]() |
Channel |
Range: 0 - 11 | |
![]() |
Prescaler |
![]() |
Period |
![]() |
Return |
![]() |
PWMEnable |
Enable a PWM output | |
![]() |
Channel |
Range: 0-11 | |
![]() |
Return |
![]() |
Initialise |
Initialise the comms to the Arduino board ready for commands to be sent. | |
![]() |
Return |
![]() |
Initialise |
![]() |
Return |