Skip to content

Commit c02474f

Browse files
authored
Merge pull request #78 from htfab/main
Analog Toolkit: update docs
2 parents 0e6e734 + 189eb1a commit c02474f

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

docs/user_peripherals/26_analog_toolkit.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Peripheral index: 26
88

99
Allows building low frequency ADCs, DACs, capacitive sensors etc. using passives only
1010

11-
(To be expanded)
12-
1311
## Register map
1412

1513
| Address | Name | Access | Description |
@@ -37,13 +35,42 @@ Build one of the test circuits:
3735
should cover a reasonable range of values, say, 64 to 192
3836

3937
- DAC
40-
- ...
38+
- create an RC low-pass filter from a resistor and
39+
a capacitor attached to `uo_out[1]`
40+
- generate a PWM signal by setting the frequency
41+
using DIV (register 4) and the duty cycle using
42+
OUT0 (register 0)
43+
- the low-pass filter should smooth the PWM output
44+
to a an average voltage corresponding to the
45+
duty cycle
4146

4247
- Capacitive sensor
43-
- ...
48+
- connect the touch pad (or just two wires) to
49+
`ui_in[0]` and `uo_out[1]`
50+
- set DIV (register 4) to 0x60 (~64Hz clock)
51+
- set OUT0 (register 0) to 0x80 (1/2 duty cycle)
52+
- set CH (register 5) to 0 (set input to `ui_in[0]`)
53+
- read IN (register 3) for a value that depends on
54+
the capacitance between `ui_in[0]` and `uo_out[1]`
55+
- tweak DIV (register 4) to make the sensor
56+
more sensitive in the capacitance range you are
57+
interested in
4458

4559
- LED dimmer
46-
- ...
60+
- connect an LED to `uo_out[1]` and ground, using a
61+
series resistor appropriate for the LED voltage
62+
drop and current rating, assuming Vcc of 3.3V
63+
- set DIV (register 4) to 0xa0 (~1kHz clock)
64+
- set OUT0 (register 0) to tweak the PWM duty cycle
65+
- the range 0x00 to 0x7f maps to the duty cycle
66+
in a quasi-exponential way, and the human eye
67+
percieves brightness in a quasi-logarithmic
68+
way, so you should see a smooth ramp in
69+
apparent brightness as you tweak the values
70+
- you can add two more LEDs to `uo_out[2]` and
71+
`uo_out[3]` and set their brightness using
72+
OUT1 (register 1) and OUT2 (register 2)
73+
respectively
4774

4875
## External hardware
4976

0 commit comments

Comments
 (0)