Posts

FPGA in VHDL - 7-segment display

Image
 There is an idea to drive 7-segment display with FPGA Let's start with the hardware. The construction of the display is quite simple. For one display we have 7 + 1 diodes. One LED for each segment of 'figure 8' plus one for display point. See this: Then, the 'inside' schematic is as below. Presenting here only one (of two) option(s), named common anode, as this is what is built in Nexys Digital Systems Builder board. Also, the PNP transistor and resistor is not a part of the 7-segment display. It is here for explaining logic of driving with development board. Schematic of 7-segment display with CA (common anode) arrangement as in Nexys FPGA board From this schematic you can fetch some important information. To activate a single segment, let's say A, we need to do two things: 1. Drive the anode. As this arrangement is with PNP transistor, the anode is 'activated' by providing LOW state to AnodeDrive. This makes a possibility for the current to flow thro...

Code FPGA: AND gate in VHDL

Image
 AND gate in VHDL This is a code used in FPGA program to represent AND gate. The .vhd file is a main file, telling what the programmer wants to achieve. In below example we want to use two switches as user inputs. User can set each of switch to be set to '0' (low state) or '1' (high state). Result of the AND operation will be shown on LED, where '1' equals to diode lighting, '0' diode stays inactive or dark. In my case the program is edited and synthesised in software named ISE 14.7 It is a free software available from XILINX and possible to run on Windows 10 with Virtual machine (from ORACLE). I hadn't had a succesful installation on Win 11.  Note: Maybe it can work with simultaneous linux installation (Win 11 + Linux). In this case ISE would be installed on Linux. I didn't try this. Hardware: I have an old Nexyx - Digital Systems Builder board, where I tested my programs.  I used small software named Adept from DIGILENT, where I can recognise ...

ADS129x and bcm2835 library and Raspberry Pi 4

This time I would use the same library as previously ( bcm2835 ) and Raspberry Pi 4 with Raspbian GNU/Linux 11 (bullseye).  Wiring is kept the same as for RPi3 (pin compatibility between Pi3 and Pi4, hurra!).   System preparation After system being installed and updated and upgraded I installed bcm2835 library.  To do so, in terminal type: cd ~  wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz  tar xvfz bcm2835-1.71.tar.gz  cd bcm2835-1.71  ./configure make  After some time all things were installed.  Now, it is fine to use scripts from RPi3, anyway to do so they have to be re-compiled and re-built.  Easy, run Geany, open source codes, compile, build, etc...  Do not forget: when compiling and building project consisting of many files, those of .c extensions have to be re-compiled too. Ok, you probably realised now, that it would be easier if we setup Geany.  Geany setup Start Geany, go to menu Build -> Set bu...

Data collection from ADS1298

To collect data from ADS1298 the previous setup will be used. Data will be formatted. What is received from ADS1298: 3 bytes status + 8 groups of 3 bytes (for each channel). Because value of each channel is 24-bit it will be manipulated to fit into 32-bit integer value. Again, you need CLK and SCLK clock (both) to establish communication between RPi and ADS1298. For plotting purposes first column of data will contain time stamps. /* * Code to perform communication with ADS1298 * * ads1_1 - basic communication established. ADS gives an answer to Raspberry Pi B through SPI bus. * ads1.3 - read device signature, reset introduced, basic initial settings, generating test signal and printf of one channel and one value * ads1.4 - preparation for pipeing to continously give one channel value out * * ads2.0 - seperated files, 'manual' control for /CS chip * ads2.1 - output now: saving to file (to allow use with kst2 - fast plotting program) * ads2.2 - time stamps * ...

Hello world with ADS1298

Image
Let's make first simple communication with ADS1298 (delta-sigma ADC). To confirm communication with this ADC, we will ask for its ID.   Hardware To talk to ADS1298 we will use SPI and bcm2835 library. SPI is an intuitive solution here. ADS1298 is capable of 20MHz SPI communication, anyway due to Raspberry Pi problems with SPI speeds higher than 16MHz we will stay on 8MHz (7.8125MHz exactly). To provide this basic communication connectivity we need an SPI (hardware) connections with separately defined /CS signal. This is due to inconsistency in providing spacing between end of CLK and rising end of /CS.  We will use RESET signal as well. Be aware that to establish communication with ADS1298, there is a need of both, simultaneously: CLK (in range freqency  from 1.945 525MHz to 2.415,459MHz) and SCLK (SPI clock: max 20MHz when powered 2.7 V ≤ DVDD ≤ 3.6 V and 15MHz when 1.65 V ≤ DVDD ≤ 2 V). This may be counter intuitive, but from experience: it is a mus...

Syntax highlight test

Trying to use syntax highlight:  c++: #include <iostream> using namespace std; int main() { cout << "Hello, World!"; return 0; } python: import matplotlib k=input() mylist=[] mylist.append(k)

Pipes. Let's start from something simple.

Again, something on Raspberry Pi (Raspbian/Debian), but there is a chance it would be useful for other systems.  I needed to direct a stream of data from c program to python script. To try the easiest way, I did small c program to send some data (string for this example) and another c program (to receive and print) and forced them to co-operate. Below is an explanation of how it is done. C sender to c receiver This is easy and often used form of creating a pipe (yes, we will use pipe to stream data from output of 'sender' to input of 'receiver'). Sender will print something out and receiver will accept this data. We will start from both programs being written in c, and then we will create a script in python to do the job of receiver. 1. pipesender.c #include <stdio.h&gt int main(){   printf("Message from sender\n");   return 0; } 2. pipereceiver.c #include <stdio.h> int main(){   char str1[21]; //buffer long enough for string from se...