Component: API (Arduino Mega) (API Slave Devices)
Author | Matrix TSL |
Version | 2.0 |
Category | API Slave Devices |
Contents
API (Arduino Mega) component
Connects to an Arduino Mega running the API Firmware allowing the board to become a slave to the Flowcode Embedded simulation or Flowcode App Developer. Supports: Digital IO / ADC / I2C / SPI / UART / PWM See Flowcode Help Wiki for firmware.
Component Pack
FREE
Detailed description
The App Developer (Arduino Mega) component allows an Arduino Mega board to be controlled from within the Flowcode simulation runtime.
To allow Flowcode to communicate and control the Arduino Mega hardware the board must first be pre-programmed with dedicated firmware.
The firmware hex file and Flowcode source project can be downloaded from here.
Arduino Mega App Developer Firmware
More information about the workings of the firmware project can be found on the FiniteStateMachine page.
The COM port to the Arduino hardware is selected via the SCADA_Ard_Mega component COM port property.
When building the component into a App Developer project remember to expose the COM port property to allow the end user to select the correct port 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 | 0 | 1 | 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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
Device Port Pin | E0 | E1 | E2 | E5 | G5 | E3 | H3 | H4 | H6 | H6 | B4 | B5 | B6 | B7 | J1 | J0 | H1 | H0 | D3 | D2 | D1 | D0 | A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | D7 | G2 | G1 | G0 | L7 | L6 | L5 | L4 | L3 | L2 | L1 | L0 |
Arduino Style Pin | 0 | 1 | 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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
Here is a table showing how the App Developer Slave analogue pins are mapped on the device.
App Developer Slave Analogue Pin | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Device Port Pin | F0 | F1 | F2 | F3 | F4 | F5 | F6 | F7 | K0 | K1 | K2 | K3 | K4 | K5 | K6 | K7 |
Arduino Style Pin | A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 |
Here is a table showing how the App Developer Slave peripheral pins are mapped on the device.
App Developer Slave Peripheral Pin | I2C 0 SDA | I2C 0 SCL | SPI 0 MOSI | SPI 0 MISO | SPI 0 SCK | UART 0 RX | UART 0 TX | UART 1 RX | UART 1 TX | UART 2 RX | UART 2 TX | PWM 0 | PWM 1 | PWM 2 | PWM 3 | PWM 4 | PWM 5 | PWM 6 | PWM 7 | PWM 8 | PWM 9 | PWM 10 | PWM 11 | PWM 12 | PWM 13 | PWM 14 | PWM 15 |
Device Port Pin | D1 | D0 | B3 | B4 | B5 | D2 | D3 | H0 | H1 | J0 | J1 | B7 | G5 | B5 | B6 | B7 | B4 | H6 | E3 | E4 | E5 | H3 | H4 | H5 | L3 | L4 | L5 |
Arduino Style Pin | D20 | D21 | D50 | D10 | D11 | D19 | D18 | D17 | D16 | D15 | D14 | D13 | D4 | D11 | D12 | D13 | D10 | D9 | D5 | D2 | D3 | D6 | D7 | D8 | D46 | D45 | D44 |
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-53 | |
![]() |
Return |
![]() |
ADCSample8 |
Reads the voltage present on an Analog pin as an 8-bit value range 0-255 | |
![]() |
ADCChannel |
Range: 0-15 | |
![]() |
Return |
![]() |
UARTCheckRX |
Check to see if the UART module has received any data | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
![]() |
UARTInitialise |
Initialise the UART module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
![]() |
RegisterWrite |
Writes to one of the registers on-board the device | |
![]() |
RegisterAddress |
The address of the register | |
![]() |
Data |
The data value to assign to the register | |
![]() |
Return |
![]() |
RegisterRead |
Read one of the registers on-board the device | |
![]() |
RegisterAddress |
The address of the register | |
![]() |
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-15 | |
![]() |
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 | |
![]() |
Last |
Last byte to receive: Range 0-1 | |
![]() |
Return |
![]() |
I2CStop |
Put the I2C Module into Stop mode | |
![]() |
Channel |
![]() |
Return |
![]() |
ADCSetReferenceVoltage |
Specified the reference setting for ADC reads. | |
![]() |
RefType |
0=AREF, 1=VCC, 3=Internal 1.1V | |
![]() |
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-15 | |
![]() |
Duty |
![]() |
Return |
![]() |
ADCSample10 |
Reads the voltage present on an Analog pin as an 10-bit value range 0-1023 | |
![]() |
ADCChannel |
Range: 0-15 | |
![]() |
Return |
![]() |
IOSetOutputPin |
Sets the selected digital pin to an output and assigns the output state. | |
![]() |
Pin |
Range: 0-53 | |
![]() |
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 |
![]() |
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 |
Range: 0-15 | |
![]() |
Prescaler |
![]() |
Period |
Default 255 | |
![]() |
Return |
![]() |
PWMEnable |
Enable a PWM output | |
![]() |
Channel |
Range: 0-15 | |
![]() |
Return |
![]() |
Initialise |
Initialise the comms to the Arduino board ready for commands to be sent. | |
![]() |
Return |