measure impulsive voltage sensor.

Hello everyone!

I encounter a problem when I use Arduino to measure impulsive voltage combine with Matlab.

The following is my code of hardware in Arduino, it can successfully run. Please see the attached file-"sketch_dec22b"

int analogPin = 5;
int val = 0;

void setup()
{
//Serial.begin(115200);
Serial.begin(9600);
}

void loop()
{

val = analogRead(analogPin);
Serial.println(val);//将传感器读取到温度值通过串口发送给LabVIEW
delay(20);
}

The following is my Matlab program (GUI, Please see the attached file-"New sample GUI") which is also can run, but the output figure can not correctly demonstrate the voltage variance. Please see the attached figure, named' GUIshow when the Matlab program is runing'.__

function varargout = light_degree_sensor3(varargin)
% LIGHT_DEGREE_SENSOR3 MATLAB code for light_degree_sensor3.fig
% LIGHT_DEGREE_SENSOR3, by itself, creates a new LIGHT_DEGREE_SENSOR3 or raises the existing
% singleton*.
%
% H = LIGHT_DEGREE_SENSOR3 returns the handle to a new LIGHT_DEGREE_SENSOR3 or the handle to
% the existing singleton*.
%
% LIGHT_DEGREE_SENSOR3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LIGHT_DEGREE_SENSOR3.M with the given input arguments.
%
% LIGHT_DEGREE_SENSOR3('Property','Value',...) creates a new LIGHT_DEGREE_SENSOR3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before light_degree_sensor3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to light_degree_sensor3_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help light_degree_sensor3

% Last Modified by GUIDE v2.5 22-Dec-2020 21:26:21

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @light_degree_sensor3_OpeningFcn, ...
'gui_OutputFcn', @light_degree_sensor3_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before light_degree_sensor3 is made visible.
function light_degree_sensor3_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to light_degree_sensor3 (see VARARGIN)

% Choose default command line output for light_degree_sensor3
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes light_degree_sensor3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = light_degree_sensor3_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global mycom;
myComPort = serial('COM3');
fopen(myComPort);
% now disconnect the device
delete(myComPort)
clear myComPort
% now connect the device again, the following will now be successful:
% myComPort = serial('COM3');
% fopen(myComPort);
% instrfind
s = serial('COM3'); %定义串口对象
set(s,'BaudRate',9600); %设置波特率s9600
% set(s,'BaudRate',115200);%设置波特率s115200是没有问题的
fopen(s); %打开串口对象s
mycom=s;
%% 把这些值传给下一个
handles.mycom=mycom;%传值出去
guidata(hObject,handles);%这一句必须加上
% fclose(mycom);%退出程序前,串口一定要关闭,否则端口占用,必须重新启动计算机
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
%%取出传值数据
mycom=handles.mycom;%%取出传值数据

fclose(mycom);%退出程序前,串口一定要关闭,否则端口占用,必须重新启动计算机

% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
mycom=handles.mycom;%%取出传值数据
interval = 5000; %这里开始的代码很Part1里的代码类似
passo = 1;
t = 1;
x = 0;
while(t<interval)
b = str2num(fgetl(mycom)); %用函数fget(s)从缓冲区读取串口数据,当出现终止符(换行符)停止。
x = [x,b]; %所以在Arduino程序里要使用Serial.println()
plot(x);
grid
t = t+passo;
drawnow;
end
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

sketch_dec22b.ino (302 Bytes)

New_sample_GUI.zip (25.1 KB)

You need to at least post the code correctly using code tabs .

The Arduino part is very simple , but there will be slight delays involved in the “ print” if that’s the issue ??

What is the circuit ?

You might be better off posting in a matlab forum if you suspect that is where your problem resides

Hi, thank you for your answer.
If I do not delay(20), there will be a kind of peak in the signal. I have used the same program of Arduino to connect a light degree sensor. With out delay(20), the signal is like the following figure 1. There are many periodical peak.

