09-24-2019 08:41 AM
@crossrulz wrote:
1. You are not telling the VISA Read to read enough characters. Set that number to be a lot more than any message you could possibly receive. I like to use 50.
2. JÞB has a good eye spotting that the read buffer looks like junk. This points to an incorrect baud rate or some other serial port setting (parity, number of data bits, number of stop bits, etc).
3. No need for the wait in your loop. You want to read as quick as the data comes in.
Its Later in the day here....I'd had my coffee for several hours already
09-24-2019 09:26 AM - edited 09-24-2019 09:31 AM
@JÞB wrote:
@crossrulz wrote:
1. You are not telling the VISA Read to read enough characters. Set that number to be a lot more than any message you could possibly receive. I like to use 50.
2. JÞB has a good eye spotting that the read buffer looks like junk. This points to an incorrect baud rate or some other serial port setting (parity, number of data bits, number of stop bits, etc).
3. No need for the wait in your loop. You want to read as quick as the data comes in.
Its Later in the day here....I'd had my coffee for several hours already
Thanks alot Sir. It works 🙂 i also change the string little bit in coding now.
but now i cannot see the current graph which is in blue rising for falling however voltage i can see fairly changes. Thanks for that to you both MR JPB and CROSSRULZ please help me with that.I provide a link with the video of execution.
https://www.youtube.com/watch?v=NlWuc4qbYNI&feature=youtu.be
As you can see in the video current is 3.11 Ampere which is near me and i just said my colleague to just decrease the voltage from the source he done it and i see clearly the change in the graph(goes down green one) however currentI(blue) doesnot even change. (Also i want to know how can i speed up the graph means the sampling rate of sending data so i can see the clear change very fast.
Please take a look on my arduino code also once. I donot have good concept of String. Neither i m good much at coding :(.
Thanks once again. If my current comes there and showed me up i will accept your solution and will make this thread to an end.
I upload the code please look into it. In the end is just part of the code complete code in the attachment
void setup() {
Serial.begin(9600);
}
void loop() {
// Voltage sensor void loop
value = analogRead(A2);
voltagesensor = value*(5.0/1024.0)*((R1+R2)/R2);
//Serial.print(voltagesensor);
//Serial.println("V");
//Current sensor void loop
float voltage_raw = (5.0 / 1024.0)* analogRead(VIN);// Read the voltage from sensor
voltage = voltage_raw - QOV + 0.001 ;// 0.007 is a value to make voltage zero when there is no current
float current = voltage / FACTOR;
if(abs(voltage) > cutOff ){
Serial.print(voltagesensor);// print voltage with 2 decimal places
//Serial.print("V");
Serial.print(current); // print the current with 2 decimal places
//Serial.println("A");
}else{
Serial.println("0.00A");
}delay(150);
}
Waiting anxiously.
Regards,
Maaz
09-24-2019 09:47 AM
STOP MESSING WITH THE STRING YOU ARE SENDING!!!! You are creating a moving target and breaking stuff.
In your latest Arduino code, it looks like there is no deliminator between your measurements at all. I don't even see a PrintLn being used (they were all commented out). I recommend you use a single PrintLn command for writing to the serial port. The format of the data that makes the most sense is "Voltage,Current". Then you have the simple comma separating your voltage and current measurements in a line. Alternatively, use a space.
As far as your update rate, you have a 150ms delay in the Arduino code. You can try making that smaller.
09-24-2019 10:06 AM
@crossrulz wrote:
STOP MESSING WITH THE STRING YOU ARE SENDING!!!! You are creating a moving target and breaking stuff.
In your latest Arduino code, it looks like there is no deliminator between your measurements at all. I don't even see a PrintLn being used (they were all commented out). I recommend you use a single PrintLn command for writing to the serial port. The format of the data that makes the most sense is "Voltage,Current". Then you have the simple comma separating your voltage and current measurements in a line. Alternatively, use a space.
As far as your update rate, you have a 150ms delay in the Arduino code. You can try making that smaller.
As per your request. You may see now either i cannot see the current value on COM port.
By Putting it println(voltagesensor,current)
I can only see the value of voltage only not current on COM.
09-24-2019 10:08 AM
@maazqaiser wrote:but now i cannot see the current graph which is in blue rising for falling however voltage i can see fairly changes. Thanks for that to you both MR JPB and CROSSRULZ please help me with that.I provide a link with the video of execution.
https://www.youtube.com/watch?v=NlWuc4qbYNI&feature=youtu.be
As you can see in the video current is 3.11 Ampere which is near me and i just said my colleague to just decrease the voltage from the source he done it and i see clearly the change in the graph(goes down green one) however currentI(blue) doesnot even change. (Also i want to know how can i speed up the graph means the sampling rate of sending data so i can see the clear change very fast.
Just watched the video...
Why aren't you using the VI you last uploaded? Instead, you are constantly opening and closing the port and using the Run Continuously function. Use the code you showed earlier that had a loop around the read and parsing.
Plus, turn off the highlight execution and your VI will run A LOT faster.
And, yes, the issue is your data format. The integer part of your current is being counted as part of the voltage. So the parsed current is only what comes after the decimal point. This is why you need a deliminator to separate your data points.
09-24-2019 10:11 AM
@maazqaiser wrote:
By Putting it println(voltagesensor,current)
You still need the delimiter. Use PrintLn(voltagesensor,",",current)
09-24-2019 10:15 AM
Does anyone have an explanation why people have such a difficult time understanding how serial communication works?
Here is a situation where even when you explain the basics, the person goes and just makes random changes without any valid reason and wonders why things still don't work!
09-24-2019 10:19 AM
@crossrulz wrote:
@maazqaiser wrote:
By Putting it println(voltagesensor,current)You still need the delimiter. Use PrintLn(voltagesensor,",",current)
09-24-2019 10:23 AM
@RavensFan wrote:
Does anyone have an explanation why people have such a difficult time understanding how serial communication works?
Here is a situation where even when you explain the basics, the person goes and just makes random changes without any valid reason and wonders why things still don't work!
'Thanks i wont ask now any body here. Many thanks
I m just a beginner i donot know much about serial communication
Thanks to all.
Who helped me alot
09-24-2019 10:44 AM
I could have sworn I saw people put multiple variables into a PrintLn command. But after some quick Googling, I can see I was wrong. So you will need something like this then:
Serial.Print(voltagesensor); Serial.Print(","); Serial.PrintLn(current);