Hello, friends.
Today I will tell you how to read analog data using Visa.
In this case I just use Arduino board and one potentiometer as you see in the hardware portion over
here.
This is my potentiometer.
I just connect its one end with the five volt or you can say VCC, another end is with, it is connected
to the ground and middle one.
Or you can say wiper is connected to the A zero pin.
So over here I just open Arduino code
for this
particular case.
In this case, one minute it will take some time
over here, this is my Arduino IDE and this Arduino IDE.
I just set a variable,
as you see over here.
This is the code I already write.
I just use this variable name initially, then void setup.
In this case, you have to pinmode.
I'm using a zero and it is my input pin in the Arduino board.
Every value analog value, it is converted into digital value because ADC is present over every pin.
Okay.
So in the Arduino we have total A0 to a5 total six analog pins are there right now I'm using A0 and
over here this is my variable.
I just read analog read.
The pin number is zero serial print line.
And over here this is my variable.
I just put a delay of 50.
You can also check in the serial monitor.
I just run it.
Let's check what value is there over here?
This is the value.
Seven, seven, five.
In the case of when five volt is there, it will print 1024 and when zero volt is there, it will print
zero.
Okay, so this is the code I just upload inside the Arduino board
right now.
As you see, uploading is completed.
I just close this Pi.
Now just go to the lab view over here.
Just go to the instrument input output or here in the serial, I just configure portfast, create control
over here.
Then in this also you need to set the baud rate.
Then you just go to the input output.
Over here you just select bytes at serial port Connect resource to resource error into error out.
After this I just need to still not read.
I just read VSA read.
Okay.
So over here I just I have read visa
connect error into error out bytes at port to this bytes count.
Okay.
So over here I got the data create indicator for this.
It will show me the data.
Now I just close this also.
So close this.
I just connect simple error handler.
Now I just go for continuous reading.
Create control over here.
Over here.
I got the data.
Okay, so this will show me the data.
And over here I have to set the visa resource and this is my stop button.
So now I just hit on run button.
Let's check what happened before this.
You need to set the visa resource also.
As you see over here, it is asking me the com port eight is my source.
When I hit on run button,
I just need to stop it again.
Hit on run button.
So in this case I just reset it, run it again.
My com port is shared right now as you see.
Stop this one.
In this case I just remove my USB again.
Connect it.
Let's check it is shared or not.
Again hit on run button.
Let's check data.
Is there or not?
The data is not visible to us because delay.
I should put some delay also inside this.
So I just put 50.
50 milliseconds delay right now, as you see.
808 is present over here.
And when I move it right now, it is changing.
Right now it is 3 to 6.
So if you want to just maximize it.
Just go over here size, as you see over here, you just got the size.
And if you want some interactive display over here, in this case, I just use the gauge.
And the range of this gauge is 1024.
I just connect this gauge to over here before this because over here data is in string form.
I need to convert this.
I just go to string conversion fractional.
But exponential strain to number.
This is fractional string.
I just connect this number over here.
Right now, when I just hit on the button, as you see over here, I just got the data.
And when I move this, it is changing.
And right now it is maximum.
Okay.
And right now I just change it.
So this is how you can read analog data using visa resource.
This is the code.
This is all about today's lecture.
Thank you.