Difference between revisions of "Component: USB HID (Comms: USB)"
Line 16: | Line 16: | ||
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
Line 22: | Line 24: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
Revision as of 10:40, 17 November 2021
Author | Matrix Ltd |
Version | 1.4 |
Category | Comms: USB |
Contents
USB HID component
Component to create and communicate using a standard HID type USB class. Compatible with simulation and USB enabled microcontroller devices PIC/dsPIC/AVR. Note that AVR is currently in Beta and may have problems with custom descriptors.
Detailed description
No detailed description exists yet for this component
Examples
Here are some examples to get you started with USB HID communications using Flowcode.
HID Mouse
Reads a EB014 keypad and depending on the key pressed sends the appropriate movement and button clicks to control the mouse.
The speed is set by the speed variable which can range from 1 to 127.
Key breakdown: 1 = UpLeft, 2=Up, 3=UpRight, 4=Left, 6=Right, 7=DownLeft, 8=Down, 9=DownRight, *=Left Click, #=Right Click.
Reads two encoders and moves the mouse cursor based on their movement since the last operation.
A switch on pin B0 can be used to toggle the left mouse click on and off and pin B1 can be connected to an LED to show the status of the left mouse button.
The EB073 encoders board connected to PortB will allow all of this functionality.
HID Keyboard
Converts a ASCII character into a keypress that will be sent to the USB host device.
A demo string is provided which is then broken down into characters and sent to the USB host.
Here is a file showing the standard HID keyboard scan codes to help make sense of the example.
File:HID Keyboard Scan Codes.xls
With the example running if you create a text file and highlight the text file then the USB device will populate the file with data.
E.g.
HelloFromYourUSBKeyboardDevice12345
HelloFromYourUSBKeyboardDevice12345
HelloFromYourUSBKeyboardDevice12345
Currently only compatible with the following characters: 0123456789!"£$%^&*()/\*-+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n\t
A complete list of keyboard scan codes can be found here under section 7 - Keyboards.
http://www.freebsddiary.org/APC/usb_hid_usages.php
HID Descriptor Tool
This tool allows you to create your own descriptors which can then be inserted into the HID descriptor property with the custom descriptor type selected.
Downloadable macro reference
![]() |
ReceiveByte |
Receives a byte from the USB. | |
![]() |
Idx |
![]() |
Return |
![]() |
SetSerialNumber |
Allows the device serial number to be edited. | |
![]() |
SerialNumber |
![]() |
Return |
![]() |
SendData |
Sends the contents of the transmit buffer to the USB. | |
![]() |
Return |
![]() |
CheckRx |
Checks for any incoming data. Returns the number of data bytes received since the last check. | |
![]() |
Return |
![]() |
UpdateData |
Allows a byte of the transmit buffer to be assigned. | |
![]() |
idx |
![]() |
value |
![]() |
Return |
![]() |
ReceiveString |
Receives a string of bytes from the USB | |
![]() |
NumBytes |
![]() |
Return |
![]() |
SendDataDirect |
Sends data directly to the USB | |
![]() |
Data |
![]() |
Return |
![]() |
Initialise |
Starts up the USB connection and waits for the device driver to be correctly installed on the PC. | |
![]() |
Return |
![]() |
DCOFFS |
Sets the dc offset to <nrf> Volts. (Lower limit: -4.500 Vdc - Upper limit: 4.500 Vdc). | |
[[File:]] - | DCOffset |
Sets the dc offset in Volts(Vdc) (4.500 Vdc - 4.500 Vdc). | |
![]() |
Return |
![]() |
PRE |
Sets the Parallel Port Enable Register to the value <nrf>. | |
![]() |
Status |
Set register value 0-255 | |
![]() |
Return |
![]() |
SWPMKRFREQ |
Sets the sweep marker to <nrf> Hz. (Lower limit: 10kHz - Upper limit: 100kHz). | |
[[File:]] - | Frequency |
Set the sweep marker in Hertz(Hz) (10kHz - 100kHz). | |
![]() |
Return |
![]() |
MODAMSRC |
Sets AM waveform source to; 0 = INT, 1 = EXT. | |
[[File:]] - | Source |
Sets AM waveform source (0 = INT, 1 = EXT). | |
![]() |
Return |
![]() |
AMPUNIT |
Sets the amplitude units to; 0 = VPP, 1 = VRMS, 2 = DBM. | |
![]() |
Units |
Sets the amplitude units (0 = VPP, 1 = VRMS, 2 = DBM). | |
![]() |
Return |
![]() |
ESRRet |
Returns the value in the standard event status register in <nr1> | |
![]() |
Return |
![]() |
QERRet |
Query and clear error register | |
![]() |
Return |
![]() |
SWPTIME |
Sets the sweep time to <nrf> seconds | |
[[File:]] - | Seconds |
Set the sweep time in seconds. | |
![]() |
Return |
![]() |
MODHOPFREQ |
Sets HOP frequency to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 50MHz). | |
[[File:]] - | Frequency |
Sets HOP frequency in Hertz(Hz) (1uHz - 50MHz). | |
![]() |
Return |
![]() |
PULSWID |
Sets the pulse waveform width to <nrf> sec. (Lower limit: 20ns - Upper limit: 1Ms). | |
[[File:]] - | Seconds |
Sets the pulse waveform width in seconds (20ns - 1Ms). | |
![]() |
Return |
![]() |
PRERet |
Returns the value in the Parallel Poll Enable Register in <nr1> numeric format. The syntax of the response is <nr1><rmt>. | |
![]() |
Return |
![]() |
MODPOLFSK |
Sets FSK trigger slope to; 0 = POS, 1 = NEG. | |
[[File:]] - | Slope |
Set FSK trigger slope (0 = POS, 1 = NEG). | |
![]() |
Return |
![]() |
ARB4Ret |
Returns the binary-data from an existing abbitrary wavefrom memory location. | |
![]() |
Return |
![]() |
ESERet |
Returns the value in the Standard Event Status Enable Register in <nr1> numeric format. The syntax of the response is <nr1><rmt>. | |
![]() |
Return |
![]() |
SLVRST |
Sets the SLAVE generator ready to be synchronised | |
![]() |
Return |
![]() |
SQRSYMM |
Sets the square waveform symmetry to <nrf> %. (Lower limit: 20 - Upper limit: 80) | |
[[File:]] - | Symmetry |
Sets the square waveform symmetry in percent (20 - 80). | |
![]() |
Return |
![]() |
OUTPUT |
Sets the output to; 0 = ON, 1 = OFF, 2 = NORMAL, 3 = INVERT. | |
![]() |
SetOutput |
Set the output. (0 = ON, 1 = OFF, 2 = NORMAL, 3 = INVERT). | |
![]() |
Return |
![]() |
MODPWMDEVWDT |
Sets the PWM waveform deviation to <nrf> sec. | |
[[File:]] - | Sec |
![]() |
Return |
![]() |
SWPMODE |
Sets the sweep mode to <CONT> or <TRIG>. 0 = CONT, 1 = TRIG. | |
[[File:]] - | Mode |
Set the sweep mode (0 = CONT, 1 = TRIG). | |
![]() |
Return |
![]() |
MODFSKRATE |
Sets FSK rate to <nrf> Hz. (Lower limit: 2mHz - Upper limit: 100kHz). | |
[[File:]] - | Rate |
Sets FSK rate in Hertz(Hz) (2mHz - 100kHz). | |
![]() |
Return |
![]() |
BST |
Sets the burst mode to; 0 = <OFF>, 1 = <NCYC>, 2= <GATED>, 3 = <INFINITE>. | |
![]() |
MODE |
Sets the burst mode (0 = OFF, 1 = NCYC, 2 = GATED, 3 = INFINITE). | |
![]() |
Return |
![]() |
LOLVL |
Sets the amplitude-low-level to <nrf> Volts. (Lower limit: 5.000 V - Upper limit: -0.010 V). | |
[[File:]] - | LowLevel |
Sets the amplitude-low-level in Volts(V) (-5.000 V - -0.010 V). | |
![]() |
Return |
![]() |
SAV |
Saves the complete instrument setup to the setup-file named <nrf> | |
![]() |
StoreLocation |
Memory location of register (0-9) | |
![]() |
Return |
![]() |
TRG |
This command is the same as pressing the TRIGGER key. | |
![]() |
Return |
![]() |
ARBDCOFFS |
Sets the arbritary dc waveform offset to <nrf> volts. | |
[[File:]] - | OffsetVoltage |
Set the offset voltage | |
![]() |
Return |
![]() |
SWPTRGPOL |
Sets the sweep trigger slope to; 0 = POS, 1 = NEG. | |
[[File:]] - | Slope |
Set the sweep trigger slope (0 = POS, 1 = NEG). | |
![]() |
Return |
![]() |
CLKSRC |
Sets the clock source to; 0 = INT, 1 = EXT. | |
[[File:]] - | Source |
Sets the clock source (0 = INT, 1 = EXT). | |
![]() |
Return |
![]() |
ARB1DEFRet |
Returns user specified waveform name, waveform pint interpolation state and waveform length of ARB1. | |
![]() |
Return |
![]() |
BEEP |
Sound one beep. | |
![]() |
Return |
![]() |
SWPCNTFREQ |
Sets the sweep centre frequency to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 50MHz). | |
[[File:]] - | Frequency |
Sets the sweep centre frequency in Hertz(Hz) (1uHz - 50MHz). | |
![]() |
Return |
![]() |
SWP |
Sets the sweep to <ON> or <OFF>. 0 = ON, 1 = OFF. | |
[[File:]] - | Sweep |
Enable or disable the sweep (0 = ON, 1 = OFF). | |
![]() |
Return |
![]() |
BSTTRGSRC |
Sets the burst trigger source to; 0 = INT, 1 = EXT, 2 = MAN. | |
![]() |
Source |
Set the burst trigger source (0 = INT, 1 = EXT, 2 = MAN). | |
![]() |
Return |
![]() |
MODPWMFREQ |
Sets PWM waveform frequency to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 20kHz). | |
[[File:]] - | Frequency |
Sets PWM waveform frequency in Hertz(Hz) (1uHz - 20kHz). | |
![]() |
Return |
![]() |
ARB2Ret |
Returns the binary-data from an existing abbitrary wavefrom memory location. | |
![]() |
Return |
![]() |
RST |
Resets the instrument parameters to their default values. | |
![]() |
Return |
![]() |
RMPSYMM |
Sets the ramp waveform symmetry to <nrf> %. (Lower limit: 0 - Upper limit: 100) | |
[[File:]] - | Symmetry |
Sets the ramp waveform symmetry in percent (0 - 100). | |
![]() |
Return |
![]() |
BSTCOUNT |
Sets the burst count to <nrf> cycles, maximum 1048575 cycles. | |
[[File:]] - | Count |
Sets the burst count in cycles (1 - 1048575). | |
![]() |
Return |
![]() |
SWPMKR |
Sets the sweep marker to <ON> or <OFF>. 0 = ON, 1 = OFF. | |
[[File:]] - | Marker |
Enable or disable the sweep marker (0 = ON, 1 = OFF). | |
![]() |
Return |
![]() |
PULSFREQ |
Sets the pulse waveform frequency to <nrf> Hz (Lower limit: 1uHz - Upper limit: 50MHz). | |
[[File:]] - | Frequency |
Sets the pulse waveform frequency in Hertz(Hz) (1uHz - 50MHz). | |
![]() |
Return |
![]() |
MODFMDEV |
Sets FM waveform deviation to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 25MHz). | |
[[File:]] - | Deviation |
Sets FM waveform deviation in Hertz(Hz) (1uHz - 25MHz). | |
![]() |
Return |
![]() |
RCL |
Recalls the instrument setup contained in store <nrf>. | |
![]() |
StoreLocation |
Memory location (0-9) | |
![]() |
Return |
![]() |
ESESet |
Sets the standard event status enable register to the value of <nrf>. (Lower limit: 0 - Upper limit: 255) | |
![]() |
Value |
Enable the register to this value. (0 - 255) | |
![]() |
Return |
![]() |
LOCAL |
Returns the instrument to local opertion and unlocks the keyboard. | |
![]() |
Return |
![]() |
SWPSPNFREQ |
Sets the sweep frequency span to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 50.25kHz). | |
[[File:]] - | Frequency |
Set the sweep frequency span in Hertz(Hz) (1uHz - 50.25kHz). | |
![]() |
Return |
![]() |
CALSTEP |
Step to the next calibration point. | |
![]() |
Return |
![]() |
SRERet |
Returns the value of the Service Request Enable Register in <nr1> numeric format. | |
![]() |
Return |
![]() |
MODPMFREQ |
Sets PM waveform frequency to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 20kHz). | |
[[File:]] - | Frequency |
Sets FM waveform frequency in Hertz(Hz) (1uHz - 20kHz). | |
![]() |
Return |
![]() |
ARBRESIZE |
Changes the size of arbritary waveform <cpd> to <nrf>. | |
[[File:]] - | Size |
Size of waveform | |
![]() |
Waveform |
Arbritary Waveform | |
![]() |
Return |
![]() |
LRN |
Intall data from a previous *LRN? command. | |
![]() |
Return |
![]() |
ARB4 |
Loads the binary-data to an existing arbitrary waveform memory location ARB4. | |
![]() |
Waveform |
![]() |
Return |
![]() |
CLKSRRet |
Returns the clock source <INT> or <EXT>. | |
[[File:]] - | Return |
![]() |
MODPMDEV |
Sets PM waveform deviation to <nrf> degrees. (Lower limit: -360° - Upper limit: 360°). | |
[[File:]] - | Degrees |
Sets PM waveform deviation in degrees (-360 - 360). | |
![]() |
Return |
![]() |
MSTLOCK |
Sends signal to SLAVE generator to get synchronised | |
![]() |
Return |
![]() |
HILVL |
Sets the amplitude-high-level to <nrf> Volts. (Lower limit: -0.490 V - Upper limit: 5.000 V). | |
[[File:]] - | HighLevel |
Sets the amplitude-high-level in Volts(V) (-0.490 V - 5.000 V). | |
![]() |
Return |
![]() |
ARB3 |
Loads the binary-data to an existing arbitrary waveform memory location ARB3. | |
![]() |
Waveform |
![]() |
Return |
![]() |
CALADJ |
Adjust the selected calibration value by <nrf> (Lower limit: -100 - Upper limit: 100). | |
[[File:]] - | Calibrate |
Adjust the selected calibration value (-100 - 100). | |
![]() |
Return |
![]() |
STBRet |
Returns the value of the Status Byte Register in <nr1> numeric format. | |
![]() |
Return |
![]() |
ARB2 |
Loads the binary-data to an existing arbitrary waveform memory location ARB2. | |
![]() |
Waveform |
![]() |
Return |
![]() |
EERRet |
Query and clear execution error number register. | |
![]() |
Return |
![]() |
MODFMSRC |
Sets FM waveform source to; 0 INT, 1 = EXT. | |
[[File:]] - | Source |
Sets FM waveform source (0 = INT, 1 = EXT). | |
![]() |
Return |
![]() |
MODAMFREQ |
Sets AM waveform frequency to <nrf> Hz. (Lower limit: 1uHz - Upper limit: 20kHz). | |
[[File:]] - | Frequency |
Sets AM waveform frequency in Hertz(Hz) (1uHz - 20kHz). | |
![]() |
Return |
![]() |
ESE |
Sets the Standard Event Status Enable Register to the value of <nrf>. | |
![]() |
Value |
Value of register 0-255 | |
![]() |
Return |
![]() |
ARB1 |
Loads the binary-data to an existing arbitrary waveform memory location ARB1. | |
![]() |
Waveform |
16 Bit binary number for arbitrary waveform. | |
![]() |
Return |
![]() |
ARB4DEFRet |
Returns user specified waveform name, waveform pint interpolation state and waveform length of ARB4. | |
![]() |
Return |
![]() |
CLS |
Clears status byte register of the interface. | |
![]() |
Return |
![]() |
MSTRELOCK |
Resynchronises the two generators in MASTER-SLAVE mode. | |
![]() |
Return |
![]() |
NOISLVL |
Sets the output noise level to <nr1> %. (Lower limit: 0% - Upper limit: 50%) | |
![]() |
Percent |
Sets the output noise level in percent. (0 - 50) | |
![]() |
Return |
![]() |
LOCKMODE |
Sets the synchronising mode to; 0 = MASTER, 1 = SLAVE, 2 = INDEP. | |
![]() |
Mode |
Sets the synchronising mode (0 = MASTER, 1 = SLAVE, 2 = INDEP). | |
![]() |
Return |
![]() |
ADDRESSRet |
Returns the instruments address | |
[[File:]] - | Return |
![]() |
MODPMSRC |
Sets PM waveform source to; 0 INT, 1 = EXT. | |
[[File:]] - | Source |
Sets PM waveform source (0 = INT, 1 = EXT). | |
![]() |
Return |
![]() |
MODPWMSRC |
Sets PWM waveform source to; 0 = INT, 1 = EXT. | |
[[File:]] - | Source |
Sets PWM waveform source (0 = INT, 1 = EXT). | |
![]() |
Return |
![]() |
MOD |
Sets modulation to; 0 = OFF, 1 = AM, 2 = FM, 3 = PM, 4 = FSK, 5 = PWM. | |
![]() |
Modulation |
Sets modulation (0 = OFF, 1 = AM, 2 = FM, 3 = PM, 4 = FSK, 5 = PWM). | |
![]() |
Return |
![]() |
ISTRet |
Returns IST local message as defined by IEEE Std. 488.2. The syntax of the response is 0<rmt>, if the local message is false, or 1<rmt>, if the local message is true. | |
[[File:]] - | Return |
![]() |
LRNRet |
Returns the complete setup of the instrument as a binary data block | |
[[File:]] - | Return |
![]() |
OPCRet |
Query Operation Complete status. The response is always 1<rmt> and will be available immediately the command is executed because all commands are sequential. | |
[[File:]] - | Return |
![]() |
PULSRANGE |
Sets PWM waveform source to <1>, <2> or <3>; 1 = 1, 2 = 2, 3 = 3. | |
![]() |
Range |
Sets the pulse rise and fall range. (1, 2 or 3) | |
![]() |
Return |
![]() |
TSTRet |
The generator has no self test capability and the response is always 0 <rmt>. | |
[[File:]] - | Return |
![]() |
BSTTRGPOL |
Sets the burst trigger slope to; 0 = POS, 1 = NEG. | |
[[File:]] - | Slope |
Set the burst trigger slope (0 = POS, 1 = NEG). | |
![]() |
Return |
![]() |
ARB3Ret |
Returns the binary-data from an existing abbitrary wavefrom memory location. | |
![]() |
Return |
![]() |
BSTPHASE |
Sets the burst phase to <nrf> degrees. (Lower limit: -360 - Upper limit: 360) | |
[[File:]] - | Degrees |
Sets the burst phase in degrees (-360 - 360) | |
![]() |
Return |
![]() |
SWPTRGPER |
Sets the sweep trigger period to <nrf> seconds | |
[[File:]] - | Seconds |
Set the sweep trigger period in seconds. | |
![]() |
Return |
![]() |
PULSDLY |
Sets the waveform delay to <nrf> sec | |
[[File:]] - | Sec |
![]() |
Return |
![]() |
Initialise |
Opens the COM port ready for communications. | |
![]() |
Return |