Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Exercises 2: C programming | ||||||||
Line: 34 to 34 | ||||||||
Generate 100 values for the sin(x) argument x running from 0 to 2π and write them to a file called sine.dat. | ||||||||
Changed: | ||||||||
< < | Read sine.dat with LibreOffice and generate a plot. | |||||||
> > | Read sine.dat with LibreOffice and generate a plot. | |||||||
Generate a plot with gnuplot. |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
Exercises 2: C programming Goal:We will program most of our sensor readout programs in the C programming language and programming a few simple C programs will help us with future exercises. As soon as programs become a bit more complex it becomes important to describe how the program must be built. This description is usually done in Makefiles in such a way that the simple command make will reconstruct the entire program compiling just the code that has been modified and linking the right files and libraries needed be the program.Exercise 1: Hello World!The first program to be written in C is traditionally the “Hello World!” program. We don’t want to change this tradition and you are therefore asked to write the program that prints “Hello World!”.First compile it with the gcc command, then write a Makefile to build the program using the make command. Exercise 2: A calculatorWe want to produce a calculator program capable of calculating the 4 basic calculations:
Exercise 3: Calculate a sine functionOne of the devices we will use during the sensor exercises is a digital to analogue converter (DAC), allowing us to generate an arbitrary wave form. This is a 12 bit device and we want to generate a sine wave for it. In order to do this, calculate the values to be sent to the DAC in such a way, that the min/max values of the sine wave are adapted to the 12 bits of the DAC. Generate 100 values for the sin(x) argument x running from 0 to 2π and write them to a file called sine.dat. Read sine.dat with LibreOffice and generate a plot. Generate a plot with gnuplot. --![]() Comments |