![]() | LEGO Mindstorms EV3 |
Manages the detection of adding and removing different devices to an input or an output port.
The device will change some connection levels on the port when added and that way give an event to start the evaluation of the device id.
The evaluation state machine is timer interrupt driven at a low frequency (less than 1KHz) so the used CPU power is held at lowest possible level.
Input Port
If anything changes to a steady value (for more than STEADY_TIME) it will start a state machine that will try to detect what happened.
When it is detected - a signal is sent to the Input Library Device Setup and the state will freeze in a state that only looks for an open port condition (for more than STEADY_TIME).
*/ #define IN_CONNECT_STEADY_TIME 350 // [mS] time needed to be sure that the connection is steady #define IN_DISCONNECT_STEADY_TIME 100 // [mS] time needed to be sure that the disconnection is steady #define IN1_NEAR_5V 4800 // [mV] higher values mean that connection 1 is floating #define IN1_NEAR_PIN2 3100 // [mV] higher values mean that connection 1 is shorted to connection 2 (5000 * 18K / (18K + 10k)) #define IN1_TOUCH_HIGH 950 // [mV] values in between these limits means that an old touch sensor is connected #define IN1_TOUCH_LOW 850 // [mV] #define IN1_NEAR_GND 100 // [mV] lower values mean that connection 1 is shorted to connection 3 #define IN6_NEAR_GND 150 // [mV] lower values mean that connection 6 is floating /* INPUT ************************************************************************************************************************************************************************************************************************** MICRO CIRCUIT CONNECTION EV3 UART DEVICE EV3 DUMB INPUT DEVICE NXT SENSOR TACHO MOTOR EV3 DUMB OUTPUT DEVICE ---------------------- ---------------------------------- ---------- --------------------- ------------------------ -------------------- ---------------- ---------------------- Analogue I 10K pull up to ADC_REF 1 Short circuit to ground ID resistor to ground Analogue value Motor + Motor + Digital I 6K4 impedance to NEAR_PIN2 voltage 2 Open Open Short to ground Motor - Motor - Ground Ground 3 Ground Ground Ground Ground Ground Supply Supply 4 Supply Supply Supply Supply Supply Digital I/O (float) 100K pull up to 3.3V 5 RXD (float) Short to ground ? Tacho A ID resistor to ground Analogue I + Digital I/O (float) 220K pull down to ground 6 TXD (low) Analogue value ? Tacho B Float or low ************************************************************************************************************************************************************************************************************************** ID VALUE ON CONNECTION 1: ADC_REF ----- IN1_NEAR_5V ----- | | | TACHO MOTOR and EV3 DUMB OUTPUT DEVICE | | IN1_NEAR_PIN2 ----- | | | | | | | | EV3 INPUT DEVICE ID's | | | | | | | EV3 UART DEVICE 0.0V -----
IMPLEMENTED DETECTION RULES (sequence matters): I. Connection 2 low 1. Connection 5 and 6 high -> NXT IIC DEVICE 2. Connection 5 low -> NXT LIGHT SENSOR 3. Connection 1 lower than IN1_NEAR_GND -> NXT COLOR SENSOR 4. Connection 1 higher than IN1_NEAR_5V -> NXT TOUCH SENSOR 5. Connection 1 between IN1_TOUCH_HIGH and IN1_TOUCH_LOW -> NXT TOUCH SENSOR 6. else -> NXT SOUND SENSOR II. Connection 1 loaded 1. Connection 1 higher than IN1_NEAR_PIN2 -> ERROR 2. Connection 1 lower than IN1_NEAR_GND -> EV3 UART DEVICE 3. else (value on connection 1 is ID) -> EV3 DUMB INPUT DEVICE III. Connection 6 high -> NXT IIC TEMP SENSOR IV. Connection 5 low -> ERROR
EV3 DUMB INPUT DEVICE ID's: The range from 0mV to just beneath the voltage on connection 2 is free to be used for the EV3 dumb input device ID's: 0R <100mV Intelligent input device (UART sensor) 430R 206mV I-#01 - RESERVED for LEGO EV3 input device 910R 427mV LEGO EV3 Touch sensor 1K3 575mV I-#03 - RESERVED for LEGO EV3 input device 2K0 833mV I-#04 - RESERVED for LEGO EV3 input device 2K7 1063mV I-#05 - RESERVED for LEGO EV3 input device 3K3 1241mV I-#06 - RESERVED for LEGO EV3 input device 3K9 1403mV LEGO EV3 Test 4K7 1599mV I-#07 - RESERVED for LEGO EV3 input device 5K6 1795mV I-#08 - RESERVED for LEGO EV3 input device 6K8 2024mV I-#10 - RESERVED for LEGO EV3 input device 7K87 2202mV I-#11 - RESERVED for LEGO EV3 input device 9K1 2382mV I-#12 - RESERVED for LEGO EV3 input device 11K 2619mV I-#13 - RESERVED for LEGO EV3 input device 13K 2826mV Third party input device
The hysteresis is defined by IN1_ID_HYSTERESIS (see System Defines)
\n
Output Port
If anything changes to a steady value (for more than STEADY_TIME) it will start a state machine that will try to detect what happened.
When it is detected - a signal is sent to the Input Library Device Setup and the state will freeze in a state that only looks for an open port condition (for more than STEADY_TIME).
*/ #define OUT5_IIC_HIGH 3700 // [mV] values in between these limits means that an old IIC sensor or color sensor is connected #define OUT5_IIC_LOW 2800 // [mV] #define OUT5_BALANCE_HIGH 2600 // [mV] values in between these limits means that connection 5 is floating #define OUT5_BALANCE_LOW 2400 // [mV] #define OUT5_LIGHT_HIGH 850 // [mV] values in between these limits means that an old light sensor is connected #define OUT5_LIGHT_LOW 650 // [mV] #define OUT5_NEAR_GND 100 // [mV] lower values mean that connection 5 is shorted to ground #define OUT5_DUMP_HIGH 2350 #define OUT5_DUMP_LOW 1150 #define OUT5_MINITACHO_HIGH1 2000 // [mV] values in between these limits means that a mini tacho motor is pulling high when pin5 is pulling low #define OUT5_MINITACHO_LOW1 1600 // [mV] #define OUT5_NEWTACHO_HIGH1 1600 // [mV] values in between these limits means that a new tacho motor is pulling high when pin5 is pulling low #define OUT5_NEWTACHO_LOW1 1200 // [mV] #define OUT5_INTELLIGENT_HIGH1 1150 #define OUT5_INTELLIGENT_LOW1 850 #define OUT5_INTELLIGENT_HIGH2 1150 #define OUT5_INTELLIGENT_LOW2 850 #define OUT5_NEWTACHO_HIGH2 650 // [mV] values in between these limits means that a new tacho motor is pulling low when pin5 floats #define OUT5_NEWTACHO_LOW2 450 // [mV] #define OUT5_MINITACHO_HIGH2 450 // [mV] values in between these limits means that a mini tacho motor is pulling low when pin5 floats #define OUT5_MINITACHO_LOW2 250 // [mV] /* OUTPUT ************************************************************************************************************************************************************************************************************************** MICRO CIRCUIT CONNECTION EV3 UART DEVICE EV3 DUMB INPUT DEVICE NXT SENSOR TACHO MOTOR EV3 DUMB OUTPUT DEVICE ---------------------- ------------------------------- ---------- --------------------- ------------------------ -------------------- ---------------- ---------------------- Motor driver + Connected to motor driver 1 ID resistor to ground ID resistor to ground Analogue value Motor + Motor + Motor driver - 100K pull up to ADC_REF 2 Open Open Short to ground Motor - Motor - Ground Ground 3 Ground Ground Ground Ground Ground Supply Supply 4 Supply Supply Supply Supply Supply Analogue I + Digital I/O 50K impedance to OUT5_BALANCE 5 RXD (float) Short to ground ? Tacho A ID resistor to ground Digital I/O (low) 100K pull up to connection 2 6 TXD (low) Analogue value ? Tacho B ? ************************************************************************************************************************************************************************************************************************** ID VALUE ON CONNECTION 5: ADC_REF --------------------------------------------------------------------- NEAR_5V ----- | | | | | 3.3 - | - - - - - - - - - - - - - - - - - - - - - - | - - - - - - - - - - - - FUTURE ADC reference voltage | LARGE TACHO MOTOR - | MINI TACHO MOTOR - OLD TACHO MOTOR | NEW TACHO MOTOR - OUT5_IIC_HIGH ----- | | OLD IIC SENSOR - OUT5_IIC_LOW ----- | | | OUT5_BALANCE_HIGH ----- | | OPEN - OUT5_BALANCE_LOW ----- | OUT5_DUMB_HIGH ----- | | (390K 2250mV) | | (180K 2000mV) | | NEW DUMB OUTPUT (120K 1750mV) | | (68K 1500mV) | | (47K 1250mV OUT5_DUMB_LOW ----- | | NEW INTELIGENT (33K 1050mV) | ----- | OUT5_LIGHT_HIGH ----- | | OLD LIGHT SENSOR - OUT5_LIGHT_LOW ----- | | NEW TACHO MOTOR (12K7 = 506mV) - | MINI TACHO MOTOR ( 6K8 = 299mV) - | LARGE TACHO MOTOR ( 3K3 = 155mV) - OUT5_NEAR_GND ----- ----- | EV3 DUMB INPUT DEVICE 0.0V ---------------------------------------------------------------------
IMPLEMENTED DETECTION RULES (sequence matters): I. 1. Value5Float is between OUT5_BALANCE_LOW and OUT5_BALANCE_HIGH and Connection 6 is low -> ERROR (NXT TOUCH SENSOR, NXT SOUND SENSOR, EV3 UART DEVICE) 2. Value5Float is lower than OUT5_NEAR_GND -> ERROR (EV3 DUMP INPUT DEVICE) 3. Value5Float is between OUT5_LIGHT_LOW and OUT5_LIGHT_HIGH -> ERROR (NXT IIC SENSOR) 4. Value5Float is between OUT5_IIC_LOW and OUT5_IIC_HIGH -> ERROR (NXT TEMP SENSOR) 5. Value5Float is lower than OUT5_BALANCE_LOW Value5Float is higher than OUT5_MINITACHO_HIGH2 -> NEW TACHO Value5Float is higher than OUT5_MINITACHO_LOW2 -> MINI TACHO (NEW MINI TACHO MOTOR) else -> TACHO MOTOR 6. Set connection 5 low and measure new Value5Low 7. VALUE5Low is lower than OUT5_MINITACHO_LOW1 -> NEW TACHO (NEW MINI TACHO MOTOR) VALUE5Low is lower than OUT5_MINITACHO_HIGH1 -> MINI TACHO (NEW MINI TACHO MOTOR) else -> TACHO MOTOR
EV3 TACHO OUTPUT DEVICE ID's: 3K3 155mV LARGE TACHO MOTOR 6K8 299mV MEDIUM TACHO MOTOR 12K7 506mV RESERVED for LEGO EV3 TACHO MOTOR
EV3 DUMB OUTPUT DEVICE ID's: 33K 1000mV +-100 Intelligent output device 47K 1250mV +-100 O-#01 - RESERVED for LEGO EV3 output device 68K 1500mV +-100 O-#02 - RESERVED for LEGO EV3 output device 120K 1750mV +-100 O-#03 - RESERVED for LEGO EV3 output device 180K 2000mV +-100 O-#04 - RESERVED for LEGO EV3 output device 390K 2250mV +-100 Third party output device
\n