04-10-2012 01:33 PM
I'm trying to set up wireless communication between 2 Arduinos, one of which has the LVIFA base on it.
I'm having trouble writing even the simplest code, though...I have the Arduinos hooked directly to each other for now and did a PWM write, but the Arduino won't initialize in LabVIEW.
I was wondering if maybe serial communication between 2 Arduino isn't possible while also using the LVIFA. I know LabVIEW is using the Arduino's main serial port for communication, but if I'm using a different serial port, it should still work, right? Can someone tell if this is true or false? Or if there is maybe another issues I haven't thought of?
My goal is just to write a PWM value from LabVIEW and have it go from Arduino1 to Arduino2.
Connections:
Arduino1 Serial3 rx --> Arduino2 Serial3 tx
Arduino1 Serial3 tx --> Arduino2 Serial3 rx
Arduino1 GND --> Arduino2 GND
Arduino1 is hooked to labtop. It has the LVIFA base on it with an additional Serial3.begin(9600) in the custom setup.
Arduino2 is power by a DC plug and has the following code:
void setup(){
Serial.begin(9600);
Serial3.begin(9600);
}
void loop(){
if (Serial3.available()){
Serial3.read();
}
analogWrite(9, Serial3.read());
}
04-10-2012 05:04 PM
To communicate over Serial3 I would imagine you need to use Serial3 commands. This means you need to add a function in LIFA that will execute Serial3.write() with the information that you want to have transmitted.
What command are you currently sending from LabVIEW?
04-11-2012 10:22 AM
How do I create a Serial3.write()? I need to take all of the information in LabVIEW and send it through Serial3. I also need to be able to read information from Serial3 and process it in LabVIEW
04-11-2012 10:53 AM
Actually, I don't think it'll work with the transceivers I have. Has anyone used LVIFA with some sort of wireless communicator? If so, with what and how?
04-11-2012 11:41 AM
hmm, I am not too familiar with Arduino C code, but why would you not use the following scheme:
PC+Xbee (via usb) talks to remote Arduino 1 and remote Arduino 2 to command them to do something? I just do this generating a pulse on each Arduino. So I do not change anything on the Arduino side, Just the LVIFA baud rate. By changing the setting of the destination address of the PC_Xbee you could talk to either Arduino with LabVIEW
L.
04-11-2012 11:43 AM
... each remote arduino has a Xbee with its own address respectively 1 and 2 for instance. Both Xbees would have their destination address set to 0, 0 being the address you set for the PC_Xbee. By using the AT command set you can change the destination address of PC_Xbee to 1 or 2 to talk to ARduino 1 or 2 using LV.
L.
04-11-2012 03:54 PM
Well, I don't actually have any Xbees right now. That's just an option I'm looking at since I can't get my current transceivers to work (radiometrix part# BIM3A-914-64).
I've been doing lots of testing and I can't get the Serial.read() command to work within the LVIFA base. I need to take information that I'm getting from commands in LabVIEW and store them into a variable in a custom code in the LVIFA base so I can send that data out again.
04-11-2012 06:24 PM
Serial3.write() exists on the arduino already. You just need to code in a function in the labview functions switch that will send information via Serial3.write().
Sending the commands to the second Arduino is conceptually simple but reading from it might not be so because, if I understand correctly, I think you would need to buffer everything that comes from Arduino 2 in Arduino 1 until LabVIEW requests it (or something like that).
However, I'm not sure that piggybacking Arduino's is a very efficient thing to do. As was said above, having both Arduino's connect directly to the PC (wired or wireless) is the way I would do it (in fact, that's what I'm doing with my project).
04-11-2012 07:25 PM
I think you misunderstood me. I have successfully communicated between the two Arduinos using multiple serial ports and everything works well. I was referring to setting up a function in LabVIEW.
I don't think that will be necessary, however. I am going to switch from my current transceivers to Xbees and I will go from there. I think the LVIFA is just not easily integrable with the transceivers I have.
04-11-2012 09:56 PM
Setting up a function for LabVIEW is actually quite simple. I just learned by looking at an existing functions and then creating my own. I posted one recent for using the pulsein() function. Maybe that will help you.
I think you would need to create a LabVIEW function that sends the information/command to Arduino 1 then have that function on Arduino 1 then send the information to Arduino 2 via Serial3 and wait for a response. When you get the response, you would then write the response back to the computer with Serial.write() like all the other functions do.
I might be able to write something up that should work but it would have to be after next Wednesday (too many important tests in the next 7 days).