Component: API (ECIO40P) (API Slave Devices)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 4.0
Category API Slave Devices


API (ECIO40P) component

Connects to an ECIO40P 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 / UART See Flowcode Help Wiki for firmware.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_ECIO40P_API_Comp.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_ECIO40P_API_Comp.fcfx

Detailed description

The App Developer (ECIO40P) component allows an ECIO40P board to be controlled from within the Flowcode simulation runtime.

To allow Flowcode to communicate and control the ECIO40P hardware the board must first be pre-programmed with dedicated firmware.

The firmware hex file and Flowcode source project can be downloaded from here.

ZIP Icon.png ECIO40P App Developer Firmware

More information about the workings of the firmware project can be found on the FiniteStateMachine page.


The COM port to the ECIO hardware is selected via the SCADA_ECIO40P 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
Device Port Pin A0 A1 A2 A3 A4 A5 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2


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
Device Port Pin A0 A1 A2 A3 A5 E0 E1 E2 B2 B3 B1 B4 B0


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 B0 B1 C7 B0 B1 C7 C6 C2 C1

Direct Slave Access

Here is a simple demo to switch on and off digital pin 29 (the LED pin).


FC6 Icon.png ECIO40P App Developer Example








Macro reference

ADCSample10

Fc9-comp-macro.png ADCSample10
Reads the voltage present on an Alanog pin as an 10-bit value range 0-1023 
Fc9-u8-icon.png - BYTE ADCChannel
Range: 0-12 
Fc9-u16-icon.png - UINT Return


ADCSample8

Fc9-comp-macro.png ADCSample8
Reads the voltage present on an Alanog pin as an 8-bit value range 0-255 
Fc9-u8-icon.png - BYTE ADCChannel
Range: 0-12 
Fc9-u8-icon.png - BYTE Return


ADCSampleArray10

Fc9-comp-macro.png ADCSampleArray10
Reads the voltage present on an Analog pin as an 10-bit value range 0-1023 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet 
Fc9-u8-icon.png - BYTE ADCChannel
Range: 0-5 
Fc9-u8-icon.png - BYTE SampleCount
Range: 1- 32 
Fc9-u16-icon.png - UINT SampleDelay
Delay in us between each sample 
Fc9-u16-icon.png - UINT Samples
10-bit samples returned from the function 
Fc9-void-icon.png - VOID Return


ADCSampleArray8

Fc9-comp-macro.png ADCSampleArray8
Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet 
Fc9-u8-icon.png - BYTE ADCChannel
Range: 0-5 
Fc9-u8-icon.png - BYTE SampleCount
Range: 1- 32 
Fc9-u16-icon.png - UINT SampleDelay
Delay in us between each sample 
Fc9-u8-icon.png - BYTE Samples
8-bit samples returned from the function 
Fc9-void-icon.png - VOID Return


ADCSampleAverage10

Fc9-comp-macro.png ADCSampleAverage10
Reads the voltage present on an Analog pin as an 10-bit value range 0-1023. Performs the selected number of samples with the selected time in microseconds in between samples 
Fc9-u8-icon.png - BYTE ADCChannel
Range: 0-5 
Fc9-u8-icon.png - BYTE SampleCount
Range: 1- 100 
Fc9-u8-icon.png - BYTE SampleDelay
Delay in us between each sample 
Fc9-u16-icon.png - UINT Return


ADCSampleAverage8

Fc9-comp-macro.png ADCSampleAverage8
Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples 
Fc9-u8-icon.png - BYTE ADCChannel
Range: 0-5 
Fc9-u8-icon.png - BYTE SampleCount
Range: 1- 100 
Fc9-u8-icon.png - BYTE SampleDelay
Delay in us between each sample 
Fc9-u8-icon.png - BYTE Return


ADCSetPrechargeTime

Fc9-comp-macro.png ADCSetPrechargeTime
Specifies the precharge time for the ADC input readings in microseconds. The longer the time the more immune to noise the reading will be. 
Fc9-u8-icon.png - BYTE ChargeTime
Default 10 
Fc9-void-icon.png - VOID Return


