DIY Electronics

Simple electronics as a hobby

Linear feedback shift register

A linear-feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. Applications of LFSRs include generating pseudo-random numbers, pseudo-noise sequences, fast digital counters, and whitening sequences. Both hardware and software implementations of LFSRs are common. The initial value of the LFSR is called the seed, and because the operation of the register is deterministic, the stream of values produced by the register is completely determined by its current (or previous) state. Likewise, because the register has a finite number of possible states, it must eventually enter a repeating cycle. However, an LFSR with a well-chosen feedback function can produce a sequence of bits that appears random and has a very long cycle (source: wikipedia).
This 40-bit LFSR is based on a project done by Julian Ilett on his youtube channel ( video ). The difference is that I used a pic microcontroller as clock source that gives two pulses with a tiny delay for the shift reg clock (pin 11) and the storage reg clock (pin 12). If you tie both clock registers together then output pin Q0 becomes tab 2 instead of tab 1 (tabs are used to indicate the XOR inputs).

In a 40-bit LFSR the maximum-length counters is 2^40 - 1 (-1 because all zeros are not allowed). Tabs are placed at positions 40, 38, 21 and 19 (source: AMD).

>>> Pic 16F684 code <<<
>>> linear feedback register in C <<<


Random flasher number generator

The self flashing LEDs blink with an approximate frequency of 1.5 Hz. When an LED is turned on the voltage on the cathode side is about 2.12 volt. That voltage is used as one of the two inputs to a comparator (324n op-amp). The second input comes from a voltage divider using 8.3K as R1 and 3.8K as R2 resulting in a voltage output of 1.6 volts. The op-amp comparator gives a high or a low as output to the Pic microcontroller 8-pins of PORTC. The MCU displays the 8 bit number on the OLED and delays for 1800ms to make it slow enough to read.

>>> pic16f690 code <<<


Raspberry Pi LCD 20x4 - RSS feed

Install Raspberry PI Debian Bullseye 32-bit (lite) using Raspberry Pi Imager v1.8.5. The advanced options let you set wifi, ssh, hostname, timezone and such. Added the following to sshd_config:
UsePAM no
UseDNS no
PermitRootLogin yes

Run commands
apt-get update
apt-get upgrade
mv /etc/motd /etc/motd.sav

raspi-config
boot to command login
expand filesystem
Install wiringPi
# fetch the source
apt install git
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build debian
mv debian-template/wiringpi-3.0-1.deb .
apt install ./wiringpi-3.0-1.deb

>>> The New York Times RSS feed of World news <<<
>>> Air quality data from aqicn.org <<<
Top