Difference between revisions of "Component: API (Arduino Uno) (API Slave Devices)"
Line 22: | Line 22: | ||
==Detailed description== | ==Detailed description== | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
The App Developer (Arduino Uno) component allows an Arduino Uno board to be controlled from within the Flowcode simulation runtime. | The App Developer (Arduino Uno) component allows an Arduino Uno board to be controlled from within the Flowcode simulation runtime. |
Revision as of 16:08, 20 April 2023
Author | Matrix TSL |
Version | 2.0 |
Category | API Slave Devices |
Contents
- 1 API (Arduino Uno) component
- 2 Component Source Code
- 3 Detailed description
- 4 Examples
- 5 Macro reference
- 5.1 ADCSample10
- 5.2 ADCSample8
- 5.3 ADCSampleArray10
- 5.4 ADCSampleArray8
- 5.5 ADCSampleAverage10
- 5.6 ADCSampleAverage8
- 5.7 ADCSetPrechargeTime
- 5.8 ADCSetReferenceVoltage
- 5.9 I2CInitialise
- 5.10 I2CReceive
- 5.11 I2CRestart
- 5.12 I2CSend
- 5.13 I2CStart
- 5.14 I2CStop
- 5.15 I2CTransInit
- 5.16 I2CTransReceive
- 5.17 I2CTransSend
- 5.18 IOGetInputPin
- 5.19 IOSetOutputPin
- 5.20 Initialise
- 5.21 OneWireBusReset
- 5.22 OneWireGetDeviceCount
- 5.23 OneWireGetIDByte
- 5.24 OneWireInitialise
- 5.25 OneWireMatchROM
- 5.26 OneWireReceiveByte
- 5.27 OneWireScanBus
- 5.28 OneWireSkipROM
- 5.29 OneWireTransmitByte
- 5.30 PWMDisable
- 5.31 PWMEnable
- 5.32 PWMSetDuty
- 5.33 PWMSetPrescaler
- 5.34 RegisterRead
- 5.35 RegisterWrite
- 5.36 SPIInitialise
- 5.37 SPIPrescaler
- 5.38 SPITransfer
- 5.39 SPITransferTrans
- 5.40 ServoDisable
- 5.41 ServoEnable
- 5.42 ServoSetPosition8
- 6 Property reference
API (Arduino Uno) component
Connects to an Arduino Uno 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 / PWM See Flowcode Help Wiki for firmware.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_Arduino_Uno_API_Comp.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_Arduino_Uno_API_Comp.fcfx
Detailed description
The App Developer (Arduino Uno) component allows an Arduino Uno board to be controlled from within the Flowcode simulation runtime.
To allow Flowcode to communicate and control the Arduino Uno 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 Uno 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 App Developer_Ard_Uno componennt 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 |
Device Port Pin | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | B0 | B1 | B2 | B3 | B4 | B5 | C0 | C1 | C2 | C3 | C4 | C5 |
Arduino Style Pin | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | A0 | A1 | A2 | A3 | A4 | A5 |
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 |
Device Port Pin | C0 | C1 | C2 | C3 | C4 | C5 |
Arduino Style Pin | A0 | A1 | A2 | A3 | A4 | A5 |
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 | PWM 0 | PWM 1 | PWM 2 | PWM 3 | PWM 4 | PWM 5 | OneWire | Servo 0 | Servo 1 | Servo 2 | Servo 3 | Servo 4 | Servo 5 | Servo 6 | Servo 7 |
Device Port Pin | C4 | C5 | B3 | B4 | B5 | D6 | D5 | B1 | B2 | B3 | D3 | D2 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 |
Arduino Style Pin | A4 | A5 | 11 | 12 | 13 | 6 | 5 | 9 | 10 | 11 | 3 | 2 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Direct Slave Access
Here is a simple demo to switch on and off digital pin 5.
Rapid Development - Virtualised SPI
A feature of the App Developer Slave interface is to use the component for rapid development.
The App Developer Slave hardware can be used to take communications from the Flowcode simulation and transfer them to a real world device allowing for easy code generation and test without having to download to a target microcontroller device.
The CS pin and SPI Prescaler are set via the properties of the Injector component.
The SPI Master component is linked to the Injector component via the Injector property.
The Injector component is linked to the App Developer Slave component via the App Developer Slave property.
Arduino Uno App Developer Slave SPI Demo
Rapid Development - Virtualised I2C
A feature of the App Developer Slave interface is to use the component for rapid development.
The App Developer Slave hardware can be used to take communications from the Flowcode simulation and transfer them to a real world device allowing for easy code generation and test without having to download to a target microcontroller device.
The I2C Master component is linked to the Injector component via the Injector property.
The Injector component is linked to the App Developer Slave component via the App Developer Slave property.
Arduino Uno App Developer Slave I2C Demo
Rapid Development - Virtualised UART
A feature of the App Developer Slave interface is to use the component for rapid development.
The App Developer Slave hardware can be used to take communications from the Flowcode simulation and transfer them to a real world device allowing for easy code generation and test without having to download to a target microcontroller device.
The Baud rate and optional RS485 Properties are set via the properties of the Injector component.
The UART component is linked to the Injector component via the Injector property.
The Injector component is linked to the App Developer Slave component via the App Developer Slave property.
Arduino Uno App Developer Slave UART Demo
Macro reference
ADCSample10
![]() |
ADCSample10 |
Reads the voltage present on an Analog pin as an 10-bit value range 0-1023 | |
![]() |
ADCChannel |
Range: 0-5 | |
![]() |
Return |
ADCSample8
![]() |
ADCSample8 |
Reads the voltage present on an Analog pin as an 8-bit value range 0-255 | |
![]() |
ADCChannel |
Range: 0-5 | |
![]() |
Return |
ADCSampleArray10
ADCSampleArray8
ADCSampleAverage10
ADCSampleAverage8
ADCSetPrechargeTime
ADCSetReferenceVoltage
![]() |
ADCSetReferenceVoltage |
Specified the reference setting for ADC reads. | |
![]() |
RefType |
0=AREF, 1=VCC, 3=Internal 1.1V | |
![]() |
Return |
I2CInitialise
![]() |
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 |
I2CReceive
![]() |
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 |
I2CRestart
![]() |
I2CRestart |
Put the I2C Module into Restart mode | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
I2CSend
![]() |
I2CSend |
Transmit a byte using the I2C bus | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
DataOut |
![]() |
Return |
I2CStart
![]() |
I2CStart |
Put the I2C Module into Start mode | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
I2CStop
![]() |
I2CStop |
Put the I2C Module into Stop mode | |
![]() |
Channel |
![]() |
Return |
I2CTransInit
I2CTransReceive
I2CTransSend
IOGetInputPin
![]() |
IOGetInputPin |
Sets the selected digital pin to an input and reads the input state. | |
![]() |
Pin |
Range: 0-19 | |
![]() |
Return |
IOSetOutputPin
![]() |
IOSetOutputPin |
Sets the selected digital pin to an output and assigns the output state. | |
![]() |
Pin |
Range: 0-19 | |
![]() |
State |
Range: 0-1 | |
![]() |
Return |
Initialise
![]() |
Initialise |
Initialise the comms to the Arduino board ready for commands to be sent. | |
![]() |
Return |
OneWireBusReset
OneWireGetDeviceCount
![]() |
OneWireGetDeviceCount |
Returns the number of devices found by the last ScanBus operation. | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
OneWireGetIDByte
OneWireInitialise
![]() |
OneWireInitialise |
Initialise the OneWire module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
OneWireMatchROM
OneWireReceiveByte
![]() |
OneWireReceiveByte |
Receives a byte from the one wire bus a bit at a time | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
OneWireScanBus
![]() |
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 |
OneWireSkipROM
![]() |
OneWireSkipROM |
Performs a bus reset and the sends the SkipROM command byte | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
OneWireTransmitByte
![]() |
OneWireTransmitByte |
Transmit a byte to the one wire bus a bit at a time | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Data |
![]() |
Return |
PWMDisable
![]() |
PWMDisable |
Disable a PWM output | |
![]() |
Channel |
Range: 0-5 | |
![]() |
Return |
PWMEnable
![]() |
PWMEnable |
Enable a PWM output | |
![]() |
Channel |
Range: 0-5 | |
![]() |
Return |
PWMSetDuty
![]() |
PWMSetDuty |
Sets the duty for the PWM output | |
![]() |
Channel |
Range: 0-5 | |
![]() |
Duty |
![]() |
Return |
PWMSetPrescaler
![]() |
PWMSetPrescaler |
Sets the prescaler for the PWM output | |
![]() |
Channel |
Range: 0-5 | |
![]() |
Prescaler |
![]() |
Period |
Default 255 | |
![]() |
Return |
RegisterRead
![]() |
RegisterRead |
Read one of the registers on-board the device | |
![]() |
RegisterAddress |
The address of the register | |
![]() |
Return |
RegisterWrite
![]() |
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 |
SPIInitialise
![]() |
SPIInitialise |
Initialsie the SPI module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Return |
SPIPrescaler
![]() |
SPIPrescaler |
Modify the speed of the SPI bus | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Prescaler |
Range: 0-2 | |
![]() |
Return |
SPITransfer
![]() |
SPITransfer |
Transfer a byte using the SPI bus | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
DataOut |
![]() |
Return |
SPITransferTrans
ServoDisable
![]() |
ServoDisable |
Disable a Servo output Ch0 to 7 = Pins 2 to 9 | |
![]() |
Channel |
Range: 0-7 | |
![]() |
Return |
ServoEnable
![]() |
ServoEnable |
Enable a Servo output Ch0 to 7 = Pins 2 to 9 | |
![]() |
Channel |
Range: 0-7 | |
![]() |
Return |
ServoSetPosition8
![]() |
ServoSetPosition8 |
Sets the position as an 8-bit value Ch0 to 7 = Pins 2 to 9 | |
![]() |
Channel |
Range: 0-7 | |
![]() |
Position |
Range: 0-255 | |
![]() |
Return |