Low-level APIs for controlling embedded devices

From Flowcode Help
(Redirected from Connected Devices)
Jump to navigationJump to search

Local and remote

When thinking about remote I/O devices, and customers’ needs, we think of different classes of device:

  • Local: Local devices connect to a PC using USB or Bluetooth.
  • Remote: Remote devices connect to a PC using Wi-fi, LAN or the internet.


Defined function and Flexible function

Local and remote devices can be off-the-shelf devices or can be custom made. Some connected devices will have defined functions – for example a remote thermostat, or an Ethercat connected sensor– and others will have flexible functions - for example a Labjack input output controller. Flexible function devices have an Application Programming Interface – API – that allows developers to design electronic systems.


Open source and closed source API

Some flexible function devices have a closed source APIs – for example the LabJack. This can not be edited. Other devices have open source code and you can edit the code and make the device behave as you wish. A good example of this is the Arduino, MIAC, ESP32 and other Matrix products: the APIs are written in Flowcode embedded and you are free to edit them.


Defined function (AllCode) API devices

There are many of these. Immediately available from Matrix are the following:

Hardware Platform MIAC PIC MIAC AllCode Formula AllCode Robot Arm v2
MCU Type PIC dsPIC dsPIC dsPIC
Slave Type AllCode AllCode AllCode AllCode
Communications
USB Y Y Y Y
Bluetooth Y Y Y
WIFI Y Y
Programming
Programming Method mLoader mLoader mLoader PC Loader
USB Y Y Y Y
Bluetooth Y
Firmware Firmware Firmware Firmware Firmware
Component Source Component Source
Examples Examples Examples Examples Examples
USB Driver USB Driver USB Driver USB Driver
Basic I/O
Digital Input Pins 8 8
Motor Output Pins 4 4
Relay Output Pins 4 4 1
Analogue Input Pins 8 8
Protection Y Y
Features
UART/RS232/RS485/Modbus 1
CAN 1 1
PWM 2 4
Display Y Y Y
Sensors 1 1
Motors 2 4

These products have defined functions which simplifies their use: the I/O is defined by function not by pin output. This allows the creator to have an API command like ‘MOTOR 100’ rather than to define the PWM rate and then define which outputs are on.

Flexible function (SCADA Slave) API devices

Immediately available from Matrix are the following:

Hardware Platform Arduino Uno Arduino Mega ECIO28P ECIO40P E-blocks2 BL0032 Raspberry Pi ESP32 Interface Board
MCU Type AVR AVR PIC PIC dsPIC Linux ESP32 PIC
Slave Type SCADA Slave SCADA Slave SCADA Slave SCADA Slave SCADA Slave SCADA Slave SCADA Slave SCADA Slave
Communications
USB Y Y Y Y Y Y Y
Bluetooth Y
WIFI Y Y Y
Programming
Programming Method AVRdude AVRdude mLoader mLoader mLoader SD Card / SSH ESP IDF PICkit
USB Y Y Y Y Y Y Y
WIFI / Ethernet Y Y
Firmware Firmware Firmware Firmware Firmware
Component Source Component Source
Examples Examples Examples Examples Examples
USB Driver USB Driver
Basic I/O
Digital I/O Pins 14 54 19 30 47 26 32 17
Analogue Output Pins 2 1 1
Analogue Input Pins 6 16 10 14 13 14 3
Features
SPI 1 1 1 1 4 1 1 1
I2C 1 1 1 1 1 2 1
UART/RS232/RS485/Modbus 3 1 1 6 1 3 1
CAN 2
Bluetooth 1 1 1 1
WIFI 1 1 1 1
Ethernet/TCPIP/Modbus TCP 1
PWM 6 16 2 2 27 2 2 2

The source code for all of these is available – so you can manufacture your own local and remote flexible function device for use with Flowcode App Developer.

Using an API device in App Developer

Fixed Function devices

1. Connect the device to the PC via USB. Start a new App Developer programme. You may be able to load a template for the device which will preserve the settings in Flowcode and save you some time.

2. You will need to ensure that you have the appropriate driver installed

3. Open a 2D Dashboard panel. Select COMPONENT LIBRARIES…..API

4. Click and drag a ,for example, MIAC Allcode API onto the panel.

5. In Project Explorer click on Components and you will see the API icons that you can use to construct your program.

6. Construct the program

7. Select DEBUG…Go and your program should run on the slave device.


Flexible function devices

For example with Arduino Uno

1. Take an Arduino, Connect it to the PC using USB. You will need to ensure that you have the appropriate driver installed

2. Load the Flowcode API programme for the Arduino Uno into Flowcode Embedded and compile it to the Arduino. Your Uno with flexible function API is now ready for use.

3. Start a new App Developer programme. You may be able to load a template for the device which will preserve the settings in Flowcode and save you some time.

4. Open a 2D Dashboard panel. Select COMPONENT LIBRARIES…..API

5. Click and drag a SCADA(Arduino uno) API onto the panel.

6. In Project Explorer click on Components and you will see the API icons that you can use to construct your program.

7. Construct the program

8. Select DEBUG…Go and your program should run on the slave device.


Additional API device examples

Matrix App Developer supports by default a selection of hardware devices with a built in API. Some devices have a basic or built in API and will not need firmware loading on to them, such as the PS2000 oscilloscope or K8055D Velleman I/O board. Other devices will need a API firmware loading on to them to allow the PC SCADA application to communicate with the firmware API. Most of the API's come as open source projects.


Device Manufacturer Comms Description Embedded Firmware Component Source Project Runtime Example Project USB Driver
FTD2XX FTDI USB General purpose USB driver chip N/A Available on request Examples FTDI Website
K8055D Velleman USB General purpose USB I/O board N/A Available on request Examples Velleman Website
PS2000 Pico Technology USB Oscilloscope N/A Available on request Examples Picotech Website
PL155-P TTI USB Power supply N/A Available on request Examples TTI Website
TG5011 TTI USB Signal generator N/A Available on request Examples TTI Website