Trying to get real non whole numbers into excel via PLX-DAQ

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

I wrote a sketch

Post your code in code tags (using the </> icon)

Pete

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

#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);
}

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

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.

I appreciate your help with this

Justin

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

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.

#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);
}

Send 12.00. What does it display?

Pete

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

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

@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: Exchange of digital and analog data between Excel and Arduino - Interfacing w/ Software on the Computer - Arduino Forum and the newer thread el_supremo already has given above)

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.

Thanks Bob.

Pete

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 Current Sensor | Modern Device) 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.