Component: MIAC USB Slave API (PIC) (AllCode)

From Flowcode Help
Jump to navigationJump to search
Author Matrix Ltd
Version 1.1
Category AllCode


MIAC USB Slave API (PIC) component

Allows Matrix's MIAC PLC to be used as a PC peripheral controlled by Flowcode via a USB connection. Requires that the MIAC (PIC) has the USB Slave firmware downloaded to it.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_MIAC_Slave.fcsx

Please click here to view the component source code (Beta): FC_Comp_Source_MIAC_Slave.fcsx

Detailed description

No detailed description exists yet for this component

Examples

Firmware & USB Driver

The MIAC needs programming with the USB Slave firmware to function correctly with the MIAC USB Slave component.

Use the MIACprog tool to download the firmware .hex file to the MIAC.

File:MIAC USB Slave Firmware.zip


The MIAC USB Slave USB driver will need to be installed before Windows will correctly recognise the device and allow Flowcode to communicate correctly.


Controlled Using Flowcode

Here is a simple Flowcode program to toggle one of the transistor outputs on the MIAC USB Slave device. Remember to connect a linking wire between the (M) screw terminal to the (V+) screw terminal to allow the Transistor LEDs to light. FC6 Icon.png MIAC USB Slave Here is an example of the high level MIAC USB Slave console.

MIACUSBSCH.jpg


Here is an example of the low level MIAC USB Slave console.

MIACUSBSCL.jpg


If the MIAC USB Slave component can see the MIAC USB Slave then you will able to select the instance via the Instance property.

MIACUsbCon.jpg


Multiple MIAC USB slaves can be connected to a single PC and controlled by adding multiple MIAC USB Slave components each referring to their own instance of the hardware.


Controlled Using VB6 / VB2008

Files taken from the Locktronics Industrial sensor, actuator and control applications solution

File:VB Examples.zip


Controlled Using Labview

Files taken from the Locktronics Industrial sensor, actuator and control applications solution

File:Labview Examples.zip


Command Table

Command Number Description Parameters Returns
1 Digital Input Channel (1-8) Input State (0-1)
2 Digital Multi Input N/A Input State 8-bit (0-255)
3 Analogue Input Channel (1-8) Input ADC Reading (0-255)
4 Read Keypad Buffer N/A Key Press (0-8 or 255)
5 Clear Keypad Buffer N/A N/A
6 Relay Control Channel (1-4)

Relay State (0-1)

N/A
7 Transistor Control Channel (1-4)

Transistor State (0-1)

N/A
8 Multi Output Control Output Value (0-255)

Output Mask (0-255)

N/A
9 Display Clear N/A N/A
10 Display Cursor Position X Coord (0-15)

Y Coord (0-3)

N/A
11 Display Number Number Low Byte (0-255)

Number High Byte (0-255)

N/A
12 Display String String Data N/A
13 PWM Enable Control PWM Channel (1-2)

Enabled (0-1)

N/A
14 PWM Duty Control PWM Channel (1-2)

Duty (0-255)

N/A
15 PWM Period Control Prescaler (0-2) N/A
16 PWM Overcurrent Check N/A Overcurrent State (0-1)
17 EEPROM Write Address (0-255)

Data (0-255)

N/A
18 EEPROM Read Address (0-255) Data (0-255)
19 CAN Set Data Num Bytes (0-8)

Data0 (0-255) Data1 (0-255) Data2 (0-255) Data3 (0-255)

Data4 (0-255) Data5 (0-255) Data6 (0-255) Data7 (0-255)

N/A
20 CAN Send Message ID Low Byte (0-255)

ID High Byte (0-7)

N/A
21 CAN Check Incoming N/A ID High

ID Low

22 CAN Get RX Data N/A Num Bytes (0-8)

Data0 (0-255) Data1 (0-255) Data2 (0-255) Data3 (0-255)

Data4 (0-255) Data5 (0-255) Data6 (0-255) Data7 (0-255)

23 Register Read Address Low Byte (0-255)

Address High Byte (0-255)

Register Data Byte (0-255)
24 Register Write Address Low Byte (0-255)

Address High Byte (0-255) Register Data Byte (0-255)

N/A

Component Source

The component source code is available here.

FC6 Icon.png MIAC PIC Slave Component








Macro reference

CANCheckRx

Fc9-comp-macro.png CANCheckRx
Checks to see if a CAN message has been received, if so the ID is returned 
Fc9-u16-icon.png - UINT Return


CANGetRxData

Fc9-comp-macro.png CANGetRxData
Collects the data from the last received CAN message 
Fc9-string-icon.png - STRING Return


CANSetTxData

Fc9-comp-macro.png CANSetTxData
Sets the LCD cursor position on the MIAC 
Fc9-u8-icon.png - BYTE DataCount
 
Fc9-u8-icon.png - BYTE d0
 
Fc9-u8-icon.png - BYTE d1
 
Fc9-u8-icon.png - BYTE d2
 
Fc9-u8-icon.png - BYTE d3
 
Fc9-u8-icon.png - BYTE d4
 
Fc9-u8-icon.png - BYTE d5
 
