I-V Tracer with MATLab

Hello people!

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.

clear all

%% 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!

Attached is the layout of my circuit.

My current issue is that my Analog reading is a constant 5V value or sometimes a 0V value but when I use a digital multimeter to check the voltage drop across either of the “Voltage Sensing” resistors, I get a more accurate value like 0.004V or 4.873V and similar values.

I understand that the voltage output from the PV Panel is 12 volts and my board can only take in a maximum of 5 volts, thus I have connected the voltage dividing circuit as such.

Am I doing something very silly here?