10-10-2017 11:31 AM - edited 10-10-2017 11:41 AM
hi guys, i've been reading a lot of post on how to make it work, but still i cant make a full duplex com betwen the arduino and labview.
since my english is quite poor, i'll talk through images :3
ARDUINO SIDE
void loop(void) { if (Serial.available()) { String serial_input_01 = Serial.readStringUntil(serial_input_separator); Serial.read(); String serial_input_02 = Serial.readStringUntil(serial_input_separator); Serial.read(); String serial_input_03 = Serial.readStringUntil(serial_input_separator); Serial.read(); String serial_input_04 = Serial.readStringUntil(serial_input_terminator); Serial.read(); int input_01 = serial_input_01.toInt(); int input_02 = serial_input_02.toInt(); int input_03 = serial_input_03.toInt(); int input_04 = serial_input_04.toInt(); switch (input_01) { case 1: if (input_02 == 1) { digitalWrite(7, LOW); } if (input_02 == 2){ digitalWrite(7, HIGH); } break;}
if i write in the serial monitor from the arduino 01,01 and hit enter digital write(7) turns off, if i write 01,02 turns on, so i guess it works right? if i wirte for instance 02,###,###,### i set the colors of an rgb led.
after the switch case structure:
sensors.requestTemperatures(); Serial.print("A"); Serial.println(sensors.getTempCByIndex(0)); int potValue = map(analogRead(potPin), 0, 1023, 0, 100); Serial.print("B"); Serial.println(potValue, DEC); delay(250);
} // end loop
as you can see arduino send every loop the values of the bs18d20 and the pot
A##.##
B###LABVIEW SIDE
so finally i add a switch and a visa write, but then the program does not recieve nor send a thing (and doesnt give any error)
taller.vi only reads
taller-02.vi try to write
so this is it guys, i really dont know what i'm doing wrong and it's driving me crazy, any help would be appreciated... PLEASE HELP! u.u
10-12-2017 10:09 AM - edited 10-12-2017 10:28 AM
FIX
i'm srry guys taller-02.vi was a wrong file, here is the current try-to-write file, with a little improvement
10-12-2017 10:29 AM
Remove "Bytes at port", it is not used when reading a line with a terminal symbol (carriage return). Instead of this function, put a constant, for example 100.
Check what actions Arduino performs when receiving the package. What he does if the package is wrong. Make sure that Arduino correctly accepts the parcel.
10-12-2017 12:19 PM - edited 10-12-2017 12:34 PM
thank you for your answer Borjomy
in the labview side there is an improvement after deleting the bytes at port, for that i cant thank you enough!
so after watching for a moment this is what i read in the read buffer
debug: number1: 1 number2: 101 number3: 101 number4: 101 A## B##
after moving the bool swtich
debug: number1: 1 number2: 201 number3: 201 number4: 201 A## B##
again thank you!
i guess is about how i'm sending the strings to the arduino.
--edit--
after a few test i did in serial monitor, this is what arduino is receiving for each state of the boolean switch
01,0101,0101,0101.. or 1,0101,0101,0101
02,0202,0202,0202... or 2,0202,0202,0202...
if i enter 1,101,101,101
arduino responds with
Debug: number1: 1 number2: 1 number3: 1 number4: 1
10-15-2017 12:38 PM
solution attached