ADCSetReferenceVoltage

Fc9-comp-macro.png ADCSetReferenceVoltage
Specified the reference setting for ADC reads. 
Fc9-u8-icon.png - BYTE RefType
0=VDD 1= VREF+ (AN3) 
Fc9-void-icon.png - VOID Return


I2CInitialise

Fc9-comp-macro.png I2CInitialise
Initialsie the I2C module ready for communications 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-u8-icon.png - BYTE Baud
0=100KHz, 1=400KHz, 2=1MHz 
Fc9-void-icon.png - VOID Return


I2CReceive

Fc9-comp-macro.png I2CReceive
Receive a byte using the I2C bus 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-bool-icon.png - BOOL Last
Last byte to receive: Range 0-1 
Fc9-u8-icon.png - BYTE Return


I2CRestart

Fc9-comp-macro.png I2CRestart
Put the I2C Module into Restart mode 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-void-icon.png - VOID Return


I2CSend

Fc9-comp-macro.png I2CSend
Transmit a byte using the I2C bus 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-u8-icon.png - BYTE DataOut
 
Fc9-bool-icon.png - BOOL Return


I2CStart

Fc9-comp-macro.png I2CStart
Put the I2C Module into Start mode 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-void-icon.png - VOID Return


I2CStop

Fc9-comp-macro.png I2CStop
Put the I2C Module into Stop mode 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-void-icon.png - VOID Return


I2CTransInit

Fc9-comp-macro.png I2CTransInit
Initialises the I2C Transaction mode with the 7-bit device address 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-u8-icon.png - BYTE DeviceAddress
7-bit Device Address 
Fc9-u8-icon.png - BYTE Baud
0=100KHz, 1=400KHz, 2=1MHz 
Fc9-void-icon.png - VOID Return


I2CTransReceive

Fc9-comp-macro.png I2CTransReceive
Receives an I2C Transaction on the selected I2C channel. Returns the number of bytes received. 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-u8-icon.png - BYTE Data
Data variable to receive into 
Fc9-u16-icon.png - UINT Count
Number of bytes to receive 
Fc9-u16-icon.png - UINT Return


I2CTransSend

Fc9-comp-macro.png I2CTransSend
Sends an I2C Transaction on the selected I2C channel. Returns the number of bytes sent. 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
Fc9-u8-icon.png - BYTE Data
Data to send 
Fc9-u16-icon.png - UINT Count
Number of bytes to send out, MS bit 0x8000 signifies no Stop if set 
Fc9-u16-icon.png - UINT Return


IOGetInputPin

Fc9-comp-macro.png IOGetInputPin
Sets the selected digital pin to an input and reads the input state. 
Fc9-u8-icon.png - BYTE Pin
Range: 0-29 
Fc9-bool-icon.png - BOOL Return


IOSetOutputPin

Fc9-comp-macro.png IOSetOutputPin
Sets the selected digital pin to an output and assigns the output state. 
Fc9-u8-icon.png - BYTE Pin
Range: 0-29 
Fc9-bool-icon.png - BOOL State
Range: 0-1 
Fc9-void-icon.png - VOID Return


Initialise

Fc9-comp-macro.png Initialise
Initialise the comms to the ECIO40P device, ready for commands to be sent. 
Fc9-void-icon.png - VOID Return


PWMDisable

Fc9-comp-macro.png PWMDisable
Disable a PWM output 
Fc9-u8-icon.png - BYTE Channel
Range: 0-1 
Fc9-void-icon.png - VOID Return


PWMEnable

Fc9-comp-macro.png PWMEnable
Enable a PWM output 
Fc9-u8-icon.png - BYTE Channel
Range: 0-1 
Fc9-void-icon.png - VOID Return


PWMSetDuty

Fc9-comp-macro.png PWMSetDuty
Sets the duty for the PWM output 
Fc9-u8-icon.png - BYTE Channel
Range: 0-1 
Fc9-u8-icon.png - BYTE Duty
 
