0:16
everyone welcome to controllers tech
0:20
this is another video in next in series
0:23
and today we will see
0:24
how to use waveforms on this display
0:28
i will be using my stm32 for sending the
0:31
sine wave and the square waves of
0:33
different frequencies
0:35
let's start by creating a new project in
0:44
give some name to the project here
0:48
select your display type and the display
0:50
orientation that you want to work with
0:54
i am going to add a waveform here
0:57
resize it to fit the whole display
1:12
you can change the grid width and height
1:20
i will change it back to 40 that fits my
1:27
you can select how many channels you
1:33
i will use two channels to show the
1:35
difference between the two
1:43
let's debug this once
1:50
i will send the waveform to this display
1:56
that's how it's going to look
2:01
each grid here represents 40 and that's
2:04
why the lowest point is 40
2:06
as i have used it as the minimum value
2:14
let's upload it to the board
2:21
here i am using aftdi module to upload
2:26
the blue wire is connected between the
2:28
display tx to the module rx
2:30
and the yellow is between the display rx
2:36
red is 5 volts and black is ground
2:40
let's upload the code now
2:44
it's uploaded and the editor part is
2:52
let's open the cube id and create a new
3:15
i am selecting external crystal for the
3:19
i am using uart4 to send data to the
3:25
change the board rate to 9600
3:33
in the clock setup i have external eight
3:37
and i want the system to run at maximum
3:43
click save to generate the project
3:50
so here is our main file
3:56
i am adding these end commands that we
3:58
need to send to the display
4:00
after we are done with sending data
4:03
now we need to send the values to the
4:06
in order to generate the wave let's
4:10
check the instructions for the next ian
4:20
here we can use add function to send the
4:22
values to the waveform
4:25
data ranges from 0 to 255.
4:33
here is an example to send data
4:43
i have created a function to send the
4:45
sine wave to this display
4:48
don't worry i will explain this but
4:50
first let's define the object name here
4:56
this is the object name for the waveform
5:07
here this function takes the parameters
5:11
which you can see here is 1.
5:17
then the channel number to which you
5:19
want to send the data to
5:21
the amplitude of the sine wave the
5:25
the y shift and the grid height which in
5:39
i have defined the number of samples as
5:43
you can change them according to your
5:47
i will explain this part later let's
5:50
come to the main part here
5:52
i am using the sine function to get the
5:58
and this 127 is to keep the mean
6:01
position of the wave in the middle of
6:07
as we saw the values ranges here from 0
6:11
so that's why i am using 127 to bring
6:15
the wave to the middle
6:17
basically 127 will be added in each
6:22
and therefore we will get the wave in
6:24
the middle of the display
6:27
also the y shift will be added further
6:34
now we send the add command with id
6:37
number channel number
6:45
and in the end send the end command
6:57
let's include the math.h for sine
7:00
and stdio for the s printf
7:23
call the function in the while loop
7:26
i have id number 1 channel 0 amplitude 1
7:31
frequency 1 no y shift and the grid
7:37
let's build and flash this
7:53
you can see the sine wave in the middle
7:57
this is because i haven't provided any y
8:02
also the amplitude is 1. let's make some
8:07
i will first change the amplitude to 2.
8:25
you can see the wave with amplitude of
8:29
let's increase frequency also
8:40
this is working as expected
8:47
i will change everything back to 1 and
8:50
experiment with the shift in the y-axis
9:37
that small portion is cut from the
9:40
anyway this is working just fine
9:47
now coming to this grid calibration here
9:51
first we get the value of the grid width
9:53
which in my case is 40
9:55
but this function will get that value
10:12
and then we get the value for the grid
10:16
in this case this value here will be
10:20
now i have replaced the number of
10:23
samples with the width
10:25
and the rest of the functions are same
10:33
to use this part we must define this in
10:42
now you see this part is grayed out
10:46
let's build and flash
10:58
you can see one oscillation of sine wave
11:01
is equal to one width of the grid i will
11:16
and now you can see it perfectly we can
11:20
change the amplitude and the frequency
11:52
that's all about the sine wave i also
11:56
want to include the square wave here
12:03
this is exactly the same function as the
12:07
except for this line here this will
12:10
basically limit the values to either
12:13
or low no intermediate values
12:21
let's call the square wave function also
12:30
before that i will disable the grid
12:34
you can use this also i just want to use
12:42
again id number is one i want to use
12:45
another channel for this
12:46
and rest of the things are kept to
12:55
this channel should be one as the first
13:00
let's build and flash
13:14
you can see the square wave and the sine
13:17
wave of same frequencies
13:20
let's try to move the square wave a
13:22
little up on the display
13:26
i will change the y shift to 2 here
13:49
and we got the perfect result obviously
13:53
one function is executing at a time and
13:55
that's why the waves are shifting one at
13:59
if you want both of them to shift
14:01
simultaneously then send both the values
14:05
and the square wave at the same time
14:08
i will leave the code in the description
14:12
this is it for this video in the next
14:16
of the next ian series i will cover the
14:20
you can download the code from the link
14:24
keep watching be safe and have a nice