Then with the delay(20), the periodical peaks will disappear. You can see the following figure 2.

From the above figure, it can show the change of light degree.

It should be known that the light sensor is a commercial product.
Then, I want to use the same program to measure the voltage. The voltage produced from a triboelectric nanogenerator(TENG). The following is the circuit figure 3.

When running the Matlab program, the sense of figure1 appears again when the Arduino is used to measure the voltage, Which is shown in figure 4.

So that my problem.

Thank you so much for your help.

From the graph it looks like the input voltage is saturating the A/D.
Also your input voltage is not a steady DC signal - the A/D takes an instantaneous value and so you will see a changing signal in your readings .

The last graph is that: the first 3000 points, I do nothing. 3000-5000, I operate the TENG. It can produce a voltage between 0-10V approximately. Please see figure 5.

I do not know why I do nothing, the periodical peaks appear again. And when I operate the TENG., the voltage is also weird. The normal graph looks like the following figure. Please see figure 6.

figure 6.png

figure 6.png

What is this "TENG" and what is the voltage (profile) you expect to come out of it?

If the maximum "impulsive voltage" (whatever that may be) is 10V, with your resistor divider you should get no more than 0.4V on the ADC pin. Assuming Vcc = 5V that means a reading of up to about 82, not taking the voltage drop over the bridge rectifier into account, which would bring it down to about 65.

The graph you posted gives peaks every ~2 seconds (based on the 20 ms delay between pulses) at a reading of 150-180 or so, suggesting a way higher input voltage.

The last image you post suggest voltages of 150-200V. No idea what that has to do with this 10-volt TENG. Applying THAT voltage to your 47k/2k voltage divider WILL max out the ADC, as you're getting over 8V on the A5 input (well, you would if the clamping diodes weren't there limiting it to Vcc+0.5V and protecting your board from damage due to overvoltage).

So... long story short, the information you given so far is inconsistent, and appears incomplete and self-contradictory. Not knowing what you're actually trying to do I can't tell what is really going on.

Sorry to make you confused. TENG stands for triboelectric nanogenerator.

"The last image you post suggest voltages of 150-200V." The last image is just a demo to show what the normal signal should look like.

In this case, the voltage produced by my TENG is around 0-10V.

As the Arduino can only measure the voltage between 0-5v, So I use a resistor divider to reduced the voltage produced by TENG

If the voltage you want to monitor is 0-10V, why is there even a bridge rectifier? The best thing it will do is seriously mess with the voltage you try to read (including blocking it completely when it drops below ~1.4V).

Still the question: why are you using a 47k/2k voltage divider?

What is the output impedance (or internal resistance) of your TENG device? The wikipedia page lists a few such things and gives load resistance values of 100M-500M. There is no chance of reading such a signal with a 50k load as you're trying to do.

Hi, thank u for your continuous attention.

the bridge rectifier is used for transfer AC to DC.

"why are you using a 47k/2k voltage divider?"

That is because of security reasons in the case the voltage is too high to break the Arduino.

"What is the output impedance (or internal resistance) of your TENG device?"

The output impedances is 47k+2k=49k, in this case. Yes the internal resistance is very high, almost 100M-500M, that is the reason why the output current is so much, normally at a level of uA. But the output voltage is usually high. In my case the highest voltage is around 10V.

I am very confused about the figure 6. you can see the very werid periodical peak of the output curve at the first part, I do nothing about TENG, just connect it to the Arduino. But When I operate (normally contact and seperate ) the curve become large periodical component is still mixed in the firgure.

How can I remove the periodical peak?

I want to remove the periodical peak, so that the curve can reflect the voltage change, which is what I want.

Thank you

TENG normally produced AC voltage. With the bridge rectifier, it can transfer the AC voltage to DC.

There is some basic knowledge about vertical contact-separation modal TENG, which is what I fabricate. please check it.

The following is a professional explanation. In my words, it can be simplified as: two materials with different polarity can produce voltage when they contact and separate.