Fc9-void-icon.png - VOID Return


PWMSetPrescaler

Fc9-comp-macro.png PWMSetPrescaler
Sets the prescaler for the PWM output 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Prescaler
 
Fc9-u8-icon.png - BYTE Period
 
Fc9-void-icon.png - VOID Return


RegisterRead

Fc9-comp-macro.png RegisterRead
Read one of the registers on-board the device 
Fc9-u16-icon.png - UINT RegisterAddress
The address of the register 
Fc9-u8-icon.png - BYTE Return


RegisterWrite

Fc9-comp-macro.png RegisterWrite
Writes to one of the registers on-board the device 
Fc9-u16-icon.png - UINT RegisterAddress
The address of the register 
Fc9-u8-icon.png - BYTE Data
The data value to assign to the register 
Fc9-void-icon.png - VOID Return


SPIInitialise

Fc9-comp-macro.png SPIInitialise
Initialsie the SPI module ready for communications 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
Fc9-void-icon.png - VOID Return


SPIPrescaler

Fc9-comp-macro.png SPIPrescaler
Modify the speed of the SPI bus 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
Fc9-u8-icon.png - BYTE Prescaler
Range: 0-2 
Fc9-void-icon.png - VOID Return


SPITransfer

Fc9-comp-macro.png SPITransfer
Transfer a byte using the SPI bus 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
Fc9-u8-icon.png - BYTE DataOut
 
Fc9-u8-icon.png - BYTE Return


SPITransferTrans

Fc9-comp-macro.png SPITransferTrans
Transfer an array of bytes using the SPI bus 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
Fc9-u16-icon.png - UINT Count
Number of bytes to send and receive 
Fc9-u8-icon.png - BYTE DataOut
Outgoing data 
Fc9-u8-icon.png - BYTE DataIn
Incoming data 
Fc9-void-icon.png - VOID Return


UARTBaud

Fc9-comp-macro.png UARTBaud
Control the communications rate of the UART module 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
Fc9-u8-icon.png - BYTE Rate
0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200 
Fc9-void-icon.png - VOID Return


UARTCheckRX

Fc9-comp-macro.png UARTCheckRX
Check to see if the UART module has received any data 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
Fc9-u8-icon.png - BYTE Return


UARTInitialise

Fc9-comp-macro.png UARTInitialise
Initialise the UART module ready for communications 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
Fc9-void-icon.png - VOID Return


UARTReceive

Fc9-comp-macro.png UARTReceive
Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
Fc9-u8-icon.png - BYTE Return


UARTSend

Fc9-comp-macro.png UARTSend
Send a byte via the UART module 
Fc9-u8-icon.png - BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
Fc9-u8-icon.png - BYTE Data
Data Byte to send. Range: 0-255 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-conn-icon.png Connection
Fc9-type-7-icon.png Auto Detect
 
Fc9-type-16-icon.png COM Port
Lists all the current available COM port hardware on your PC. 
Fc9-type-7-icon.png Refresh Ports
 
Fc9-conn-icon.png API Peripherals
Fc9-type-21-icon.png Digital IO
 
Fc9-type-21-icon.png Analog Input
 
Fc9-type-21-icon.png Analog Output
 
Fc9-type-21-icon.png PWM Output
 
Fc9-type-21-icon.png I2C Bus
 
Fc9-type-21-icon.png SPI Bus
 
Fc9-type-21-icon.png UART
 
Fc9-type-21-icon.png SERVO
 
Fc9-conn-icon.png Console
Fc9-type-7-icon.png Console Log
Create an automatic console log of the commands sent to the Arduino 
Fc9-type-16-icon.png Log Mode
Controls how the console data is formatted. Fixed statistics gives an easy to read overview of the IO, Analog and PWM functionality Command Log gives a more in depth analysis of the outgoing commands and incoming returns ASCII mode allows serial data to be shown in raw text form, other commands are shown as in the Command Log mode