- 1.6k
- 2
- 12
- 20
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where,
X = Flag CP Value
_ = Space
P = Polarity
C = CP Received value
Y = Flag Field Gradient
F = Field Gradient Received value
Z = Flag Contact CP
T = Contact CP Received value
There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs
< X -89 Y -1989 Z -1096 > < X 1039 Y 8 Z 78 >
< X -89 Y -1989 Z -1096 >
< X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1(0x48); /*/ Use this for the 16-bit version */
Adafruit_ADS1115 ads2(0x49);
void setup(void){
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin();
ads2.begin();
}
void loop(void){
int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1();
results02 = ads1.readADC_Differential_2_3();
results03 = ads2.readADC_Differential_0_1();
Serial.print("X ");
Serial.print(round(results01 * multiplier));
Serial.print(" Y ");
Serial.print(round(results02 * multiplier));
Serial.print(" Z ");
Serial.print(round(results03 * multiplier));
Serial.println(); // send a cr/lf
delay(500);
}
Any help pointing me in the right direction would be Amazing. Thanks in advance
Joe
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where,
X = Flag CP Value
_ = Space
P = Polarity
C = CP Received value
Y = Flag Field Gradient
F = Field Gradient Received value
Z = Flag Contact CP
T = Contact CP Received value
There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs
< X -89 Y -1989 Z -1096 > < X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */
Adafruit_ADS1115 ads2(0x49);
void setup(void){
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin();
ads2.begin();
}
void loop(void){
int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1();
results02 = ads1.readADC_Differential_2_3();
results03 = ads2.readADC_Differential_0_1();
Serial.print("X ");
Serial.print(round(results01 * multiplier));
Serial.print(" Y ");
Serial.print(round(results02 * multiplier));
Serial.print(" Z ");
Serial.print(round(results03 * multiplier));
Serial.println(); // send a cr/lf
delay(500);
}
Any help pointing me in the right direction would be Amazing. Thanks in advance
Joe
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where,
X = Flag CP Value
_ = Space
P = Polarity
C = CP Received value
Y = Flag Field Gradient
F = Field Gradient Received value
Z = Flag Contact CP
T = Contact CP Received value
There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs
< X -89 Y -1989 Z -1096 >
< X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1(0x48); // Use this for the 16-bit version
Adafruit_ADS1115 ads2(0x49);
void setup(void){
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin();
ads2.begin();
}
void loop(void){
int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1();
results02 = ads1.readADC_Differential_2_3();
results03 = ads2.readADC_Differential_0_1();
Serial.print("X ");
Serial.print(round(results01 * multiplier));
Serial.print(" Y ");
Serial.print(round(results02 * multiplier));
Serial.print(" Z ");
Serial.print(round(results03 * multiplier));
Serial.println(); // send a cr/lf
delay(500);
}
Any help pointing me in the right direction would be Amazing. Thanks in advance
Joe
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where, X = Flag CP Value _ = Space P = Polarity C = CP Received value Y = Flag Field Gradient F = Field Gradient Received value Z = Flag Contact CP T = Contact CP Received value There
X = Flag CP Value
_ = Space
P = Polarity
C = CP Received value
Y = Flag Field Gradient
F = Field Gradient Received value
Z = Flag Contact CP
T = Contact CP Received value
There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs <
< X -89 Y -1989 Z -1096 > < X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h> #include <Adafruit_ADS1015.h> Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */ Adafruit_ADS1115 ads2(0x49); void setup(void) {
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin(); ads2.begin();
}
void loop(void) { int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1(); results02 = ads1.readADC_Differential_2_3(); results03 = ads2.readADC_Differential_0_1();
Serial.print("X "); Serial.print(round(results01 * multiplier));
Serial.print(" Y "); Serial.print(round(results02 * multiplier));
Serial.print(" Z "); Serial.print(round(results03 * multiplier)); Serial.println(); // send a cr/lf delay(500);
}
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */
Adafruit_ADS1115 ads2(0x49);
void setup(void)
{
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin();
ads2.begin();
}
void loop(void)
{
int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1();
results02 = ads1.readADC_Differential_2_3();
results03 = ads2.readADC_Differential_0_1();
Serial.print("X ");
Serial.print(round(results01 * multiplier));
Serial.print(" Y ");
Serial.print(round(results02 * multiplier));
Serial.print(" Z ");
Serial.print(round(results03 * multiplier));
Serial.println(); // send a cr/lf
delay(500);
}
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where, X = Flag CP Value _ = Space P = Polarity C = CP Received value Y = Flag Field Gradient F = Field Gradient Received value Z = Flag Contact CP T = Contact CP Received value There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs < X -89 Y -1989 Z -1096 > < X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h> #include <Adafruit_ADS1015.h> Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */ Adafruit_ADS1115 ads2(0x49); void setup(void) {
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin(); ads2.begin();
}
void loop(void) { int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1(); results02 = ads1.readADC_Differential_2_3(); results03 = ads2.readADC_Differential_0_1();
Serial.print("X "); Serial.print(round(results01 * multiplier));
Serial.print(" Y "); Serial.print(round(results02 * multiplier));
Serial.print(" Z "); Serial.print(round(results03 * multiplier)); Serial.println(); // send a cr/lf delay(500);
}
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where,
X = Flag CP Value
_ = Space
P = Polarity
C = CP Received value
Y = Flag Field Gradient
F = Field Gradient Received value
Z = Flag Contact CP
T = Contact CP Received value
There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs
< X -89 Y -1989 Z -1096 > < X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */
Adafruit_ADS1115 ads2(0x49);
void setup(void)
{
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin();
ads2.begin();
}
void loop(void)
{
int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1();
results02 = ads1.readADC_Differential_2_3();
results03 = ads2.readADC_Differential_0_1();
Serial.print("X ");
Serial.print(round(results01 * multiplier));
Serial.print(" Y ");
Serial.print(round(results02 * multiplier));
Serial.print(" Z ");
Serial.print(round(results03 * multiplier));
Serial.println(); // send a cr/lf
delay(500);
}
Newbe needing help with fixed string length
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need - <X_PCCCC_Y_PFFFF_Z_PTTTT> Where, X = Flag CP Value _ = Space P = Polarity C = CP Received value Y = Flag Field Gradient F = Field Gradient Received value Z = Flag Contact CP T = Contact CP Received value There is also a line feed and carriage return present at the end of each string. The polarity indicator will only display a minus sign ‘-‘ if the received value is negative otherwise no assignation will be transmitted. Although the overall string length is constant the values for each measurement are right justified and hence a space will be present should the value of the measurement not necessitate the utilisation of all allocated character spaces. Sample Outputs < X -89 Y -1989 Z -1096 > < X 1039 Y 8 Z 78 >
this is my code so far
#include <Wire.h> #include <Adafruit_ADS1015.h> Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */ Adafruit_ADS1115 ads2(0x49); void setup(void) {
Serial.begin(9600);
ads1.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads2.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV
ads1.begin(); ads2.begin();
}
void loop(void) { int16_t results01,results02,results03;
results01 = ads1.readADC_Differential_0_1(); results02 = ads1.readADC_Differential_2_3(); results03 = ads2.readADC_Differential_0_1();
Serial.print("X "); Serial.print(round(results01 * multiplier));
Serial.print(" Y "); Serial.print(round(results02 * multiplier));
Serial.print(" Z "); Serial.print(round(results03 * multiplier)); Serial.println(); // send a cr/lf delay(500);
}
Any help pointing me in the right direction would be Amazing. Thanks in advance
Joe