-5V to 5V range with Arduino PWM, an op amp and a symmetric power supply

As you may know the current measuring here was done by measuring AI0, then AI1, and thus doing AI0-AI1 to get the voltage at the resistance and retrieving the current with Ohm's law. It was before implementing this whole circuit to draw the current-voltage characteristic in the negatives too.
But here, my voltages are going to be negative. So I cannot do an analogRead(AI0) or analogRead(AI1) because it's going to damage my analog inputs right? I thought Arduino pins only accepted positive 0-3.3V voltages. Am I mistaken ?

From aarduino due doc : I/O Voltage 3.3V

What are you referring to ?

Duplicate the part I circled in red and connect it to AI1.
So now you have a positive voltage 0 to 3.3V for both AI0 and AI1

Okay yeah I thought about this but hoped there would be other possibilities.
Thanks! I'll keep you updated with the final schemes and photos of the prototype when everything is finished and working!

"Duplicate the part I circled in red and connect it to AI1."

AI1 is at GND. I'm pretty sure that anything else connected to it will be at GND, too.
image

2 Likes


Yeah you're right I now disconnected the ground there and changed R4 from 10k 270 ohms to get more precision on my current

2 Likes

You turned R4 back to a 10K res. Do you think that's better ? I thought a smaller resistance like 270 would bring a smaller voltage drop in this branch, meaning I'd enjoy more of my range in my SD pin. Because for the moment, my Up in my SD pin goes from -0.6V to 2.2V

I just left it there from the last schemaic.
You will have to experiment to see what gives you the best range but 270 seem to be a good choice.

Good news is, I have things that are really close to the actual result I'm supposed to have. But certain plots have very strange faces. For example, manually, I plotted the Chip Select (DAT3) pin and got this :
CS_Manual
Then I did it with the arduino and here's the result :
CS

I don't know why there are such discontinuities. Here's the Python script for those interested:

import serial
import matplotlib.pyplot as plt
import numpy as np

# Serial port connection part
port = "COM3"
baudrate = 9600 
timeout = 10

ser = serial.Serial(port, baudrate, timeout=timeout)

A0=[]
A1=[]
i=[]
u=[]
val_A1=0
val_A0=0
Ur=[]
n=0
m=0
l=0

while True:
    line = ser.readline().decode('utf-8').strip()  #read the line from the serial port
    pos=0
    if line == "": #if there no more lines, break
        break
    for i in range (len(line)):
        if line[pos] == " ": # the space character is used to seperate AI1 and AI0
            val_A1=line[0:pos]
            val_A0=line[pos+1:]
        else:
            pos+=1
    
    A0.append(float(val_A0))
    A1.append(float(val_A1))
    n+=1
    print(line)

ser.close()

#re-scaling of the range
for m in range (len(A0)):
    Ur.append(-0.0064453125*(A0[m]-A1[m]))
    i.append(Ur[m]*1000/270) #current values are in this list

for l in range (len(A1)):
    u.append(A1[l]*(-0.0064453125)+3.3) #voltage values are in this list

#plot part
Y=i
X=u

plt.plot(X,Y)
plt.grid()
plt.title("Current-voltage characteristic")
plt.xlabel("Voltage (V)")
plt.ylabel("Intensity (mA)")
plt.show()

Also, I would like to make everything automatic, even the selection of the different pins. I thought I could use a multiplexer that is connected to all the different entrys and redirects the entry of only 1 pin, waits for the current-voltage characteristic to be drawn, then goes onto the next one... I'm going to see what different choices I have with these components and how they work. Never used one I don't know if that's even possible or if it's just going to work digitally

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