LMS 2012
|
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 NEW UART DEVICE NEW DUMB SENSOR OLD SENSOR TACHO MOTOR NEW DUMP ACTUATOR ---------------------- ---------------------------------- ---------- --------------------- ------------------------ -------------------- ---------------- ----------------- 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 ? Supply Supply 4 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 5 Analogue I + Digital I/O (float) 220K pull down to ground 6 TXD (low) Analogue value ? Tacho B ID resistor to 6 ********************************************************************************************************************************************************************************************************************* ID VALUE ON CONNECTION 1: ADC_REF ----- IN1_NEAR_5V ----- | | | TACHO MOTOR and NEW DUMB ACTUATOR | | IN1_NEAR_PIN2 ----- | | | | | | | | NEW SENSOR ID's | | | | | | | NEW UART SENSOR 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 -> NEW UART DEVICE 3. else (value on connection 1 is ID) -> NEW DUMB DEVICE III. Connection 6 high -> NXT IIC TEMP SENSOR IV. Connection 5 low -> ERROR NEW ID's: The range from 0mV to just beneath the voltage on connection 2 is free to be used for the new sensor ID's - recommendations: I. Use a short circuit to ground to identify the UART device.
\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_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_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_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] #define OUT5_NEAR_GND 100 // [mV] lower values mean that connection 5 is shorted to ground /* OUTPUT ********************************************************************************************************************************************************************************************************************* MICRO CIRCUIT CONNECTION NEW UART DEVICE NEW DUMB SENSOR OLD SENSOR TACHO MOTOR NEW DUMP ACTUATOR ---------------------- ------------------------------- ---------- --------------------- ------------------------ -------------------- ---------------- ----------------- 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 ? Supply Supply 4 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 5 Digital I/O (low) 100K pull up to connection 2 6 TXD (low) Analogue value ? Tacho B ID resistor to 6 ********************************************************************************************************************************************************************************************************************* ID VALUE ON CONNECTION 5: Connection 6 floating Connection 6 low and value on connection 5 changed --------------------------------------------------------------------------------------- -------------------------------------------------- ADC_REF ------------------------------------------------------------------------------------------------- NEAR_5V ----- | | | | | 3.3 - | - - - - - - - - - - - - - - - - - - - - - - | - - - - - - - - - - - - - - - - - - - - - - - - 2014 ADC reference voltage | LARGE TACHO MOTOR - | MINI TACHO MOTOR, NEW DUMB MOTOR - OLD TACHO MOTOR | NEW TACHO MOTOR - OUT5_IIC_HIGH ----- | | OLD IIC SENSOR - OUT5_IIC_LOW ----- | | | OUT5_BALANCE_HIGH ----- | | OPEN - OUT5_BALANCE_LOW ----- | | | ----- | | | | | | | | | NEW ACTUATOR ID's | | | | | | | | ----- OUT5_LIGHT_HIGH ----- | | OLD LIGHT SENSOR - OUT5_LIGHT_LOW ----- | | NEW TACHO MOTOR - | MINI TACHO MOTOR - | LARGE TACHO MOTOR - OUT5_NEAR_GND ----- ----- | NEW DUMB SENSOR 0.0V ------------------------------------------------------------------------------------------------- When something is connected: the value on connection 5 is stored as Value5Float. Connection 6 is driven low and the value on connection 5 is then stored as Value5Low. Connection 6 is set floating again. The two stored values is used to determine the type of the attached device. IMPLEMENTED DETECTION RULES (sequence matters): I. Value5Float is equal to Value5Low 1. Value5Float is between OUT5_BALANCE_LOW and OUT5_BALANCE_HIGH and Connection 6 is low -> ERROR (NXT TOUCH SENSOR, NXT SOUND SENSOR, NEW UART SENSOR) 2. Value5Float is lower than OUT5_NEAR_GND -> ERROR (NEW DUMP SENSOR) 3. Value5Float is between OUT5_LIGHT_LOW and OUT5_LIGHT_HIGH -> ERROR (OLD IIC SENSOR) 4. Value5Float is between OUT5_IIC_LOW and OUT5_IIC_HIGH -> ERROR (OLD 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 II. Value5Float is NOT equal to Value5Low 1. Value5Low is between OUT5_NEAR_GND and OUT5_BALANCE_LOW -> NEW DUMP ACTUATOR (ID is Value5Low) 2. else -> ERROR NEW ID's: The range from 800mV to OUT5_BALANCE_LOW is free to be used for the new sensor ID's - recommendations: I. Use a short circuit between connection 5 and connection 6 to identify the cheapest device II. Remember to reserve one id for the smart actuator (maybe the highest resistance = 500K) III. Remember that the ID resistor must get connection 5 out of balance IV. Remember the voltage on pin 1 when connected to an input port
\n