Skip to content

10. Input devices

Group assignment:

Probe an input device(s)’s analog levels and digital signals (As a minimum, you should demonstrate the use of a multimeter and an oscilloscope.) Document your work on the group work page and reflect on your individual page what you learned

Research

This week’s group assignment was to investigate the analog and digital differences of input devices using an oscilloscope and a multimeter.

input

1. Analog Input

First, we measured a variable resistor as an analog input. We prepared a 10-ohm B-curve pod type and a slider type. We soldered the wires to connect them and connected them to the evaluation board created by Daisuke in Week 8 to confirm their operation.

The microcontroller used was the Xiao RP2040, programmed with the following code.

const int VOL_PIN = 26;

void setup(){
    Serial.begin( 115200 );
}

void loop(){
    int value;
    float volt;

    value = analogRead( VOL_PIN );

    volt = value * 3.3 / 1023.0;

    Serial.print( "Value: " );
    Serial.print( value );
    Serial.print( "  Volt: " );
    Serial.println( volt );


    delay( 100 );
}

This code uses the AD converter function of port 26 (pin 0 of the Xiao) as the input. During verification, data processing was performed using 8 bits divided into 1024 steps from 0 to 3.3V. However, later investigation revealed that when a voltage value of 0 to 3.3V is input, it can be read as a 16-bit integer value from 0 to 65535 corresponding to the voltage value. Although the value range is 16 bits, it was found that internally it operates with a 12-bit (4096 steps) resolution (range).

Furthermore, to convert it to a voltage value, you can use the formula 3.3V/1024bit* (analog in numerical value) to obtain the current voltage applied to the terminal.

Important note: Do not apply a voltage higher than 3.3V to the microcontroller! If you need to measure it, use a voltage divider to reduce it to 3.3V or less.

input

We were able to confirm that the voltage displayed on the oscilloscope and the voltage calculated by the program were almost identical when measuring the pod-type variable resistor. oscilloscopeV programV

However, the slide potentiometer exhibited an odd behavior where the voltage would rise all the way up to 3.3V midway through its operation. sliderNG

Using a multimeter to check the resistance revealed that the fixed 10kΩ terminal (terminal 3) and the slider terminal (terminal 2) were swapped.

connectmissingslider

When correctly connected, the oscilloscope showed normal values ​​when moving the potentiometer from 0 to maximum. sliderOK

2. Digital Input

We investigated the switch input as a digital 0/1 signal. While a microcontroller’s digital input only outputs 0 (LOW) and 1 (HIGH), an analog input allows us to observe the uncorrected values ​​of the moment of ON/OFF chatter. (Depending on the sampling period, even minute ON/OFF fluctuations due to tens of milliseconds can be observed.) Initially, we used the switch in the circuit designed by Daisuke.

notworkswich

However, upon examining the waveform, we realized that the design intended to use INPUT PULLUP, meaning the waveform represented a state without a physical pull-up circuit.

pulldownswich

Therefore, we assembled a temporary switch and pull-down circuit on a breadboard and performed testing.

pulldownswichosilo

Regarding Chatter

Programmatically, this could involve waiting approximately 20ms after the switch turns ON, re-checking the state, and only confirming the input if stable, or increasing the reading interval to avoid reading the chattered state.

Electronically, this could involve smoothing the signal with capacitors (integrating circuits, low-pass/high-cut filters), or using R-S flip-flops or Schmitt trigger circuits to input only specific signals.