analog to digital signal/Using it/11. When the output is wrong
Using it · 11 of 11

When the output is wrong

Most wrong answers from the TK29 come from six places: an empty IN socket, the switch at the other letter, a knob out of range, the LED read the wrong way round, chatter at the threshold, or DIG and ANA swapped on the header. Each one has a look of its own.

Six symptoms

When the output is wrong
What you see
The threshold is outside what the input ever reaches: turned to one end, or above 1.8 V from 3V3, the top of the comparator's range, which is the top 45 % of the knob. Put the input where you want it to switch and turn slowly until the LED changes.

Each symptom above rings the part to check. In order of how often they happen:

Random. Nothing in IN. The comparator's input is connected to nothing and follows a hand, a draught, the mains hum in the room. DIG wanders and ANA drifts. Push an analog block fully into the socket.

Backwards. HIGH where you expected LOW, consistently. The switch is at the other letter: H and L.

Never changes. The knob is beyond anything the input reaches, or above the comparator's range, about 1.8 V from 3V3. Setting the threshold finds where it is.

Flickers. The input is at the threshold and wobbling. There is no hysteresis on the board; chatter and hysteresis adds it in the sketch.

Two that are wiring

The LED disagrees with the sketch. The LED lights while DIG is LOW. A lit LED with a sketch printing 0 is right. A lit LED with a sketch printing 1 means the sketch is not reading DIG: the wrong pin, or a wire one position over.

ANA reads only near 0 or near full scale. It is on DIG. The two sit side by side at the right-hand end of OUT, DIG third from the square pad and ANA fourth. Swap them, or swap the pin numbers in the sketch.

When all else fails

Take the board away from your microcontroller. Power it alone from VCC and GND, put a TK08 in IN, and turn the TK08 slowly from one end to the other. The red LED should change once, at the knob. If it does, the TK29 is fine and the problem is in the wires or the sketch. If it never does, turn the knob to the middle of its lower half and try again.

When it does not work

Nothing at all: DIG reads 1 and the LED is dark.

DIG is pulled up to VCC and nothing is pulling it down, which is also what an unpowered comparator looks like. Check VCC and GND first: the block in IN takes its power from the same two pins, so ANA reading 0 as well points there.

It works on the Uno and not on my ESP32.

On the ESP32, ANA has to be on an ADC1 pin: GPIO 34 in this book, not an ADC2 pin, which stops reading when Wi-Fi is on. VCC has to move to 3V3. And from 3V3 the comparator's range ends at about 1.8 V, so a knob set high for the Uno's 5V may now be out of range.

It worked, then stopped when I moved the board.

The slider was knocked to the middle of its travel, or the block worked loose in the IN socket. Push the slider firmly to H or L, and push the block fully home.

Where this goes next

Every TinkerBlock, and the analog ones that plug into this one's socket.

Back to the blocks

Edit this page — content/books/analog-to-digital-signal/when-the-output-is-wrong.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Analog to Digital Signal

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum