04-15-2013 12:39 PM
See this post, it should accomplish what you're asking for:
https://decibel.ni.com/content/thread/16932
Note: This is exactly what Sam is suggesting in the previous post.
07-01-2013 01:20 AM
I have been tinkering with adding my serial LCD to the Adriano Board at Pin 1 tx->
I know how to operate the display in basic, adapting to LabVIEW, seems challenging.
10-31-2013 11:45 PM
Hello there,
I Need to connect multiple devices to a single UART (RX/TX) line!
I did try and the Arduino Mega was able to read the 4 probes connected to this Serial1 Port thrue the Multiplexer.
Now I would like to have the same reading on LabView...........
And here is where I stand now,
How do you transform the following code from Atlas Scientific for Arduino (they are the producer of my PH and DO probes) in to LabView?????
Any Idea
Thanks for your help.
Best Regards
Andrea
//Arduino MEGA sample code for the Atlas Scientific Mux/Demux serial port connector.
//This code has intentionally has been written to be overly lengthy and includes unnecessary steps.
//Many parts of this code can be truncated. Easy of understanding was the primary focus of this code.
//Code efficiency was not considered. Modify this code as you see fit.
//This code will output data to the Arduino serial monitor.
//This code was written for and tested on an Arduino MEGA 2560
//pin outs:
//VCC=5V
//SI=Arduino Mega pin 2
//SO=Arduino Mega pin 3
//E=GND
//RX=Arduino Mega pin 14(TX3)
//TX=Arduino Mega pin 15(RX3)
//GND=GND
//How to use this code:
//This code does not seem to work well with the Arduino serial monitor, we do not know why.
//Download Termite a simple RS232 terminal here: http://www.compuphase.com/software/termite-3.0.exe
//Be sure to setup Termite correctly. Append carriage return, baud rate=38400, data bits=8, stop bits=1, parity=none,
//flow control= none, forward= none.
//When sending data to the Arduino this is the format: "channel, command <CR>" (Where <CR> is carriage return, do not
//send the string "CR>")
//to open channel Y0 and send the "i" command it would be done as such: "0,i"
//to open channel Y3 and send the "r" command it would be done as such: "3,r"
Click here to download the *.ino file
int channel_tx(int channel,char* data);
int channel=99;
void setup()
{
Serial.begin(38400);
Serial3.begin(38400);
pinMode(s_I, OUTPUT);
pinMode(s_O, OUTPUT);
}
void loop(){
int channel_tx(int channel,char* data){
if(data_parse==true){
buffer_1=strtok(computerdata,",");
buffer_2=strtok(0,",");
channel=atoi(buffer_1);
data_parse=false;
channel_tx(channel,buffer_2);
}
}
void serialEvent(){
received_from_computer=Serial.readBytesUntil(13,computerdata,20);
computerdata[received_from_computer]=0;
data_parse = true;
}
void serialEvent3(){
received_from_device=Serial3.readBytesUntil(13,device_data,40);
device_data[received_from_device]=0;
Serial.println(device_data);
}
char *buffer_1;
char *buffer_2;
byte s_I=2;
byte s_O=3;
byte received_from_computer=0;
byte received_from_device=0;
boolean data_parse = false;
char computerdata[20];
char device_data[40];
//This is a function will open the correct channel and TX the data that is to be sent to it.
//we have 4 possible channels on the Mux/Demux(0-3) We set the channel var to 99
//on boot up that way it won’t open a channel inadvertently.
//this buffer holds the channel open data.
//this buffer holds the data to be sent to the open channel.
//enable the hardware serial port.
//enable the hardware serial port.
//sets the digital pin as output.
//sets the digital pin as output.
//this interrupt will trigger when the data coming from
//the serial monitor (pc/Mac/other) is received.
//we read the data sent from the serial monitor
//(pc/Mac/other) until we see a <CR>. We also count
//how many characters have been received.
//we add a 0 to the spot in the array just after the last
//character we received. This will stop us from transmitting
//incorrect data that may have been left in the buffer.
//This flag will indicate that data has been received and
//it is now time to do something with it.
//this interrupt will trigger when the data coming from
//the Mux/Demux serial port connector is received.
//we read the data sent from the Mux/Demux serial port
//connector until we see a <CR>. We also count how many
//characters have been received.
//we add a 0 to the spot in the array just after the last
//character we received. This will stop us from transmitting
//incorrect data that may have been left in the buffer.
//we output the received data from the Mux/Demux serial
//port connector to serial monitor.
//has data been sent to the Arduino Mega from the serial monitor(pc/mac/other).
//The data must be broken up. if "2,i" was TX'ed it will be parsed here. Buffer_1 will
//hold the number "2" indicating what channel to open.
//Buffer_2 will hold the "i", which is the command to be sent to the device on channel Y2.
//convert the string "2" into an int.
//we are done here, let’s stop this section of code from repeating.
//send the int (containing the number 2) and the string (containing the "i").
//this function will open a channel and transmit the data we have sent it.
switch (channel){
case 0:
digitalWrite(s_I,LOW);
digitalWrite(s_O,LOW);
Serial3.print('\r');
Serial3.print(data);
Serial3.print('\r');
break;
//which channel do we open? 0-3.
//we are to open channel Y0.
//Y0 is opened with SI=0.
//Y0 is opened with SO=0.
//We send a <CR> first to clear out any junk that was left in the RX buffer of an
//Atlas Scientific device. Data noise can happen when switching between channels.
//Send the data.
//All data going to an Atlas Scientific device if transmitted with a <CR>.
//Exit this case.
case 1:
digitalWrite(s_I,HIGH);
digitalWrite(s_O,LOW);
Serial3.print('\r');
Serial3.print(data);
Serial3.print('\r');
break;
//we are to open channel Y1.
//Y1 is opened with SI=1
//Y1 is opened with SO=0.
//We send a <CR> first to clear out any junk that was left in the RX buffer of an
//Atlas Scientific device. Data noise can happen when switching between channels.
//Send the data.
//All data going to an Atlas Scientific device if transmitted with a <CR>.
//Exit this case.
case 2:
digitalWrite(s_I,LOW)
digitalWrite(s_O,HIGH);
Serial3.print('\r');
Serial3.print(data);
Serial3.print('\r');
break;
//we are to open channel Y2.
//Y2 is opened with SI=0
//Y2 is opened with SO=1.
//We send a <CR> first to clear out any junk that was left in the RX buffer of an
//Atlas Scientific device. Data noise can happen when switching between channels.
//Send the data.
//All data going to an Atlas Scientific device if transmitted with a <CR>.
//Exit this case.
case 3:
digitalWrite(s_I,HIGH);
digitalWrite(s_O,HIGH);
Serial3.print('\r');
Serial3.print(data);
Serial3.print('\r');
break;
}
}
//we are to open channel Y3.
//Y3 is opened with SI=1
//Y3 is opened with SO=1.
//We send a <CR> first to clear out any junk that was left in the RX buffer of an
//Atlas Scientific device. Data noise can happen when switching between channels.
//Send the data.
//All data going to an Atlas Scientific device if transmitted with a <CR>.
//Exit this case.
//switch I is connected to pin 2.
//switch O is connected to pin 3.
//we need to know how many characters have been received.
//we need to know how many characters have been received.
//has the data been parsed?
//we make a 20 byte character array to hold incoming data from a pc/Mac/other.
//we make a 40 byte character array to hold incoming data from the connected device.