Posts

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 build command and modify lines there to look like below:  Com

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 must to achieve communi

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

matplotlib and Raspberry Pi 3 - show my 'Hello world!'

Image
17 April 2018 Here it is: I have tried to do simple plot using matplotlib on freshly installed Raspbian (jessy). Way to accomplish this seemingly easy task is quite bumpy thou. This post serves to document the steps i have done to see the plot first time. 1. grab a Raspberry Pi and all peripherals 2. If you have an NOOBS SD card, install Raspbian, if not, visit  https://www.raspberrypi.org/downloads/noobs/  and  download NOOBS, follow the installation procedure. 3. Raspbian installed? Great. This is Linux named Debian, to quickly check what you have installed open terminal and type lsb_release -a  As answer you obtain something like: Distributor ID: Raspbian Description:     Raspbian GNU/Linux9.4 (stretch) Release:           9.4 Codename:      stretch Start from typing a command: sudo apt-get update Check the python version you have by typing in terminal  python or  python3 first line appearing after this command tells about installed version(s) of python. N

Rule the pins of Raspberry Pi 3

Image
To easily drive the pins of RPi use library named bcm2835. It will work with Raspberry Pi 3 despite the fact this model uses BCM2837 chip. Visit  http://www.airspayce.com/mikem/bcm2835/ Check the latest version of bcm2835 library. Open terminal and do what is below. wget command will fetch the choosen version of the library, say bcm2835-1.55.tar.gz and the others commands will unpack it and install: wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.xx.tar.gz tar zxvf bcm2835-1.xx.tar.gz cd bcm2835-1.xx ./configure make sudo make check sudo make install It is time to test the library now. Using Geany (should be installed by default) go to File -> New and place the code which could be find on http://www.airspayce.com/mikem/bcm2835/blink_8c-example.html The below example has some modification to work with RPi3: instead of original #define PIN RPI_GPIO_P1_11 there is #define PIN RPI_BPLUS_GPIO_J8_11 what is a correct PIN definition when using RPi 3. To check how correc