I need your light on a VERY easy programming code.
I am new to arduino and need your help for a project.
I have a LEONARDO and all i want it to give 2 analog signals inputs 0-5v (pressure sensors) and take their voltage difference as an output (pwm)
For example if A0 is 5v analog and A1 is 1V i want output pwm 4V
If its the opposite then -4V.
I will be grateful for any help!
Also any guidance on the connections.
Shall i connect anywhere on leonardo the - of the sensors?or just the + on A0 and A1?
Are you sure you understand what PWM is? Do you mean a continuous 4V that is made by feeding a PWM signal into an RC filter? Or do you mean you want to rapidly switch between 4V and 0V?
I would like to thank both of you for your responses,especially if we consider its Sunday.
Ok let me explain you
I have 2 pressure transducers which gives 0-5v output
I log both of them on a data logger and i can screen some results.
Now,there is a need to track the differential pressure,that means P1-P2
Unfortunately data logger programm cant make this subtraction and here is where arduino comes in!
Both sensors give analog signals,i also want analog output but arduino doesn’t have it.
So pwm signal is closer and almost same with analog for my application.
So all i want it to take P1-P2 and log them as input to my data logger.
As you understand P1-P2 will have positive and negative form.
If your datalogger has ony one single analog input. You have to create the negative voltage with some circuitry.
This circuitry can either be a operational amplifier supplied with +7V and explicitly with a -7V (you see the minus-sign?!) which does the substraction.
or you lift the ground-potential of the analog-datalogger to +2,5V. Compared to the Ground of the arduino. This means any voltages - coming from the arduino - below 2,5V will be negative for the datalogger.
Are you sure yor datalogger can log negative voltages?
Can you post a link to the datasheet of your datalogger?
Even more interesting: what is the final purpose of all this and where does the datalogger store his data?
Knowing the complete project may offer new ideas to achieve the final purpose
Be the change you want to see in the world
best regards Stefan
My datalogger has 2 inputs, + and -
For example i have a motor spinning and a generator at his shaft,motor clockwise is + if anti clockwise then -
Generator has 2 output wires and swaps the voltage accordingly.
Motor at max speed = +-10v (depends on the direction)
So yes my datalogger can screen negative voltage.
The problem starts with arduino leonardo,at the beginning i thought it was possible to make it with one pwm output
Now if I understand correct from your replies,its not possible?
All i want to do is to make a graph on my datalogger program with P1-P2 in time.
Datalogger screens the results live on computer screen and its possible to save them on pc
to the PWM-signal: with 0% dutycycle you get 0,00V with anything above 0% dutycycle you get a plus-voltage. But never a negative voltage.
As I have said a negative voltage would require additional analog circuitry
With this information about the datalogger and the rest of your project it is still unclear to me if it would be possible to get the data into the computer without using the datalogger.
The Arduino Due delivers digital data which could be feeded into the computer directly
So what is the timeinterval you are storing the measurements?
How much "live" = realtime does the logging have to be? showing the actual values only milliseconds after the measurement is done?
What interface does the DataQ-Datalogger use to send the data into the computer?
Be the change you want to see in the world
best regards Stefan
Ok let me explain more.
Datalogger has 8 inputs (16 total +-)
Lets focus on the 2 sensors i am interested.
Currently these 2 sensors go to the datalogger on different ports (they capture 2/8 inputs)
There is program called windaq (which is very very permitted) and dont allow you to make big changes.Just screen the results of each port or compare them.
Until now I downloaded all data of my measurements on an excel file and i made the subtraction there,then i graph again.
Some days ago i was thinking if its possible to connect the pressure transducers to an arduino instead of the datalogger directly.
Then arduino is going to make the subtraction and give me 1 output which I will connect to the datalogger (at the original position of 1/2 pressure transducers)
Windaq program is going to make the graphs normally if we achieve that.
About the dutycycle.
I am currently working with 50-100 samples per second to all the tests i am running,each test is accomplished in 100 sec ( 0.01 or 0,02hz)
Ok let me explain more.
Datalogger has 8 inputs (16 total +-)
Lets focus on the 2 sensors i am interested.
Currently these 2 sensors go to the datalogger on different ports (they capture 2/8 inputs)
There is program called windaq (which is very very permitted) and dont allow you to make big changes.Just screen the results of each port or compare them.
Until now I downloaded all data of my measurements on an excel file and i made the subtraction there,then i graph again.
Some days ago i was thinking if its possible to connect the pressure transducers to an arduino instead of the datalogger directly.
Then arduino is going to make the subtraction and give me 1 output which I will connect to the datalogger (at the original position of 1/2 pressure transducers)
Windaq program is going to make the graphs normally if we achieve that.
About the dutycycle.
I am currently working with 50-100 samples per second to all the tests i am running,each test is accomplished in 100 sec ( 0.01 or 0,02hz)
You have the hardware of the datalogger and how does the physical plug of the datalogger that is plugged into a physical socket in your computer look like??
50 to 100 measurements per second is a frequency of 50 to 100 Hz. (not 0,01 Hz)
0,01 Hz would be one measurement every 100 seconds.
So how many datapoints do you collect:
100 seconds long 100 measurings per second which sums up to 10.000 measured values?
I would like to thank you once again,especially more as its sunday!
Ok i collect 50 samples per second from datalogger and total test duration is 100 sec (thats where 0.01hz are reffered to)
So total 5000 samples per test.
you can imagine 50 sample per second as
a trigger gets fired 50 times per second and this is exactly 50 Hz.
100 seconds long is just 100 seconds long. It is just a time.
And has absolutely nothing to do with Hz.
Hz is waves per second Hz is 1/second
OK the datalogger has a USB-interface.
If you just want to use these two input-channels P1, P2 and calculate the difference P1 - P2 and feed this into the the windaq-software. If you go to your device-manager and look for
interfaces (COM&LPT) and then plug in your di-1110-usb.
does there appear a new comport?
If yes there might be a chance to connect the arduino due instead of the datalogger
Be the change you want to see in the world
best regards Stefan
Let me reply you tomorrow when i will return to the lab!
You are confusing me a little bit,why not to connect these 2 sensors with the arduino and then arduino output to one channel of datalogger?
The generator i have on the motor it gives -+ voltage to one channel of the datalogger and everything is fine,i can make graphs correctly!
Why we cant do the same with the arduino?
I am trying to understand why you want to skip datalogger and connect arduino directly on the computer ports and then log the data to the dataloggers program.
I think its much easier just to take arduino outputs and use them as datalogger inputs.
power-supply
a first power-supply creating plus-voltage
a second power-supply creating a minus-voltage
This dual-power-supply is needed for this analog circuit that creates the negative voltage
which the arduino
can not
create
Be the change you want to see in the world
best regards Stefan
I understand well your suggestions right now,you are right!
We cant give negative voltage and positive from the same circuit,so we have to make an external power supply for 1 of them.
Let me ask you something easier :
What if we make P1-P2 output to be in a range of 0-5V no matter the sign.
Moreover lets say that our differential pressure range is -100bar to + 100bar
Why if we just make the subtraction in arduino and programm the datalogger as
0V = -100 bar
5V = +100 bar
(2,5V = P1-P2=0 )
Then arduino as :
OUTPUT = (P1-P2)/2 +2.5V
If you try all possible combinations,you are going to see that the results are correct.
So we dont need to mess with negative voltage output,just to change the limits of the datalogger software.
Hi manolos,
defining 2,5V which equals to a duty-cycle of 50% as 0 bar.
Everything below 50% dutycylce as negative result
and everything above 50% duty-cycle as positive result of P1 - P2.
Sure this will work
Be the change you want to see in the world
best regards Stefan
sure I can help. Help means not to write down the code.
You are in the right direction with your equation
OUTPUT = (P1-P2)/2 +2.5V
take pencil and paper and analyse the situation.
Whenever you have a specific question related to this calculation or the coding
post your attempt combined with a question
Be the change you want to see in the world
best regards Stefan