Difference between revisions of "Component: MIAC USB Slave API (PIC) (AllCode)"
(13 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
==MIAC USB Slave API (PIC) component== | ==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. | 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: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_MIAC_Slave.fcsx FC_Comp_Source_MIAC_Slave.fcsx] | ||
+ | |||
+ | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_MIAC_Slave.fcsx FC_Comp_Source_MIAC_Slave.fcsx] | ||
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Line 24: | Line 48: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Line 246: | Line 288: | ||
− | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Macro reference== | ||
+ | |||
+ | ===CANCheckRx=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CANCheckRx''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Checks to see if a CAN message has been received, if so the ID is returned |
|- | |- | ||
|- | |- | ||
− | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | |
− | |||
− | |||
− | |||
− | |||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===CANGetRxData=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CANGetRxData''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Collects the data from the last received CAN message |
|- | |- | ||
|- | |- | ||
− | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | |
− | |||
− | |||
− | |||
− | |||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===CANSetTxData=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CANSetTxData''' |
+ | |- | ||
+ | | colspan="2" | Sets the LCD cursor position on the MIAC | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | DataCount | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | d0 | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | d1 | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | d2 | ||
+ | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | d3 | ||
|- | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | d4 |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90% | + | | width="90%" | d5 |
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
− | | | + | | colspan="2" | |
− | |||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | d6 | ||
|- | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:]] - | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | | + | | width="90%" | d7 |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 320: | Line 389: | ||
+ | ===CANTx=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 338: | Line 408: | ||
+ | ===ClearKeypadBuffer=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ClearKeypadBuffer''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Destroys the contents of the keypad buffer. |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===GetAnalogueInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetAnalogueInput''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Returns the value for a specific analogue input on the MIAC slave. |
|- | |- | ||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Input |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===GetDigitalInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDigitalInput''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Returns the value for a specific digital input on the MIAC slave. |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Input |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | |
− | |||
− | |||
− | |||
− | |||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===GetDigitalInputs=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDigitalInputs''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Returns the value for a all 8 digital inputs on the MIAC slave. |
|- | |- | ||
|- | |- | ||
Line 410: | Line 474: | ||
+ | ===GetEEPROMData=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 428: | Line 493: | ||
+ | ===GetKeypadBuffer=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetKeypadBuffer''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Returns a keypress from the keypress buffer, returns 255 if no keypress is available. |
|- | |- | ||
|- | |- | ||
− | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===GetRegisterValue=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRegisterValue''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Gets the value of the register specified on the MIAC |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | | + | | width="90%" | RegAddress |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | | + | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
+ | |} | ||
+ | |||
+ | |||
+ | ===LCDClear=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
− | | | + | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDClear''' | ||
|- | |- | ||
− | | | + | | colspan="2" | Clears the LCD display on the MIAC. |
− | |||
|- | |- | ||
− | |||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
− | | width="90%" | | + | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
+ | |} | ||
+ | |||
+ | |||
+ | ===LCDPrintNumber=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
− | | | + | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDPrintNumber''' | ||
|- | |- | ||
− | | | + | | colspan="2" | Prints out a number to the display on the MIAC. |
− | |||
|- | |- | ||
− | |||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT |
− | | width="90%" | | + | | width="90%" | Number |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
− | | width="90%" | | + | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
+ | |} | ||
+ | |||
+ | |||
+ | ===LCDPrintString=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
− | | | + | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDPrintString''' | ||
|- | |- | ||
− | | | + | | colspan="2" | Prints a string to the LCD on the MIAC. |
− | |||
|- | |- | ||
− | |||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING |
− | | width="90%" | | + | | width="90%" | Str |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 509: | Line 578: | ||
+ | ===LCDSetCursor=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDSetCursor''' |
+ | |- | ||
+ | | colspan="2" | Sets the LCD cursor position on the MIAC | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | x | ||
+ | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | y | ||
|- | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===PWMControl=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PWMControl''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Sets the PWM channel specified to be enabled or disabled |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Channel |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Enable |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 545: | Line 626: | ||
+ | ===PWMOvercurrentCheck=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PWMOvercurrentCheck''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Checks the PWM outputs to see if they are overcurrent |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
+ | ===PWMSetDuty=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 581: | Line 664: | ||
+ | ===PWMSetPeriod=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PWMSetPeriod''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Sets the PWM period for the channel specified |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Prescaler |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Period |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 604: | Line 688: | ||
+ | ===SetEEPROMData=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetEEPROMData''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Writes a byte to the EEPROM data memory |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Address |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Data |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 627: | Line 712: | ||
+ | ===SetOutputBank=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetOutputBank''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Controls the state of one of the transistor outputs on the MIAC slave. |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Mask |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | + | | width="90%" | Output_States |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 658: | Line 736: | ||
+ | ===SetRegisterValue=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRegisterValue''' |
|- | |- | ||
− | | colspan="2" | Sets the | + | | colspan="2" | Sets the value of the register specified on the MIAC |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | | + | | width="90%" | RegAddress |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Value |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 681: | Line 760: | ||
+ | ===SetRelayOutput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRelayOutput''' |
|- | |- | ||
− | | colspan="2" | | + | | colspan="2" | Controls the state of one of the Relay outputs on the MIAC slave. |
|- | |- | ||
|- | |- | ||
− | | width="10%" align="center | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90% | + | | width="90%" | Relay |
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
− | | | + | | colspan="2" | |
− | |||
|- | |- | ||
− | | | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
+ | | width="90%" | State | ||
|- | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
Line 707: | Line 784: | ||
+ | ===SetTransistorOutput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTransistorOutput''' |
|- | |- | ||
− | | colspan="2" | Controls the state of one of the | + | | colspan="2" | Controls the state of one of the transistor outputs on the MIAC slave. |
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | Transistor |
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 728: | Line 806: | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
− | |||
− | |||
Line 744: | Line 820: | ||
|- | |- | ||
| colspan="2" | USB Slave Instance, if empty then is the MIAC slave firmware loaded, Is the MIAC slave driver installed, Is the MIAC connected and powered. | | colspan="2" | USB Slave Instance, if empty then is the MIAC slave firmware loaded, Is the MIAC slave driver installed, Is the MIAC connected and powered. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} |
Latest revision as of 11:57, 3 November 2023
Author | Matrix Ltd |
Version | 1.1 |
Category | AllCode |
Contents
- 1 MIAC USB Slave API (PIC) component
- 2 Component Source Code
- 3 Detailed description
- 4 Examples
- 5 Component Source
- 6 Macro reference
- 6.1 CANCheckRx
- 6.2 CANGetRxData
- 6.3 CANSetTxData
- 6.4 CANTx
- 6.5 ClearKeypadBuffer
- 6.6 GetAnalogueInput
- 6.7 GetDigitalInput
- 6.8 GetDigitalInputs
- 6.9 GetEEPROMData
- 6.10 GetKeypadBuffer
- 6.11 GetRegisterValue
- 6.12 LCDClear
- 6.13 LCDPrintNumber
- 6.14 LCDPrintString
- 6.15 LCDSetCursor
- 6.16 PWMControl
- 6.17 PWMOvercurrentCheck
- 6.18 PWMSetDuty
- 6.19 PWMSetPeriod
- 6.20 SetEEPROMData
- 6.21 SetOutputBank
- 6.22 SetRegisterValue
- 6.23 SetRelayOutput
- 6.24 SetTransistorOutput
- 7 Property reference
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.
MIAC USB Slave
Here is an example of the high level MIAC USB Slave console.
Here is an example of the low level MIAC USB Slave console.
If the MIAC USB Slave component can see the MIAC USB Slave then you will able to select the instance via the Instance property.
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
Controlled Using Labview
Files taken from the Locktronics Industrial sensor, actuator and control applications solution
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.
Macro reference
CANCheckRx
![]() |
CANCheckRx |
Checks to see if a CAN message has been received, if so the ID is returned | |
![]() |
Return |
CANGetRxData
![]() |
CANGetRxData |
Collects the data from the last received CAN message | |
![]() |
Return |
CANSetTxData
![]() |
CANSetTxData |
Sets the LCD cursor position on the MIAC | |
![]() |
DataCount |
![]() |
d0 |
![]() |
d1 |
![]() |
d2 |
![]() |
d3 |
![]() |
d4 |
![]() |
d5 |
![]() |
d6 |
![]() |
d7 |
![]() |
Return |
CANTx
![]() |
CANTx |
Sends the Tx data with the ID specified in the form of a CAN message | |
![]() |
CANID |
![]() |
Return |
ClearKeypadBuffer
![]() |
ClearKeypadBuffer |
Destroys the contents of the keypad buffer. | |
![]() |
Return |
GetAnalogueInput
![]() |
GetAnalogueInput |
Returns the value for a specific analogue input on the MIAC slave. | |
![]() |
Input |
![]() |
Return |
GetDigitalInput
![]() |
GetDigitalInput |
Returns the value for a specific digital input on the MIAC slave. | |
![]() |
Input |
![]() |
Return |
GetDigitalInputs
![]() |
GetDigitalInputs |
Returns the value for a all 8 digital inputs on the MIAC slave. | |
![]() |
Return |
GetEEPROMData
![]() |
GetEEPROMData |
Reads a byte from the EEPROM data memory | |
![]() |
Address |
![]() |
Return |
GetKeypadBuffer
![]() |
GetKeypadBuffer |
Returns a keypress from the keypress buffer, returns 255 if no keypress is available. | |
![]() |
Return |
GetRegisterValue
![]() |
GetRegisterValue |
Gets the value of the register specified on the MIAC | |
![]() |
RegAddress |
![]() |
Return |
LCDClear
![]() |
LCDClear |
Clears the LCD display on the MIAC. | |
![]() |
Return |
LCDPrintNumber
![]() |
LCDPrintNumber |
Prints out a number to the display on the MIAC. | |
![]() |
Number |
![]() |
Return |
LCDPrintString
![]() |
LCDPrintString |
Prints a string to the LCD on the MIAC. | |
![]() |
Str |
![]() |
Return |
LCDSetCursor
![]() |
LCDSetCursor |
Sets the LCD cursor position on the MIAC | |
![]() |
x |
![]() |
y |
![]() |
Return |
PWMControl
![]() |
PWMControl |
Sets the PWM channel specified to be enabled or disabled | |
![]() |
Channel |
![]() |
Enable |
![]() |
Return |
PWMOvercurrentCheck
![]() |
PWMOvercurrentCheck |
Checks the PWM outputs to see if they are overcurrent | |
![]() |
Return |
PWMSetDuty
![]() |
PWMSetDuty |
Sets the duty cycle for the PWM channel specified | |
![]() |
Channel |
![]() |
Duty |
![]() |
Return |
PWMSetPeriod
![]() |
PWMSetPeriod |
Sets the PWM period for the channel specified | |
![]() |
Prescaler |
![]() |
Period |
![]() |
Return |
SetEEPROMData
![]() |
SetEEPROMData |
Writes a byte to the EEPROM data memory | |
![]() |
Address |
![]() |
Data |
![]() |
Return |
SetOutputBank
![]() |
SetOutputBank |
Controls the state of one of the transistor outputs on the MIAC slave. | |
![]() |
Mask |
![]() |
Output_States |
![]() |
Return |
SetRegisterValue
![]() |
SetRegisterValue |
Sets the value of the register specified on the MIAC | |
![]() |
RegAddress |
![]() |
Value |
![]() |
Return |
SetRelayOutput
![]() |
SetRelayOutput |
Controls the state of one of the Relay outputs on the MIAC slave. | |
![]() |
Relay |
![]() |
State |
![]() |
Return |
SetTransistorOutput
![]() |
SetTransistorOutput |
Controls the state of one of the transistor outputs on the MIAC slave. | |
![]() |
Transistor |
![]() |
State |
![]() |
Return |
Property reference
![]() |
Properties |
![]() |
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. |