I had a need to plot data to a graph that could be inserted into a record for customer use. In previous projects I had use Windows LabVIEW VIs to accomplish this using the Plot XY VI which created a new picture that I would annotate and add cursors. Using the Picture to Pixmap VI, I could take the image data output and finally save to PNG using the Write PNG File VI. This worked well, but as my project goes more and more embedded I wanted to move this functionality to the cRIO 9074 in our system. Turns out this functionality is not available on the cRIO 9074 so I needed to find another solution. Since I knew I could potentially leverage Linux solutions on the new RT Linux controllers I set about finding a Linux solution. Using VMware I installed Fedora 23 to a VM and found a command line tool called gnuplot which could plot and make very complex and professional looking graphs. After being comfortable using gnuplot in a Linux environment I was ready to test on a NI RT Linux target.
First connected a cRIO 9033 to our local work network and had an IP address assigned. Using MAX I created a password for the admin account and installed the standard 2014 RT software package. The using Putty I established a connection to the cRIO and logged in using the admin password. Using opkg I was able to install gnuplot as follows:
From the command line it is possible to run gnuplot and type successive commands to plot and output to various terminals <gnuplot demos>. However the System Exec VI doesn't allow for successive command line calls. So to execute the totality of what was needed in gnuplot, I created a script containing all the commands needed for my application. Then using the System Exec VI I could call gnuplot to execute the script. The extension of "p" is totally random. The script just needs to be a text file following the instructions on gnuplot homepage.
Using the following LabVIEW code I was able to execute the script via gnuplot to create the desired PNG.
Progressing with more complicated features in gnuplot I was able to create some nice plots dynamically by opening and editing the script at run time to insert new data sets and labels. An example...
Update:
I had successfully loaded Gnuplot on a 9033 which has a 64 bit architecture. The gnuplot package was included in the opkg update from NI. However I now have a 9066 which is an ARM and Gnuplot is not listed in the feed. I forced the feed to the x64 and of course it won't load becuase it is not comptaible with the ARM architecture.
Searching on the internet I found an uncompiled packgae of gnuplot 'gnuplot-4.4.1.tar.gz'. I moved it to the target and tried to compile. But had problems compiling since I didn't have a proper compiler loaded on the 9066. To address this I found another NI forum post https://decibel.ni.com/content/thread/20236?start=15&tstart=0 and someone in there pointed out that gcc, etc. wouldn't have all the dependencies, and suggested
opkg update
opkg install packagegroup-core-buildessential
After doing this I downloaded the extracted the gnuplot-4.4.1.tar.gz to the lvuser folder and then was able to use
./configure
make
make install
Eventhough I was able to get gnuplot to compile directly on the target, I found that it was missing some libraries required to use the PNG terminal. After some digging around on the internet I found that I needed 'libgd' which is a support library for graphics drivers. Before I could use libgd properly I needed to compile another library called 'libpng', which went smoothly using "./configure", "make", "make install".
However when I went to compile the 'lingd' I noticed that the PNG library wasn't loading properly. To finally get it working properly I had to force the libpng location.
admin@NI-cRIO-9066-030c6c27:/home/lvuser# cd /home/lvuser/libgd-2.1.1
admin@NI-cRIO-9066-030c6c27:/home/lvuser/libgd-2.1.1# ./configure
** Configuration summary for libgd 2.1.1:
Support for Zlib: yes
Support for PNG library: no
Support for JPEG library: no
admin@NI-cRIO-9066-030c6c27:/home/lvuser/libgd-2.1.1# find / -name libpng
/home/lvuser/libpng-1.6.21/projects/vstudio/libpng
admin@NI-cRIO-9066-030c6c27:/home/lvuser/libgd-2.1.1# ./configure --with-png=/usr/local/
** Configuration summary for libgd 2.1.1:
Support for Zlib: yes
Support for PNG library: yes
Support for JPEG library: no
Support for VPX library: no
Support for TIFF library: no
Support for Freetype 2.x library: no
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
admin@NI-cRIO-9066-030c6c27:/home/lvuser/libgd-2.1.1# make
admin@NI-cRIO-9066-030c6c27:/home/lvuser/libgd-2.1.1# make install
After success compile of 'libgd' it was time to recompile 'gnuplot'
admin@NI-cRIO-9066-030c6c27:/home/lvuser# cd /home/lvuser/gnuplot-4.4.1
admin@NI-cRIO-9066-030c6c27:/home/lvuser/gnuplot-4.4.1# ./configure
** Configuration summary for gnuplot 4.4.1:
gnuplot will be compiled with the following terminals:
Standalone terminals: yes (always builtin)
(canvas, cgm, corel, dumb, dxf, eepic, emf, emtex,
epslatex, epson_180dpi, epson_60dpi, epson_lx800, fig, gpic, hp2623A,
hp2648, hp500c, hpdj, hpgl, hpljii, hppj, imagen,
latex, metafont, metapost, mif, pbm, postscript, pslatex, nec_cp6, okidata,
pcl5, pstex, pstricks, qms, regis, svg, tandy_60dpi,
tek40xx, tek410x, texdraw, tgif, tkcanvas, tpic, vttek)
X Window System terminal: no (requires X libraries)
jpeg terminal: no (requires libgd with jpeg support)
gif terminal: yes (with animated gif)
png terminal: yes
(jpeg, gif and png terminals cannot use TTF fonts, requires libgd support)
admin@NI-cRIO-9066-030c6c27:/home/lvuser/gnuplot-4.4.1# make
admin@NI-cRIO-9066-030c6c27:/home/lvuser/gnuplot-4.4.1# make install
admin@NI-cRIO-9066-030c6c27:/# gnuplot
G N U P L O T
Version 4.4 patchlevel 1
last modified Fri Sep 10 12:10:34 PDT 2010
System: Linux 3.2.35-rt52-2.0.0f0
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help seeking-assistance"
immediate help: type "help"
plot window: hit 'h'
Terminal type set to 'unknown'
gnuplot> set terminal
Available terminal types:
canvas HTML Canvas object
cgm Computer Graphics Metafile
corel EPS format for CorelDRAW
dpu414 Seiko DPU-414 thermal printer [small medium large]
dumb ascii art for anything that prints text
dxf dxf-file for AutoCad (default size 120x80)
eepic EEPIC -- extended LaTeX picture environment
emf Enhanced Metafile format
emtex LaTeX picture environment with emTeX specials
epslatex LaTeX picture environment using graphicx package
epson_180dpi Epson LQ-style 180-dot per inch (24 pin) printers
epson_60dpi Epson-style 60-dot per inch printers
epson_lx800 Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...
fig FIG graphics language for XFIG graphics editor
gif GIF images using libgd and TrueType fonts
gpic GPIC -- Produce graphs in groff using the gpic preprocessor
hp2623A HP2623A and maybe others
hp2648 HP2648 and HP2647
hp500c HP DeskJet 500c, [75 100 150 300] [rle tiff]
hpdj HP DeskJet 500, [75 100 150 300]
hpgl HP7475 and relatives [number of pens] [eject]
hpljii HP Laserjet series II, [75 100 150 300]
hppj HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]
imagen Imagen laser printer
latex LaTeX picture environment
mf Metafont plotting standard
mif Frame maker MIF 3.00 format
mp MetaPost plotting standard
nec_cp6 NEC printer CP6, Epson LQ-800 [monocrome color draft]
okidata OKIDATA 320/321 Standard
pbm Portable bitmap [small medium large] [monochrome gray color]
pcl5 HP Designjet 750C, HP Laserjet III/IV, etc. (many options)
png PNG images using libgd and TrueType fonts
postscript PostScript graphics, including EPSF embedded files (*.eps)
pslatex LaTeX picture environment with PostScript \specials
pstex plain TeX with PostScript \specials
pstricks LaTeX picture environment with PSTricks macros
qms QMS/QUIC Laser printer (also Talaris 1200 and others)
regis REGIS graphics language
starc Star Color Printer
svg W3C Scalable Vector Graphics driver
tandy_60dpi Tandy DMP-130 series 60-dot per inch graphics
tek40xx Tektronix 4010 and others; most TEK emulators
tek410x Tektronix 4106, 4107, 4109 and 420X terminals
Press return for more:
texdraw LaTeX texdraw environment
tgif TGIF X11 [mode] [x,y] [dashed] ["font" [fontsize]]
tkcanvas Tk/Tcl canvas widget [perltk] [interactive]
tpic TPIC -- LaTeX picture environment with tpic \specials
unknown Unknown terminal type - not a plotting device
vttek VT-like tek40xx terminal emulator
xterm Xterm Tektronix 4014 Mode
gnuplot>
System Exec VI doesn't allow for successive command line calls.
You can separate mulitple command line operation with semicolon (you can do this in pretty much any command line context, and it works fine in System Exec also). For example a command line of "cat /proc/self/comm ; cat /proc/self/stat" works and the output of both cat commands appears in the standard output parameter of System Exec.
Thanks for the excellent update for those using the ARM-based controllers. The overall flow that you have documented is more or less the flow for building a moderately complex package on a NI Linux RT target directly (instead of using the OpenEmbedded build process, which is much more complex up-front but once prepared, it makes things like dependency management much easier).