Sensors and Inputs

= Sensors and Inputs =
== Sip/Puff Sensors ==
The Sip/Puff Sensors on the mouthpiece and the individual tube(s) on either side of the joystick can each sense vacuum or pressure over a range of +/-2kPa (4 inches Water Column) and measure the analog value to categorize the strength as high or low, for a combination of four signals per sensor, hard and soft, sip or puff. When a sensor is active, an LED lights to give feedback to the user. Red for puff and Blue for sip.
To avoid triggering a soft sip/puff signal while applying a stronger pressure, a slight delay (typ 1200ms) is used to allow time for the pressure to move out of the soft region, to the hard region, before generating the signal. While the pressure is in the soft region, the corresponding status LED is lit and an audio tone, which varies with pressure, is produced, to give the user feedback about the pressure they are applying. 
Once the time delay has expired, or the pressure increases into the hard range, a click sound indicates the signal has been triggered. Once triggered, the Soft signal latches and the pressure must return below a Deactivation Threshold before the signal will release. When either Soft or Hard pressure signals are active, the pressure above the higher threshold can be used as an analog value, like with a Gamepad Trigger. If the Soft pressure zone for a particular tube is not used, the audio tones are suppressed.
The soft/hard pressure thresholds and the time delay for detecting a soft Sip/Puff are adjustable by the user.
== The Mouthpiece ==
The mouthpiece can have either two or three sip/puff holes plus a lip position sensor. The lip sensor activation and sensitivity is adjustable from a slight movement to one-half inch from the inactive position. A thumbscrew allows the lip sensor to be placed in a comfortable position. The Sip/Puff tube openings in the mouthpiece can be individually selected or used in combination, by positioning the mouth over one, two or three holes or using the tongue to cover one while sipping or puffing on another. 
With a three hole, Left, Center, Right, mouthpiece, this allows for six different hole combinations (L, C, R, LC, CR, LCR, LR (by covering the center hole with the tongue)). Multiply that by two pressure polarities (sip/puff), and two different pressure thresholds (soft & hard), for a total of twenty four signals to be obtained from the mouthpiece Sip/Puff sensors: Adding in the Push switch to act as a “Shift” key, doubles that to forty-eight discrete signals (twelve of which can also be analog), before the joystick is even moved.
With the two hole mouthpiece, a total of twelve signals can be obtained from the mouthpiece Sip/Puff sensors: Three tube combinations (L, R, LR) times two polarities of pressure times two strengths of pressure. Adding in the Push switch to act as a “Shift” key, doubles that to twenty-four discrete signals (six of which can also be analog).
In practice, a small subset of the combinations is typically used but the capability is there when needed for special situations. 
The following table contains the names of all the Sip/Puff inputs for a Three Hole Mouthpiece, with a brief description and if the adjustable delay timer is used to detect the input (This is a factor when determining suitable inputs choices to avoid slowing reaction time during game play):
top
For the two hole mouthpiece, the mp_center_sip/puff is renamed left_sip/puff.
Input Name 	Description 	Delay
mp_left_sip 	Mouthpiece Hard Sip Left sip/puff sensor 	instant
mp_left_puff 	Mouthpiece Hard Puff Left sip/puff sensor 	instant
mp_right_sip 	Mouthpiece Hard Sip Right sip/puff sensor 	instant
mp_right_puff 	Mouthpiece Hard Puff Right sip/puff sensor	instant
mp_left_right_sip 	Mouthpiece Hard Sip Both sip/puff sensors 	instant
mp_left_right_puff 	Mouthpiece Hard Puff Both sip/puff sensors	instant
left_sip 	Hard Sip Left sip/puff sensor 	instant
left_puff 	Hard Puff Left sip/puff sensor 	instant
right_sip 	Hard Sip Right sip/puff sensor 	instant
right_puff 	Hard Puff Right sip/puff sensor 	instant
mp_left_sip_soft 	Mouthpiece Soft Sip Left sip/puff sensor 	delay
mp_left_puff_soft 	Mouthpiece Soft Puff Left sip/puff sensor 	delay
mp_right_sip_soft 	Mouthpiece Soft Sip Right sip/puff sensor 	delay
mp_right_puff_soft 	Mouthpiece Soft Puff Right sip/puff sensor	delay
mp_left_right_sip_soft 	Mouthpiece Soft Sip Both sip/puff sensors 	delay
mp_left_right_puff_soft	Mouthpiece Soft Puff Both sip/puff sensors	delay
left_sip_soft 	Soft Sip Left sip/puff sensor 	delay
left_puff_soft 	Soft Puff Left sip/puff sensor 	delay
right_sip_soft 	Soft Sip Right sip/puff sensor 	delay
right_puff_soft 	Soft Puff Right sip/puff sensor 	delay
Table 1: Mouthpiece Inputs for Two Hole Mouthpiece
== Joystick ==
The joystick measures the deflection from the home, or center, position and produces both continuous analog values and discrete position signals, depending upon the output to which it is connected. When used for the Mouse or one of the Game Pad joysticks, the position is reported as continuously variable with the movement of the joystick. When used with a discrete output, like the D-Pad buttons, or to change the TV channel, when sending Infrared commands, the joystick’s position is divided up into a series of zones, such as North, South, East and West, which triggers a signal when the joystick is moved into a zone.
The discrete zones are further divided into the Ordinal directions, North-East, South-East, etc as well as into Inner ring and Outer ring zones, in a manner similar to the dual pressure thresholds for the Sip/Puff sensors. When moving through the inner ring, a tone is produced to indicate the joystick is within the inner ring region and a click is produced when either the time delay expires, or the joystick moves into the outer ring and an outer ring signal is triggered.
thumb|top|Illustration 2: Joystick Discrete Zones
The Joystick Discrete Zones diagram shows the active areas to which the joystick can be positioned to trigger a signal. The areas of deeper color saturation, around the Cardinal and Ordinal directions, show where the joystick must be to be detected. The lighter mixed color areas between the eight directions show hysteresis areas where the previous signal will remain active until the joystick enters the next detection zone. For instance, starting at North, the joystick can be moved from the Green area, into the Blue-Green-Gray area towards either NE or NW and still maintain the North signal. It can move back into the Green area and no interruption of the North signal will have occurred. However, once the joystick crosses into the Blue area around NE or NW, that new signal becomes active and will remain active as long as the joystick remains in the Blue area or the adjacent Blue-Green or Magenta areas.
The inner and outer rings operate like the Soft and Hard Sip/Puff pressures: After entering the Inner ring, the user must hold the joystick in the area between the Hysteresis ring and the Outer ring until a timer expires and triggers the signal. A tone that varies with the position will sound until the timer expires. Once the Inner ring timer has expired and the inner ring signal is activated, the joystick has to return to the center position before moving to trigger an Outer ring signal. Once triggered, either the inner or outer ring signals will stay active as long as the joystick stays outside the Hysteresis ring. The joystick deflection between the Outer ring and the maximum deflection is scaled into the pressure applied to the corresponding PS3 button, if so mapped. 
Sixteen discrete signals can be produced from the joystick using the eight compass directions and the inner/outer rings, plus using the Bite sensor like a Shift key, brings the total to thirty-two.
The deflection ring thresholds and overall sensitivity of the joystick are adjustable by the user. If the inner ring zones are not used in a specific profile, the audio tones are suppressed. 
The following table contains the name of all the Joystick Zones input signals, with a brief description and if the adjustable delay timer is used to detect the input.
Input Name	Description 	Delay
left 	Joystick Left Analog value 	instant
right 	Joystick Right Analog value 	instant
up 	Joystick Up Analog value 	instant
down 	Joystick Down Analog value 	instant
N 	Joystick Outer ring North zone 	instant
NE 	Joystick Outer ring North East zone	instant
E 	Joystick Outer ring East zone 	instant
SE 	Joystick Outer ring South East zone	instant
S 	Joystick Outer ring South zone 	instant
SW 	Joystick Outer ring South West zone	instant
W 	Joystick Outer ring West zone 	instant
NW 	Joystick Outer ring North West zone	instant
N_inner 	Joystick Inner ring North zone 	delay
NE_inner 	Joystick Inner ring North East zone	delay
E_inner 	Joystick Inner ring East zone 	delay
SE_inner 	Joystick Inner ring South East zone	delay
S_inner 	Joystick Inner ring South zone 	delay
SW_inner 	Joystick Inner ring South West zone	delay
W_inner 	Joystick Inner ring West zone 	delay
NW_inner 	Joystick Inner ring North West zone	delay
Table 2: Joystick Inputs
== Using External Inputs ==
Up to ten external input switches can be connected to the QuadStick, but there are some subtle issues with how they can be used together. All input signals are “logic level” signals and require switch contacts suitable for low current applications.
=== Input Jack with Two Switches ===
The Inputs jack on the back of the QuadStick is a 3mm stereo connector with the two input circuits (Tip & Ring) and Shield (or Ground). Two switches may be connected using the following circuit.
thumb|Illustration 3: Digital Input Connections for Two Switches
Input Name 	Description 	Delay
digital_in_1	Input Jack - Tip to Shield (SW1) 	instant
digital_in_2	Input Jack - Ring to Shield (SW2)	instant
Table 3: External Inputs 1 & 2
When using two Switches in this manner, the QuadStick can detect the switch closures independently and simultaneously. 
=== Input Jack with Four Switches ===
Using the following circuit, it is possible to add two more switches, however, with the caveat that only one switch at a time is allowed to close:
thumb|top|Illustration 4: Digital Input Connections for Four Switches
Input Name 	Description 	Delay
digital_in_1	Input Jack - Tip to Shield (SW1) 	instant
digital_in_2	Input Jack - Ring to Shield (SW2) 	instant
digital_in_3	Input Jack - Ring to Diode to Tip (SW3)	instant
digital_in_4	Input Jack - Tip to Diode to Ring (SW4)	instant
Table 4: External Inputs 3 & 4
When Switches 3 and/or 4 (plus the diodes) are added, we can detect which of the four switches are closed, but only if one is closed at a time. We do this by driving each of the I/O pins low, and seeing of the other pin drops low. If two switches are closed simultaneously, we can no longer determine which of the switches are closed, we just know that two, or more, are closed. This configuration is suitable for a 4-way joystick, where only one contact is made at a time or 4 separate switches that would not be operated at the same time. 
=== USB-A Jack with Two Switches ===
If the USB-A jack is not used for connecting to another USB device, it can be used as another Digital Input channel. Two switches may be connected using the circuit below:
thumb|top|Illustration 5: USB-A Jack with Two Switches
Input Name 	Description 	Delay
digital_in_5	USB-A Data - to Gnd (SW1)	instant
digital_in_6	USB-A Data + to Gnd (SW2)	instant
Table 5: Digital Inputs 5 & 6
The QuadStick can detect closures of Switches 1 and 2 independently and simultaneously.
=== USB-A Jack with Four Switches ===
The next circuit shows how to connect 4 switches to the USB-A connector, with the caveat that Switch pairs 1-3 or 2-4 must never close both switches in a pair at the same time.
thumb|top|Illustration 6: USB-A Jack with Four Switches
Input Name 	Description 	Delay
digital_in_5	USB-A Data - to Gnd (SW1)	instant
digital_in_6	USB-A Data + to Gnd (SW2)	instant
digital_in_7	USB-A Data - to Vcc (SW3)	instant
digital_in_8	USB-A Data +to Vcc (SW4) 	instant
Table 6: USB-A Digital Inputs 5, 6, 7 & 8 
An 8-way joystick is perfect for this circuit, using Switches 1 and 3 for opposite cardinal points (like North and South) and 2 and 4 for the orthogonal cardinal points.
=== USB-A Jack with Six Switches ===
There are several caveats to the operation of this port with six switches, like there are the main Digital Input port when using the multiplexed switches. This port can detect Switches 1 and 2, independently and simultaneously, but when we add the additional switches, we have to be careful. As with the circuit with Four switches above, certain combinations of switches must never be allowed to close at the same time, both for the inability to determine which switches are close and the possibility of shorting out the power supply.
thumb|none|Illustration 7: USB-A Jack with Six Switches
Input Name 	Description 	Delay
digital_in_5 	USB-A Data - to Gnd (SW1) 	instant
digital_in_6 	USB-A Data + to Gnd (SW2) 	instant
digital_in_7 	USB-A Data - to Vcc (SW3) 	instant
digital_in_8 	USB-A Data +to Vcc (SW4) 	instant
digital_in_9 	USB-A Data + to Diode to Data - (SW5)	instant
digital_in_10	USB-A Data - to Diode to Data + (SW6)	instant
Table 7: USB-A Digital Inputs 5 through 10
== USB-A for Chaining 3rd Party Devices ==
This feature is not yet implemented. The purpose of the USB-A connector is to allow a separate gamepad to be used in tandem to the QuadStick's built-in inputs. If the user can operate some or all inputs of another gamepad, the outputs from that device can be treated as Inputs to the QuadStick and mixed in with the rest of the Input sources in a configuration profile. 
== Voice Commands ==
Through a serial connection, either via Bluetooth or the Input jack, commands may be sent to the QuadStick from a PC. The format for activating output signals is:
output_name,state, value, duration\r 
where:
output_name is from the outputs list.
state is 0=off, 1=on, -1=toggle state.
value is an integer percent 0-100.
duration is in milliseconds or -1 for permanent.
Example, press D-Pad North button with half force for 200 milliseconds:
dpad_n,1,50,200\r
Example, press and hold Circle button continuously (until new command or reset):
circle,1,100,-1
Plus direct commands for controlling the operation of the QuadStick:
Command 	Description
mode,# 	Change selected profile mode to new value
reset 	Clear all output states and values to zero
boot 	Reboot QuadStick
help 	Print a Help messong
load,filename.csv	Load new configuration profile
echo 	Turn on local echo (for debugging)
swap,output_name 	Exchange inputs for Lip Sensor with another output
and,output_name 	Add a second output to the Lip Sensor
print 	Print out the active profile
debug 	Print out internal values
Commands are usually generated by using Dragon Naturally Speaking or Windows Speech Recognition set up with Vocola, a free voice control language program, plus PuTTY, a free communication program, and a Vocola configuration file available from QuadStick's website, to translate spoken words into the proper form for the QuadStick.
Visit the Support page on the QuadStick website for installation instructions and links to the required programs and files.
As of this writing, the following vocabulary has been developed:
Action Buttons 	Action Buttons 	Action Buttons 	Action Buttons
Square 	<nothing> 	 	Pushes button with 100% force for 200 ms
Circle 	% 	 	Pushes button with % force for 200 ms
Triangle 	% for ## seconds 	 	Pushes button with % force for ## seconds
Xray 	For ## seconds 	 	Pushes button with 100% force for ## seconds
Home 	On 	 	Holds button down with 100% force
Select 	Off 	 	Releases button
Start 	Toggle 	 	Releases or Holds button
Left One 	 	 	
Left Two 	 	 	
Left Three 	 	 	
Right One 	 	 	
Right Two 	 	 	
Right Three 	 	 	
 	 	 	
