Go Down

Topic: Trying to get real non whole numbers into excel via PLX-DAQ (Read 318 times) previous topic - next topic

Griiker

Hi All:

This will make me appear like a dummy.  This is my first Arduino Project, EVER!

I'm using a current sensor from Modern devices which uses 2 hall effect devices to generate a 0-5 volt or 0 to 3.3V signal.  I set it up to send a signal through the A0 input pin on a Arduino Leonardo.

I wrote a sketch to display the readings real time in Excel using PLX-DAQ.

However, I see that the results are in whole numbers,  with no decimal places (I've tried to use the decimal feature in eXcel.  I've noticed in the various youtube and other tutorials the same thing, there are no numbers with decimals in them.

I've tried using the floating point variable, among other things but I can't get it to generate real numbers (ex: 1.435, 2.5834, 4.3 etc) from the analog input. Why is this?

in order for the project I have in mind to work, I will need the decimal accuracy.  How can I achieve this?


Thanks

Griiker

el_supremo

Quote
I wrote a sketch
Post your code in code tags (using the </> icon)

Pete
Don't send me technical questions via Private Message.

Griiker

Sorry about that, I have to do some finagling to get the code from one computer to another.  Here is latest the code.  It is frustrating, because I have tried several different attempts with the float being placed in different places in ways that I saw in sketches done by others, but I still get an integer in the cell in eXcel.

Thanks for helping me.

griiker

Code: [Select]
#define sensor A0
 
  void setup() {
  Serial.begin(9600);
  Serial.println("CLEARDATA"); //clears any data from previous projects
  Serial.println("LABEL,Time,Timer,Volts"); //always write LABEL, so excel knows the next things will be names of columns (the example on line used Acolumn, Bcolumn)
  Serial.println("RESETTIMER"); //resets timer to 0
  // put your setup code here, to run once:

}

void loop() {
 float volts=sensor
  ;
  volts=analogRead(sensor);
 Serial.print("DATA,TIME,TIMER,");
 Serial.println(volts,4);// put your main code here, to run repeatedly
 
delay(2000);
}

el_supremo

Although volts is declared to be a float, its value is still an integer. Try sending a specific floating point value, such as 12.25, to see what you get.
If it still shows as an integer, you may have to modify the excel spreadsheet so that the Volts column displays a floating point value, although I think it defaults to 2 decimal places.

Pete
Don't send me technical questions via Private Message.

Griiker

Thanks for your help on this, Pete.

I tried your suggestion, assigning the "volts" variable an actual decimal value, I chose 12.56, out of several to choose from.  It did show up as "12.56"  in the excel spread sheet.  could this indicate that the data going into the input is not floating point data?  I'm using a current sensor from modern devices the link is below.

https://moderndevice.com/product/current-sensor/

I appreciate your help with this

Justin


el_supremo

The default format for cells in Excel is "General". Excel decides what type the data is before displaying it. If you send it 12.00 it may be deciding that it is an integer. I don't know if you can set the type of a column in Excel before you start using PLX-DAQ to send data. But after the data has been sent, you can highlight the column, right click on the heading and select "Format Cells". Then select The Format tab and the Category "Number". By default this sets the number to two decimal places and it will display 12 as 12.00

Pete
Don't send me technical questions via Private Message.

Griiker

The data is shown as number, not "General, I set that up previously.  When I set the Arduino Sketch to send "12.56" to the eXcel,  it displayed "12.56" in the cell. So the problem is not with eXcel.  When I set "volts" to use the input from A(0), I do not get floating point.

 
Code: [Select]
#define sensor A0
 
  void setup() {
  Serial.begin(9600);
  Serial.println("CLEARDATA"); //clears any data from previous projects
  Serial.println("LABEL,Time,Timer,volts"); //always write LABEL, so excel knows the next things will be names of columns (the example on line used Acolumn, Bcolumn)
  Serial.println("RESETTIMER"); //resets timer to 0
  // put your setup code here, to run once:

}

void loop() {
 float volts=sensor
  ;
  volts=analogRead(sensor);
 Serial.print("DATA,TIME,TIMER,");
 Serial.println(volts,4);// put your main code here, to run repeatedly
 
delay(2000);
}

el_supremo

Don't send me technical questions via Private Message.

ballscrewbob

I gave up with PLX-DAQ as it is limited to port numbers.

Processing was much better for my use.
Also THIS little gem which I accidentally found has a NON reset signal after it has initially started.
I can stop the graph and restart it and it doesn't send a reset signal to the board meaning I can copy out the data and restart it with only a minor loss of the few numbers between the restart.

The source is there and it looks like it would be quite easy to actually modify to add other things

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

el_supremo

The COM port limit has been fixed in the newer version of PLX-DAQ plus other fixes and enhancements.
See this thread: forum.arduino.cc/index.php?topic=437398

Pete
Don't send me technical questions via Private Message.

wichmannr

@Griiker: The analog to digital converter (ADC) on the Arduino Leonardo is converting a 0 to 5 volt singnal with 10 bit resolution into proportional integer numbers ranging from 0 to 1023. This data you can obtain with the analogREAD(Sensor) command. Multiplying the read interger number with 5 and dividing it with 1024 while converting the interger number to a real number results in the real voltage value measured. This conversion either can done on the receiving Excel sheet via PLX-DAQ or already in the Arduino Leonardo, still the resolution obviously will not change. If you then will have to convert the voltage signal into the appropriate sensor value you already could convert your ADV interger data directly into the final signal value.

Rolf

(see also: http://forum.arduino.cc/index.php?topic=434056.0 and the newer thread el_supremo already has given above)

ballscrewbob

Juts popping in to Thank ElSupremo..
And drop a kudos on him.

Tried the modified version from NetDevil and am very impressed.

Also very easy to set up from the sketch.


It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

el_supremo

Don't send me technical questions via Private Message.

Griiker

Thanks Rolf.

As I said, I'm new to this.  I modified the sketch part, and now I get the decimal places I need.  I noticed however, that I kept getting the same reading when I alter the sensor.  (Its a modern devices https://moderndevice.com/product/current-sensor/)  I checked the sensor and one of the Hall effect devices broke off, so now I still get a current reading but it doesn't change after the calculation, I am getting a  constant reading 0.0879V. 

I guessing this is the internal Voltage of the Arduino.

Fortunately, I got 2 sensors.

Go Up