The operating principle of TENGs with vertical contact-separation mode can be
described by the coupling of contact electrification and electrostatic induction [1]
Respectively, Fig. 2.1a, b depict electric output of open-circuit voltage (VOC) and
short-circuit current (ISC). At original state, no charge is generated or inducted, with
no electric potential difference between the two electrodes (Fig. 2.1a-I). With an
externally introduced displacement, the two polymers are brought into contact with
each other. Surface charge transfer then takes place at the contact area due to
triboelectric effect [9–11]. According to the triboelectric series [12] that is a list of
materials based their tendency to gain or lose charges, electrons are injected from
polymethyl methacrylate (PMMA) into Kapton, resulting in net negative charges at
the Kapton surface and net positive charges at the PMMA surface, respectively. It is
worth noting that the insulating property of the polymers allows a long-time
retention of triboelectric charges for hours or even days [13]. Since they are only
confined on the surface, charges with opposite signs coincide at almost the same
plane, generating practical no electric potential difference between the two electrodes (Fig. 2.1a-II).
As the generator starts to be released, the Kapton film intends to revert back to its
original position due to its own resilience. Once the two polymers separate, a
potential difference is then established between the two electrodes under the open
circuit condition since the opposite triboelectric charges are separated
(Fig. 2.1a-III). As the generator is being released, VOC keeps increasing until
reaching the maximum value when the Kapton film fully reverts to the original

position (Fig. 2.1a-IV, V). Such a signal will remain constant provided that the

input impedance of the electrometer is infinitely large. If pressing is immediately

followed, the potential difference starts diminishing as the two polymer layers get

closer to each other. As a result, VOC drops from the maximum value to zero when a

full contact is made again between the two polymers (Fig. 2.1a-V, VI).

If the two electrodes are shorted, any established potential difference as the two

polymers separate drives electrons from the top electrode to the bottom electrode

(Fig. 2.1b-III), resulting in an instantaneous positive current during the releasing

process (Fig. 2.1b-IV). Once the generator is pressed again, reduction of the

interlayer distance would make the top electrode possess a higher electric potential

than the bottom electrode. As a consequence, electrons are driven from the bottom

electrode back to the top electrode, reducing the amount of induced charges

(Fig. 2.1b-VI). This process corresponds to an instantaneous negative current

(Fig. 2.1b-V). When the two polymers are in contact again, all induced charges are

neutralized (Fig. 2.1b-II).

qingdaisky:
"What is the output impedance (or internal resistance) of your TENG device?"

The output impedances is 47k+2k=49k, in this case. Yes the internal resistance is very high, almost 100M-500M, that is the reason why the output current is so much, normally at a level of uA. But the output voltage is usually high. In my case the highest voltage is around 10V.
[/quote]

You have to learn the basics of electricity for starters.

If your output current is in the order of µA, your resistors will give voltages in the low mV range on the Arduino input. Nowhere close to that 10V you are hoping for. That's just Ohm's law.

Then, you need to learn some more advanced electronics.

Your voltage divider is the load, the output impedance of the TENG is equivalent to its internal resistance. A 100-500M output needs a transimpedance amplifier.

You have a signal of a few µA; your very low resistor values mean the voltage is very very low, and all the stray capacitance in your circuit (the detection cap of your Arduino's ADC is a biggie at this kind of currents) will deal with that easily. You can expect to see NO reading whatsoever from your TENG.

When designing your amplifier, as your TENG's output voltage can be negative, you should add an offset voltage so the output is always positive.

How can I remove the periodical peak?

Figure out what is the CAUSE of that peak, and deal with it.

My best guess is that it is some kind of external interference. It can be anything. Lift doors closing, a clock ticking - really, can be anything. Look carefully at the signal: how does it look? Is it regular? Irregular? What is the frequency? The latter is a very important clue as to what could be causing it.

Thank you so much for your answer, it is really helpful.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.