Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Transfer between arduino and Sensor using LabView Commands problem #21

Open
surajparab945 opened this issue Dec 9, 2018 · 0 comments

Comments

@surajparab945
Copy link

I want to do two way communication between labview and arduino. For that I am using easy transfer Library which is really helpful. This library work like polling mechanism for eg: if there is any received data then send it.

I am able to communicate arduino with switch and sensor only when I comment the Send_SensorData function in loop. When I am uncommenting it it does not receive anydata. I don't know what is the problem. Is there any clock issue between arduino and sensor.

Here is the snippet of my code`
//create two objects
EasyTransfer Msgin, Msgout;

//give a name to the group of data
RECEIVE_DATA_STRUCTURE rxdata;
SEND_DATA_STRUCTURE txdata;

static long CycleTime = 10;
static boolean rgb_state = true;
static unsigned long start_time;

void loop() {

if (Msgin.receiveData()) {

// Start only once to start cycle time
if (rxdata.command == RGB_Sensor_Cycle_Time) {
CycleTime = rxdata.data;

}

Send_SensorData(); // Uncomment: command will not be received from LV and if commented reception of command.
}

void Send_SensorData() {

uint16_t red, green, blue, c;
unsigned long current_time;
unsigned long elapsed_time;

current_time = millis();
elapsed_time = current_time - start_time;

if (elapsed_time >= CycleTime && rgb_state == true ) { //&& rgb_state == false

for (int current_sensor_number = 0 ; current_sensor_number < 1; current_sensor_number++) {

  //Read Data for Sensors 0-7
  tcaselect(current_sensor_number);
  tcs.getRawData(&red, &green, &blue, &c);
  txdata.data1 = map(red, 0, 800, 0, 255),
  txdata.data2 = map(green, 0, 800, 0, 255);
  txdata.data3 = map(blue, 0, 800, 0, 255);
  Msgout.sendData();
// rgb_state = false;
}
start_time = current_time;

}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant