I am trying to control a KEITHLEY 2612A SourceMeter using labview. I have installed the appropriate drivers and I managed to connect to the instrument using VISA. Currently I am just experimenting with the scripting language, which the instrument uses.
Is it possible to use a Numeric Controller - a Knob for example - and use its value in the script to be loaded to the instrument? I don't have enough reputation points to add images.
EDIT
ON = 1
OFF = 0
function hello()
display.clear()
display.setcursor (1,7)
display.settext ("DONE :)")
end
smub.reset()
smub.source.output = ON
--Set the measurement integration time
smub.measure.nplc = 1
smub.measure.delay = 0.05
--Configure the reading buffers
smub.nvbuffer1.clear()
smub.nvbuffer1.appendmode = 1
smub.nvbuffer1.collecttimestamps = 1
smub.nvbuffer1.collectsourcevalues = 0
smub.nvbuffer1.fillmode = smub.FILL_ONCE
for i = 0, 0.5, 0.01 do
smub.source.levelv = i
reading = smub.measure.i (smub.nvbuffer1)
end
delay(5)
hello()
smub.source.output = OFF
delay(1)
display.clear()
display.setcursor(1,1)
display.settext(string.format("%g", smub.nvbuffer1[1]))
delay(5)
display.clear()
display.settext(string.format("%g", smub.nvbuffer1[50]))
Block diagram: http://i.imgur.com/pgu0ous.png
Front panel: http://i.imgur.com/DuHUdpo.png
LabVIEW has standard string manipulation primitives, and you can accomplish your goal by using string substitution: place a sentinel string in your script and replace it with the value from the knob.
Example
Here, I've used __BUFFER_NUMBER__ as a unique string in the Script Format input terminal. LabVIEW searches for that string and replaces it with the knob's current value.
Block diagram
You add the knob control, wire the value to the number-to-string VI (http://zone.ni.com/reference/en-XX/help/371361M-01/glang/number_to_fract_string/
), and wire that to the "Search and replace string VI" (http://zone.ni.com/reference/en-XX/help/371361M-01/glang/search_and_replace_string/) you search for the value in the script that you want to replace.
Related
I would like to write a Gatan DigitalMicrograph script to acquire multiple EELS spectrum images continuously. If there is a command to obtain Spectrum Image (SI) data, and store the three-dimensional image to an array, I will achieve my plan. However, I could not find appropriate commands for SI imaging mode from reference manual. What command should I use in this case? Do you have a helpful knowledge for my purpose? It will be appreciated if you share some wisdom.
A short demo-script of how to use the SIAcquisition commands for multiple iterations of SI acquisition and "renaming" the acquired data sets.
// Assumptions:
// - GMS 2.3 used
// - Valid survey image and ROI already assigned
// - SI array size already defined
// - Signals and other SI settings made
number SIx, SIy
SIGetFieldValue( "2D Array, X samples", SIx )
SIGetFieldValue( "2D Array, Y samples", SIy )
Result("\n SI size:"+ SIx + "x" + SIy )
// Start SI
number nSI = 3
for (number i=0; i<nSI; i++ )
{
SIInvokeButton( "Start/Stop", 1 )
while(SIIsAcquisitionActive()) yield()
sleep(0.5) // Small delay needed to allow DM finish SI acquisition clean-up
// Find (and rename) SI DataSets
number nImgDoc = CountImageDocuments()
string findStr = "Spectrum Image"
for (number d=0; d<nImgDoc; d++ )
{
string docName = GetImageDocument(d).ImageDocumentGetName()
if ( find(docName,findStr) == (len(docName)-len(findStr)) )
{
GetImageDocument(d).ImageDocumentSetName( docName + "#"+(d+1) )
}
}
}
OKDialog( "Done" )
If you have the spectrum-imaging plugin installed, then the F1 help file will have a section on STEM SI scripting commands here...
However, the commands described there will allow the acquisition of one SI after the other. Each will start anew with the same overhead you get when repeatedly starting SI acquisition via the UI.
I've got the impression you want to get a "faster" repeated SI.
Unfortunately, no commands exist which could easily give you that.
However, you might be able to create a "work-arround" solution by the following idea (untested):
Set up a STEM SI with multiple-frames (Each frame pass will be summed into the same container)
Use the "SI HookUP Scripts" on a per-pixel basis (Pixel end) to catch the "last" acquired SI point (before the new frame starts). Use this to copy the existing data into a new container and set the orignal back to zero.
Alternative:
You might also be able to use the "Correction start" HookUp script point, if you set spatial drift-correction to perform at end of frame...
The above will only work with software-synchronized SI's. For hardware-synchronized, it becomes more tricky, but you might be able to do something similar with a "ImageUpdate" event-listener.
I have tried all of below snippets to use Python Parser in Field Calculator and update the values of a field called type based on a filed called MamerMN but in all of them I am getting Syntax error in Geoprocessing result window!
if !MamerMN! <= 0.151560:
return 1
and
if (!MamerMN! <= 0.151560):
return 1
and
if (MamerMN <= 0.151560):
return 1
and
def(MamerMN)
if MamerMN <= 0.151560:
return 1
and
def(MamerMN)
if (MamerMN <= 0.151560):
return 1
Can you please let me know what I am doing wrong?
You are writing your functions wrong. In the Field Calculator, make sure you check 'Show Codeblock' so the Pre-Logic Script Code box appears. Inside the Pre-Logic box, write your function-
def calcValue(mamerMN):
if mamerMN <= 0.151560:
return 1
and then in the box under, where it says the field_name =
you should write the name of the function and the field value you are passing to it surrounded by exclamations. So if your function above is named calcValue you would write
calcValue(!mamerMN!)
Without seeing a graphic of what your Field Calculator looks like, I suspect #csterling is probably right. However, an alternative is to just Select by Attribute where "mamerMN" <= 0.151560, then Field Calculate your selected features to 1 the regular way without necessitating a codeblock.
i would like to read some images with scilab and i use the function imread like this
im01=imread('kodim01t.jpg');
im02=imread('kodim02t.jpg');
im03=imread('kodim03t.jpg');
im04=imread('kodim04t.jpg');
im05=imread('kodim05t.jpg');
im06=imread('kodim06t.jpg');
im07=imread('kodim07t.jpg');
im08=imread('kodim08t.jpg');
im09=imread('kodim09t.jpg');
im10=imread('kodim10t.jpg');
i would like to know if there is a way to do something like below in order to optimize the
for i = 1:5
im&i=imread('kodim0&i.jpg');
end
thanks in advance
I see two possible solutions using execstr or using some kind of list/matrix
Execstr
First create a string of the command to execute with msprintf and then execute this with execstr. Note that in the msprintf conversion the right amount of leading zeros are inserted by %0d format specifier descbribed here.
for i = 1:5
cmd=msprintf('im%d=imread(\'kodim%02d.jpg\');', i, i);
execstr(cmd);
end
List/Matrix
This is probably the more intuitive option using a indexable container such as list.
// This list could be generated using msprintf from example above
file_names_list = list("kodim01t.jpg", "kodim02t.jpg" ,"kodim03t.jpg");
// Create empty list to contain images
opened_images = list();
for i=1:length(file_names_list)
// Open image and insert it at end of list
opened_images($+1) = imread(file_names_list[i]);
end
The code below hides the text "helloworld" in the two specified DWT coefficients using steganography. I have been trying to adapt the code to hide data contained in a .txt file. I have been working on this for a while but cant seem to get anything to work correctly. Can anyone help please?
clear all;
close all;
dataToHide = 'helloworld';
wavename = 'haar';
data = zeros(1,length (dataToHide));
for i =1 : length(dataToHide);
d = dataToHide (i)+0;
data (i) = d;
end
im=imread ('cameraman.tif');
%imshow(im);
[cA1, cH1,cV1, cD1]= dwt2(im,wavename);
A1 = upcoef2('a',cA1,wavename,1);
H1 = upcoef2('h',cH1,wavename,1);
V1 = upcoef2('v',cV1,wavename,1);
D1 = upcoef2('d',cD1,wavename,1);
subplot(2,2,1); image(wcodemat(A1,192));
title ('A1');
subplot(2,2,2); image(wcodemat(H1,192));
title ('H1');
M=max(data);
normilize = data/M;
n=length(data);
cH1 (1,1) = -1*(n/10);
cH1 (1,2) = -1*(M/10);
[~ , y] =size(cH1);
for i = 1 : ceil(n/2)
cV1 (i,y) = normilize(i);
end
for i= ceil(n/2)+1 :n;
cD1 (i,y) = normilize(i);
end
Update
I can know read text from the file.However, I have come across another problem. When I read from file I want to convert the text to binary (name=dec2bin(dataToHide). The above code doesn't want to hide binary data for me?? I am very new to matlab & steganography/watermarking. I have been doing lots of research regarding LSB embedding in the discrete wavelet transform. However, the code above, which I took from the web is manipulating subband coefficients, but from what I can read from the code it is not doing it by LSB replacement. (i.e replace LSB of cover image with MSB of the secret data file). Can anyone recommend some code for me to look at that works by LSb wavelets embedding?
I must admit it's been a few years since my RegEx class and since then, I have done little with them. So I turn to the brain power of SO. . .
I have an Excel spreadsheet (2007) with some data. I want to search one of the columns for a pattern (here's the RegEx part). When I find a match I want to copy a portion of the found match to another column in the same row.
A sample of the source data is included below. Each line represents a cell in the source.
I'm looking for a regex that matches "abms feature = XXX" where XXX is a varibale length word - no spaces in it and I think all alpha characters. Once I find a match, I want to toss out the "abms feature = " portion of the match and place the code (the XXX part) into another column.
I can handle the excel coding part. I just need help with the regex.
If you can provide a solution to do this entirely within Excel - no coding required, just using native excel formula and commands - I would like to hear that, too.
Thanks!
###################################
Structure
abms feature = rl
abms feature = sta
abms feature = pc, pcc, pi, poc, pot, psc, pst, pt, radp
font = 5 abms feature = equl, equr
abms feature = bl
abms feature = tl
abms feature = prl
font = 5
###################################
I am still learning about regex myself, but I have found this place useful for getting ideas or comparing what I came up with, might help in the future?
http://regexlib.com/
Try this regular expression:
abms feature = (\w+)
Here is an example of how to extract the value from the capture group:
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
Regex regex = new Regex(#"abms feature = (\w+)",
RegexOptions.Compiled |
RegexOptions.CultureInvariant |
RegexOptions.IgnoreCase);
Match match = regex.Match("abms feature = XXX");
if (match.Success)
{
Console.WriteLine(match.Groups[1].Value);
}
}
}
(?<=^abms feature = )[a-zA-Z]*
assuming you're not doing anything with the words after the commas