D-Pad 	D-Pad 	D-Pad 	D-Pad
North 	 	 	D-Pad Up
North East 	 	 	D-Pad Up and Right
East 	 	 	D-Pad Right
South East 	 	 	D-Pad Down and Right
South 	 	 	D-Pad Down
South West 	 	 	D-Pad Down and Left
West 	 	 	D-Pad Left
North West 	 	 	D-Pad Up and Left
 	 	 	
 	 	 	
Analog Sticks 	Analog Sticks 	Analog Sticks 	Analog Sticks
Player 	Up 	<%> 	Holds stick in specified direction by <%>
Look 	Down 	<%> 	(default = 100%)
 	Left 	<%> 	
 	Right 	<%> 	
 	 	 	
Lip Sensor Control 	Lip Sensor Control 	Lip Sensor Control 	Lip Sensor Control
Swap 	Square 	 	Switches Lip input with named output
And 	Circle 	 	Adds named output to Lip input
 	Triangle 	 	
 	Xray 	 	
 	Home 	 	
 	Select 	 	
 	Start 	 	
 	Clear 	 	Clears out Swap funtion
 	 	 	
Quadstick Control 	Quadstick Control 	Quadstick Control 	Quadstick Control
Reset 	 	 	All outputs cleared
Quit 	 	 	
Stop 	 	 	
 	 	 	
