LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino Mega Serial1, 2 and 3 with Atlas Scientific sensors

Hello there,

Any body tried to use the additional serial ports on the Arduino succesfully?

Any Idea how to write a sketch in LabView that do the same like this code written by Atlas Scierntific for Arduino?

Code:

I am using this Serial Port Multiplex:

Thanks to all

and best regards

Andrea

0 Kudos
Message 1 of 25
(13,351 Views)

Hello Andrea,

Try using the Advanced Serial Write and Read.Vi that comes with Labview to read the sensor data. 

Set COM port to a value appropriate for your computer.

Set Baud Rate to 38,400.

Set Termination character to D. Here D means carriage return.

Use this VI with the same Aduino Mega code you posted about 10 days ago.

The operation and results should be similar to what you when you used the Arduino Serial Monitor. .

hrh1818

0 Kudos
Message 2 of 25
(4,965 Views)

Hy hrh1818,

sorry for late reply, I went out of town for a wile........

I am having some issues in understanding what I actually have to do.....

Use this VI with the same Aduino Mega code you posted about 10 days ago.

The operation and results should be similar to what you when you used the Arduino Serial Monitor. .

hrh1818

At the present moment the VI is working for all what is regarding normal controls on Digial inputs and Anaolg Inputs (for temperature) like for this schematic drawing in Fritzing: Relay and Temp Probes.fzz

Now is the moment to connect the Multiplex I got from Atlas Scientific to the Arduino......

Are the 2 breadbords on the Fritzing image with the PH and DO probes.

They have to be connected to the Serial 1 and 2 on the Arduino Mega (Pin 14-15-16-17)

How the "Advanced Serial Write and Read.Vi" can see those ports?

Thanks for your time in explaining all of this.

I am adding the last version of my VI without the Serial 1 and 2 parts (because I have no idea how to ...)

Best regards

Andrea

Download All
0 Kudos
Message 3 of 25
(4,965 Views)

Hello Andrea,

Your Question

"How the  "Advanced Serial Write and Read.Vi" can see those ports?"

Answer

The Advanced Serial Write and Read.VI sees a serial port exactly the same way the Arduino Serial Monitor. You send the appropriate command from either the "Advanced Serial Write and Read.Vi or the Arduino Serial Monitor, Arduino process the command and then returns the result as appropriate to either Labview or the Arduino Serial Monitor. 

Eventually the easiest way to collect data from Arduino's analog, digital  and  serial inputs and to send commands to  the digital outputs will be to use LIFA.

When I get more time I will add some comments about a non LIFA approach to collectlng  data from Arduino's analog, digital  and  serial inputs and sending commands to the digital outputs.

Did you intentionally leave out of your Fritzing diagram the serial multiplexors and the digital signals used for selecting a serial channel.

Heh1818

0 Kudos
Message 4 of 25
(4,965 Views)

Hello hrh1818,

thanks for your answer, and explenation.

here what I am trying at the moment:

I have uploaded the Serial_Port sketch to the Arduino,

and connected the breadboard with one multiplexor and 4 probes how indicated from the Atlas Scientific website.

and tried with the Arduino 'Serial Monitor' if all was working.... and it was:

     when I write 0,r I have the single reading of that probe

     with            1,r another probe and so on.

Than uploaded the normal LIFA_BASE to the Arduino and tried the 'Advance Serial Monitor.VI'

with the suggested baud rate from Atlas Scientific that is 38400 so I used it on the VI,

Changed the letter A in D in the field 'thermination char'

When I insert the commant '0,r' in the field 'Write' and than press the 'Run' button of Labview, the RX led on the Arduino makes a single blink followed by an OFF/ON of the Led 13 but nothing else happen until the message:

appears.

I suposed that the command get to the board but the board doesn't answer.............

Could it be the 'Termination Character'?

This is what I found in the code: (file : mux_mega_sample_code.ino)

//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>")

the string I am supposed to recive is a number like

8.95

or

10.34

Doas this means that the bytes to read have to be 4 or 5?

Regarding the Fritzing:

Yes, I didnt use the proper components because are not in the 'Component' list...... it is just a schema for me to remember which Pin is used for what......

but attached there is a more complete version of it.

If I got it right(from the explenantion I found in the file attached:serial_port_connector_wiring), I must be able to send to the Multiplexor pins S1 and S0 the different status (LOW/HIGH) to request the reading of the 4 different probes attached to it. But this is in the future... I hope.

Thanks again for all your help, I hope you can get some important information that will resolve easly this problem I am block with.

All the best and regards

Andrea

0 Kudos
Message 5 of 25
(4,965 Views)

...sorry, I forgot to mention that inside the LIFA_BASE I have added the line

Serial3.begin(38400);               //enable the hardware serial port.
0 Kudos
Message 6 of 25
(4,965 Views)

I have a feeling that there is significant misunderstanding here.

"How the "Advanced Serial Write and Read.Vi" can see [Arduino serial ports]?"'  Answer:  It can't.  The Serial 1,2,3 ports on the Arduino are only accessible with Arduino code on the Arduino.

One method that hrh1818 metioned is to communicate with the sensors without LIFA but instead using LabVIEW directly (VISA VIs).  Using LabVIEW directly to communicate with the sensors requires a USB to Serial converter (the Debugger should work for this according to Atlas-Scientific).  You would then need to set the S0 and S1 pins with LIFA (to determine which device you are talking to).  This method requires no modifications of LIFA.

The other method is to modify LIFA to use the auxillary serial port (Serial 1, 2, 3) on Arduino to communicate with the sensors (this is the one that I was basing my comments on but I'm starting to think that maybe the other idea might be better).

So, Andrea, I think you have mixed the two ideas.  It will need to be one or the other.

0 Kudos
Message 7 of 25
(4,965 Views)

Hello Nathan,

When I said a non LIFA approach I thinking of code similar to the following running on Arduino.

A mixture of Arduino code an pseudo is used to illustrates the concept.

loop

{

// Set digital outputs using a shift register

while (Serial.available() > 0)

{

   // get decimal value of bit pattern

   val = Serial.parseInt();

  if(  ( 0  <= val && val <= 255 ) && ( serial.read == '\n' ) )

        {

         send decimal value of bit pattern to output

          shiftout( SER, CLK, MSBFITST, val );

       {

  }

// read serial data from one 4 channel multiplexor

// once every 20 seconds

if ( millis() % 20000 == 0 )

  {  read serial data

    send data to Labview

  ]

//  read temperature data once every 10.091 seconds

if ( millis() % 10091 == 0)

{

  read temperature data

  send temperature data to Labbview

}

// poll level switches once every 1.071 seconds

if (millis() % 1071 == 0 )

  {

    read digital inputs

    send digital input states to Labview

  }

}

Notes

There is no built in delay in the loop.

millis() goes back to zero after approximately 50 days.

hrh1818

0 Kudos
Message 8 of 25
(4,965 Views)

A fully non-LIFA approach is not an option for Andrea because she already has many other functions of her system working with LIFA.

0 Kudos
Message 9 of 25
(4,965 Views)

Hi there,

Is the 'Debugger' from Atlas Scientific going to be connected to one USB port?

And this USB port can be read from Labview?

If so I need only a USB multiplier and connect the 8 sensors on 8 different 'Debuggers' and to 8 USB ports......

Or ???

What do you think the easiest solution would be?

I'm not  seeing the light at the end of the tunnel any more......

Best regards

and thanks again for the help

Andrea

0 Kudos
Message 10 of 25
(4,965 Views)