LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Easy 7 Segment Digital Display Hardware

Solved!
Go to solution

@Dhubbell wrote:

 

HI Michael, I'm all for easy! After looking around I found another display with TEXT:
http://www.adafruit.com/products/1911
Do you think this will work with an FTDI Cable too?

I've never used the FTDI Labview pallet, but, I think I need to download and install the "FTDI Driver for Serial Communication Protocols (SPI,i2C)" from the VI Packet Manager. Is that correct? Also, do you have any sample code or can you point me to FTDI code that could help me understand it more?

 



The FTDI cable has an embedded USB to serial converter in the USB part of the connector. When you plug this in to your PC, it will appear as a simple COM port. To use this from within LabVIEW, you can use the built in VISA library from the Serial palette to communicate directly to the display. The datasheet linked from SparkFun's site goes into detail on the types of messages you can send to the display (https://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands).

 

The Adafruit text display you linked to can only be controlled via I2C, so you'd need something to sit between the PC and the display to handle interfacing to it. So this is a case where an Arduino would fit nicely. There are many options for getting data from your PC to the display (including the LIFA library as Hooovahh mentioned). Another option is to use Adafruit's display library, see this example: https://learn.adafruit.com/adafruit-led-backpack/0-54-alphanumeric. Using the library has the advantage that you don't need to do all of the lower level I2C comms (not that it's hard, it's just extra effort). One of the library examples simply echoes what it receives on the serial port to the display, which sounds like a good starting point. Again you would just send data from LabVIEW to the Arduino (via the Serial palette), which then sends the data via I2C to the display.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 11 of 22
(4,048 Views)

It's also worth bearing in mind that you can do I2C and SPI using the FTDI cables with the LibMPSSE-I2C library from FTDI. I'm not sure if they include LabVIEW examples for using the library but it's essentially calling a DLL with the call library function node. We've used it before for programming EEPROMs. You need to change the driver mode for the FTDI cable to use the D2XX API instead of VCP (virtual COM port...so it shows up as a serial port).

 

If it's a serial device - then use an FTDI cable as a serial port and use VISA to read/write to the device.


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 12 of 22
(4,025 Views)

I have the Arduino setup with the Alphanumeric display in the Arduino IDE V1.6.3, it works, but, the only way I get my display results, are when I compile & Upload the Sketch to the Arduino. This isn't very efficient since I really have no way of programmatically controlling the Alphanumeric display.  I thought I could simply write a new "ino" file on the fly and compile then upload, too slow...not efficient.

 

Further, if I try to use the “Labview Interface for Arduino” I must down grade the Arduino IDE to version 1.0.5. I tried that, but, I couldn’t figure out how to send an “ADDRESS” (0x72) to the Alphanumeric display.

Ideally, I need to be able to change the Alphanumeric display very quickly. I just don’t know how to send variables to the Arduino.  Do you know how to send variables to the Arduino using a command line?

 

I was hoping I could shell out of Labview and do something like this:
writedisplay.exe ADDRESS STRING.

 

It seems once the Arduino Sketch is loaded on the Arduino, that’s all you get, and I haven’t found a way to send variables to the Arduino on the fly.  Here's the an example Sketch I modified to display on ADDRESS = 0x72 and it will display "ABCD" on the Alphanumeric display.

 

So how do I make this a command line option for the Arduino where I can then use a VI or EXE to writedisplay.exe 0x72 ABCD  ???

 

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4();

void setup() 
{
  Serial.begin(9600);
  
  alpha4.begin(0x72);  // pass in the address

  alpha4.clear();
  alpha4.writeDisplay();

  alpha4.writeDigitAscii(0, 'A');
  alpha4.writeDigitAscii(1, 'B');
  alpha4.writeDigitAscii(2, 'C');
  alpha4.writeDigitAscii(3, 'D');
  alpha4.writeDisplay();
}
void loop() {
}

Any suggestions are helpful.
Thank you,

Doug

0 Kudos
Message 13 of 22
(3,959 Views)
Solution
Accepted by Dhubbell

The only way to get the Arduino to change anything on the fly is for you write a sketch that is listening on the serial port for a command.

Not hard to do. http://www.codeproject.com/Articles/473828/Arduino-Csharp-and-Serial-Interface

I simplified the sketch to suit my needs.

And simplified the C# program as well. You would simply replace the C# with LabVIEW.

 

Or if you want to get fancy you can use wifi or Ethernet by purchasing a shield.

0 Kudos
Message 14 of 22
(3,946 Views)

This source to the LIFA toolkit is open and free.  In it you can see how it works.  Basically it requests something over the COM port, then waits for a reply.  Look at one of the functions already written like Read Analog Pin to see how it forms the request string (0x08 0xYY where YY is the pin number) and then it gets a reply (two bytes that are then combined and scaled by 0.0049).  You can modify the Arduino source to have additional commands beyond 0x2D.

 

Also there is code already written for doing a 7 segment display using LIFA, but this method uses 7 digital lines (8 actually for the period).  Not nearly as flexible as the other displays linked earlier, or doing it with a custom message.

0 Kudos
Message 15 of 22
(3,925 Views)

@Hooovahh wrote:

This source to the LIFA toolkit is open and free.  In it you can see how it works.  Basically it requests something over the COM port, then waits for a reply.  Look at one of the functions already written like Read Analog Pin to see how it forms the request string (0x08 0xYY where YY is the pin number) and then it gets a reply (two bytes that are then combined and scaled by 0.0049).  You can modify the Arduino source to have additional commands beyond 0x2D.

 

Also there is code already written for doing a 7 segment display using LIFA, but this method uses 7 digital lines (8 actually for the period).  Not nearly as flexible as the other displays linked earlier, or doing it with a custom message.


The OP needs to change the code from the Arduino end not the LabVIEW end.

 

His current Arduino sketch is not flexible. The setup( ) function runs *once* when the Arduino is powered up. The loop( ) function is where code needs to be placed so that the Arduino can respond to commands from LabVIEW or whatever program he chooses to use.

0 Kudos
Message 16 of 22
(3,909 Views)

@nyc_(is_out_of_here) wrote:

The OP needs to change the code from the Arduino end not the LabVIEW end.


I'm sorry if it wasn't clear, I was suggesting the OP needs to change the code on both ends.  I was just suggesting to look at how the "both ends" of it works for the analog input.  See how it requests and gets data on the LabVIEW side, and see how it gets the data and sends it on the Arduiono side.  That's what I meant by "You can modify the Arduino source to have additional commands beyond 0x2D"

 

It's been a while since I've opened the LIFA firmware source, but I'm pretty sure there are comments in the code saying where to edit the code to add new functionality, and yes these comments are in the loop, not setup.

0 Kudos
Message 17 of 22
(3,899 Views)

@Hooovahh wrote:

@nyc_(is_out_of_here) wrote:

The OP needs to change the code from the Arduino end not the LabVIEW end.


I'm sorry if it wasn't clear, I was suggesting the OP needs to change the code on both ends.  I was just suggesting to look at how the "both ends" of it works for the analog input.  See how it requests and gets data on the LabVIEW side, and see how it gets the data and sends it on the Arduiono side.  That's what I meant by "You can modify the Arduino source to have additional commands beyond 0x2D"

 

It's been a while since I've opened the LIFA firmware source, but I'm pretty sure there are comments in the code saying where to edit the code to add new functionality, and yes these comments are in the loop, not setup.


The Arduino code is already written if the OP would only read the information at the link I provided in the post above.

 

 

0 Kudos
Message 18 of 22
(3,889 Views)
Solution
Accepted by Dhubbell

@nyc_(is_out_of_here) wrote:

The only way to get the Arduino to change anything on the fly is for you write a sketch that is listening on the serial port for a command.

Not hard to do. http://www.codeproject.com/Articles/473828/Arduino-Csharp-and-Serial-Interface

I simplified the sketch to suit my needs.

And simplified the C# program as well. You would simply replace the C# with LabVIEW.

 

Or if you want to get fancy you can use wifi or Ethernet by purchasing a shield.


Yes, you were correct nyc!  The code was already in the example I had, but, I'm new to the Arduino, and Here's the code that works for listening:

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4();

void setup() 
{
  Serial.begin(9600);
  
  alpha4.begin(0x72);  // pass in the address

  alpha4.clear();
  alpha4.writeDisplay();

  alpha4.writeDigitAscii(0, '*');
  alpha4.writeDigitAscii(1, '6');
  alpha4.writeDigitAscii(2, '1');
  alpha4.writeDigitAscii(3, '@');
  alpha4.writeDisplay();
}
char displaybuffer[4] = {' ', ' ', ' ', ' '};
void loop() {
    while (! Serial.available()) return;
  
  char c = Serial.read();
  if (! isprint(c)) return; // only printable!
  
  // scroll down display
  displaybuffer[0] = displaybuffer[1];
  displaybuffer[1] = displaybuffer[2];
  displaybuffer[2] = displaybuffer[3];
  displaybuffer[3] = c;
 
  // set every digit to the buffer
  alpha4.writeDigitAscii(0, displaybuffer[0]);
  alpha4.writeDigitAscii(1, displaybuffer[1]);
  alpha4.writeDigitAscii(2, displaybuffer[2]);
  alpha4.writeDigitAscii(3, displaybuffer[3]);
 
  // write it out!
  alpha4.writeDisplay();
  delay(200);

}

Now, the next step is for the NI Visa code.  I opened NI Max, Found the USB COM4, OPEN VISA TEST PANEL, INPUT/OUTPUT, ENTER COMMAND 4321/n, then I clicked WRITE, it worked in NI VISA!

 

I realize this should be very easy, but, how do I get the code from the VISA TEST PANEL to a vi?  I gave it a few tries, but, nothing seemed to work when I applied what I saw in NI MAX to a vi.

 

Thanks for all the help and suggestions!  It's very close now...How do I write to COM4 using NI VISA routines in a VI?

 

Doug

0 Kudos
Message 19 of 22
(3,880 Views)

Congrats it looks like you are really close to getting this to work.  Open the Example Finder.  From LabVIEW open the Help >> Find Examples.  Search for Serial and open the Simple Serial example.  It should work similar to MAX and show how to send a request, wait, and get a response.

0 Kudos
Message 20 of 22
(3,876 Views)