Fc9-u8-icon.png - BYTE d6
 
Fc9-u8-icon.png - BYTE d7
 
Fc9-void-icon.png - VOID Return


CANTx

Fc9-comp-macro.png CANTx
Sends the Tx data with the ID specified in the form of a CAN message 
Fc9-u16-icon.png - UINT CANID
 
Fc9-void-icon.png - VOID Return


ClearKeypadBuffer

Fc9-comp-macro.png ClearKeypadBuffer
Destroys the contents of the keypad buffer. 
Fc9-void-icon.png - VOID Return


GetAnalogueInput

Fc9-comp-macro.png GetAnalogueInput
Returns the value for a specific analogue input on the MIAC slave. 
Fc9-u8-icon.png - BYTE Input
 
Fc9-u8-icon.png - BYTE Return


GetDigitalInput

Fc9-comp-macro.png GetDigitalInput
Returns the value for a specific digital input on the MIAC slave. 
Fc9-u8-icon.png - BYTE Input
 
Fc9-u8-icon.png - BYTE Return


GetDigitalInputs

Fc9-comp-macro.png GetDigitalInputs
Returns the value for a all 8 digital inputs on the MIAC slave. 
Fc9-u8-icon.png - BYTE Return


GetEEPROMData

Fc9-comp-macro.png GetEEPROMData
Reads a byte from the EEPROM data memory 
Fc9-u8-icon.png - BYTE Address
 
Fc9-u8-icon.png - BYTE Return


GetKeypadBuffer

Fc9-comp-macro.png GetKeypadBuffer
Returns a keypress from the keypress buffer, returns 255 if no keypress is available. 
Fc9-u8-icon.png - BYTE Return


GetRegisterValue

Fc9-comp-macro.png GetRegisterValue
Gets the value of the register specified on the MIAC 
Fc9-u16-icon.png - UINT RegAddress
 
Fc9-u8-icon.png - BYTE Return


LCDClear

Fc9-comp-macro.png LCDClear
Clears the LCD display on the MIAC.  
Fc9-void-icon.png - VOID Return


LCDPrintNumber

Fc9-comp-macro.png LCDPrintNumber
Prints out a number to the display on the MIAC. 
Fc9-s16-icon.png - INT Number
 
Fc9-void-icon.png - VOID Return


LCDPrintString

Fc9-comp-macro.png LCDPrintString
Prints a string to the LCD on the MIAC. 
Fc9-string-icon.png - STRING Str
 
Fc9-void-icon.png - VOID Return


LCDSetCursor

Fc9-comp-macro.png LCDSetCursor
Sets the LCD cursor position on the MIAC 
Fc9-u8-icon.png - BYTE x
 
Fc9-u8-icon.png - BYTE y
 
Fc9-void-icon.png - VOID Return


PWMControl

Fc9-comp-macro.png PWMControl
Sets the PWM channel specified to be enabled or disabled 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Enable
 
Fc9-void-icon.png - VOID Return


PWMOvercurrentCheck

Fc9-comp-macro.png PWMOvercurrentCheck
Checks the PWM outputs to see if they are overcurrent 
Fc9-u8-icon.png - BYTE Return


PWMSetDuty

Fc9-comp-macro.png PWMSetDuty
Sets the duty cycle for the PWM channel specified 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Duty
 
Fc9-void-icon.png - VOID Return


PWMSetPeriod

Fc9-comp-macro.png PWMSetPeriod
Sets the PWM period for the channel specified 
Fc9-u8-icon.png - BYTE Prescaler
 
Fc9-u8-icon.png - BYTE Period
 
Fc9-void-icon.png - VOID Return


SetEEPROMData

Fc9-comp-macro.png SetEEPROMData
Writes a byte to the EEPROM data memory 
Fc9-u8-icon.png - BYTE Address
 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


SetOutputBank

Fc9-comp-macro.png SetOutputBank
Controls the state of one of the transistor outputs on the MIAC slave. 
Fc9-u8-icon.png - BYTE Mask
 
Fc9-u8-icon.png - BYTE Output_States
 
Fc9-void-icon.png - VOID Return


SetRegisterValue

Fc9-comp-macro.png SetRegisterValue
Sets the value of the register specified on the MIAC 
Fc9-u16-icon.png - UINT RegAddress
 
Fc9-u8-icon.png - BYTE Value
 
Fc9-void-icon.png - VOID Return


SetRelayOutput

Fc9-comp-macro.png SetRelayOutput
Controls the state of one of the Relay outputs on the MIAC slave. 
Fc9-u8-icon.png - BYTE Relay
 
Fc9-u8-icon.png - BYTE State
 
Fc9-void-icon.png - VOID Return


SetTransistorOutput

Fc9-comp-macro.png SetTransistorOutput
Controls the state of one of the transistor outputs on the MIAC slave. 
Fc9-u8-icon.png - BYTE Transistor
 
Fc9-u8-icon.png - BYTE State
 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Instance
USB Slave Instance, if empty then is the MIAC slave firmware loaded, Is the MIAC slave driver installed, Is the MIAC connected and powered.