Mode ## 	 	 	Switch directly to mode ##
Full Screen 	 	 	Toggles Full Screen display
Help 	 	 	Display help text message
Reboot Quad Stick 	 	 	Restarts the quadstick
 	 	 	
Load 	Call of Duty 	 	Loads cod.csv file
 	Default 	 	Loads config.csv file
 	 	 	
 	 	 	
 	 	 	
 	 	 	
 	 	 	
 	 	 	
Call of Duty Commands	Call of Duty Commands	Call of Duty Commands	Call of Duty Commands
Reload 	 	 	Square
Attack 	 	 	Circle
Weapon 	 	 	Triangle
Grenade 	 	 	R2
Special 	 	 	L2
Jump 	 	 	X
 	 	 	
Fire 	 	 	R1 for two seconds
Down 	 	 	R3
Flat 	 	 	R3 for 350 ms
Sprint <sec> 	 	 	L3 for <sec> seconds (default = 20 seconds)
Auto 	 	 	Square for ten seconds
 	 	 	
Aim Rifle 	 	 	L1 toggle
 	 	 	
MLB the Show 	MLB the Show 	MLB the Show 	MLB the Show
Pick off 	 	 	L2 for two seconds
 	First 	 	L2 for two seconds + Circle
 	Second 	 	L2 for two seconds + Triangle
 	Third 	 	L2 for two seconds + Square
== Summary ==
The goal of the QuadStick is to be able to extract as much information as possible using just the mouth, lips, and tongue but to also have a way to incorporate external sensors to take advantage of any other inputs the user can actuate.
The number of discrete signals possible in a single configuration profile is thirty-two for the joystick, plus twenty-four for the mouthpiece, plus eight more from each Sip/Puff tubes, for a grand total of seventy-two. Adding any external inputs can, in theory, bring that total up to eighty two. In practice, most applications map a small subset of the possible input signals to outputs, particularly for games, since there are only about twenty buttons on a gamepad. Later, in the Keyboard section, we will see how sequences of multiple input signals can be chained together and used to trigger a specific output.