I’ve been working on a project building a simple I-V Curve Tracer for photovoltaic systems.
I’m using an Arduino Uno R3, and I’ve connected it to my laptop running MATLab to collect data.
I haven’t had any luck with a simple voltage measurement circuit and I’m really clueless as to why it isn’t working correctly, so I was hoping maybe someone here could help me out a little.
My codes are in MATLab, so I’m not sure if I’ll get flamed, I could do it in Arduino as well, but one of my project requirements was to use MATLab to interpret the data, so I thought I’d just run the arduino through MATLab which has an arduino interface.
%% Setup & Initialization
ard = arduino(’/dev/cu.usbmodem1411’,‘uno’); %For Arduino Dev
d_pot = spidev(ard, ‘D10’); %Serial Peripheral Interface Setup
powerLog = zeros(3,256);
% mVperAmp = 185; % use 100 for 20A Module and 66 for 30A Module
% Rab = 10*10000; %Full Resistance
% Rw = 1; % actual wiper resistance
%% Digital Pot Control
for regVal = 0:1:255
% pot_resistance = Rab*regVal/256+Rw;
writeRead(d_pot, [hex2dec(‘11’), regVal], ‘uint8’);
fprintf(‘Pot Bit Value is %d \n’, regVal);
% currentmv = (readVoltage(ard,‘A1’) /1024)*5000;
% current = (currentmv)/66; %mA?
powerLog(1,regVal+1) = readVoltage(ard,‘A0’)*11; % Voltage Reading
powerLog(2,regVal+1) = abs((readVoltage(ard,‘A1’)*12)-30);
fprintf(‘Process Complete! \n’);
I will post a picture of the circuit in the reply below, please do let me know if I’ve missed out any crucial information! Thanks!