Updating outputs inside case and sequence structures.
I am having problems creating a control program for a
solenoid that I am working on. (This control program is a small apart of
a much larger program)
There are three states that happen to turn on the solenoid.
1) The high current stage is turned on
2) Both current stages are turned on
3) The high current stage is turned off and the low current stage remains on until
turned off.
There is a state where the solenoid is off, both states turned off.
I made a Labview program that attempts to create these three states, using a
sequence and a case statement. (see attached) You can click on "request open" and see in "global_solenoid_current.vi"
that the switches operate properly and the low current LED does not turn off
until "request closed" is clicked. (I had to use global
variables in order for this bit of code to work in my main program) The global variables
update in the sequence, but they do not update the LED's on the front panel in the properly.
How may I allow these LED's to operate properly?
Again there are many constraints with this piece of code since it is in a
larger control program with an over-all while loop.
-I cannot put a permanent while loop around the solenoid control code since it exists within
another large while loop. If the smaller loop executes then the next iteration
of the main loop never occurs until the smaller loop ends.
-Also, one must be careful not to have one unstoppable sequence since it would repeat in every
iteration of the larger main loop.
-I tried a state machine, but that did not seem to work well. The sequence repeats over and over.
Attachments:
Solenoid_Control.zip 15 KB
You need to understand dataflow.
In your program, you only read the globals exactly once/call of the subVI and write the output to the LEDs of the program. Thus the indicators get updated exactly once at an undefined time with repect to the other code.
As a bandaid fix, you could remove the global variable reads and write to locals of the LEDs in the various frames where the LEDs need to change. Also don't do unecessary global reads and writes. For example, if both cases are False, you read a global, then write the just read value back within nanoseconds. This is a completely useless operation if you think about it. Right?
Somehow, the program does not feel right at all, but I would need to see the rest of the code for a final analysis. There has to be a better way to do this!
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Solenoid_ControlMOD.vi 35 KB
Similar Messages
-
Labview Crashes when adding case and sequence structures
I am running into a problem that I have never experienced before - when I am adding case and sequence structures to a version of code I am writing, Labview 6i crashes (i.e CPU allocation jumps to 95% on the task manager and hangs there) requiring an "end task". I am writing the code within XP Pro running on a 1.7 Ghz Pentium 4 machine with 512 MB.
The code is used to control valves and temperature controllers on a Noble gas analysis line and is fairly simple. There are multiple nested sequence (30 steps long) and case structures within a while loop. The code itself is around 1.9 MB, so given the speed and on-board memory of my machine I doubt that I am reaching and physical limit in terms of the memory or proce
ssing power required.
Has anyone ever seen something like this? Could the code have been corrupted by an email transfer? If so are there ways to recover? Any help would be greatly appreciated.Yes. At least to 6.0.2. Also, you might be able to fix the problem by doing a mass recompile of the directory that the vi resides in, this fixed a similar problem I had about a year ago. Just start Labview, but don't open any of the VIs in that program, then select Tools->Advanced->Mass Compile. I am not sure why it worked for me, but it did, I think it cleans up the code a bit.
Jon D
Certified LabVIEW Developer. -
Control references and sequence structures
My supervisor and I were discussing one of his programs, and he asked
me if I knew why he kept getting "Object reference is invalid" on a
property node that was using a reference. I couldn't figure it
out either, and eventually I said to try moving the actual control
itself (on the block diagram), into the first pane of the sequence
structure, and just feed the wire through.
This solved all of our problems... however both of us were
stumped with why what I suggested actually made it work. Anyone
know why this is?
Oops... I just realized that I made this on the breakpoint board
instead of the LabVIEW board...sorry. Although I suppose that the
people who frequent this might be the best to answer this...
Message Edited by Novatron on 07-14-2005 05:24 PMThere should be no difference between the two code versions IF you adhere to proper dataflow.
(Of course it is conceivable that the program is a mess and there is a race condition, e.g. if the reference is initially invalid and you set it elsewhere in the code via e.g. a local variable of the reference. In this case, a subtle change (e.g. the sequence structure) can rearrange the execution order for it to suddenly work by accident.)
I would be very curious to see a working example that demonstrates your described behavior.
LabVIEW Champion . Do more with less code and in less time . -
Creative Zen Touch - Sounds from inside case and firmwear not reload
the story:
I was sitting in my room when suddenly in the middle of a song, the music stoped, i go over to check. Nothing works, so i get a paperclip and reset it. After reset, it stays on Creative logo for 5 mins. While inside the case a sound like a motor going on, off and then a static kind of noise. I restart a third time and i get recovery screen. I do cleanup. then reboot. Then format, reboot, then firmwear deletion, reboot.
I head on over to the website and read FAQ's and such. I attempt to put the newly downloaded firmwear onto my Zen Touch. I click the file, it starts the instalation process and then says "An application is interfering with the flash program (e.g Creative file Manager)....." I would like to add, i've tried rebooting my computer, and i've turned off every single thing except for the instalation browser.
What should i do?
Message Edited by chris23 on 08-5-2006 06:49 AMI think your hard dri've has crashed. If the player itself is making a loud noise like that it's most likely the hard dri've. I'm not sure if reloading the firmware would solve this problem.
-
Update statement with CASE and banding
Hello Folks,
I am stuck and am going nowhere.
I have two tables
MinuteCategory
Minute
MinuteCategory
MinuteLookup
MinuteCategoryId (surrogate key)
MinuteLow
MinuteHigh
MinuteCategory
Sample from Minute Lookup table ..
1 1
15 <15 min
2 16
30 <30 min
3 31
45 <45 min
4 46
60 <60 minutes
5 61
75 <1 hour 15 minutes
I am trying to update the MinuteCategory column in the MinuteCategory table using the MinuteLookup table.
For example if the minute = 33 then the corresponding lookup value would be 3 (from the lookup table), because the
33rd minute falls in between 31 min and 45 min and the corresponding surrogate key is 3
Is this possible with an Update statement in SQL? The only thing i can think of is use case statement as the join key between
the two tables but i don't think it's going to work :(
UPDATE
SET MinuteCategory = ml.MinuteCategoryId
FROM MinuteCategory mc join MinuteLookup ml on mc.Minute =
CASE WHEN mc.Minute between ml.MinuteLow and ml.MinuteHigh THEN ml.MinuteCategoryId ELSE NULL
END
Would appreciate any help.
SSPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums.
>> I have two tables <<
Have you read any book on data, so you have some idea what a “<something>_category” means? THINK!! A minute is unit of temporal measurement. By definition, it cannot be a category.
There is no such thing as a “<something>_category_id”; a data element is a “<something>_category” or a “<something>_id”, as per basic data modeling.
Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton.
CREATE TABLE Timeslots
(slot_start_time TIME(1) NOT NULL PRIMARY KEY,
slot_end_time TIME(1) NOT NULL,
CHECK (start_time < end_time));
INSERT INTO Timeslots --15 min intervals
VALUES ('00:00:00.0', '00:14:59.9'),
('00:15:00.0', '00:29:59.9'),
('00:30:00.0', '00:44:59.9'),
('00:45:00.0', '01:00:59.9'),
('23:45:00.0', '23:59:59.9');
Here is the basic query for rounding down to a time slot.
SELECT CAST (@in_timestamp AS DATE), T.start_time
FROM Timeslots AS T
WHERE CAST (@in_timestamp AS TIME)
BETWEEN T.slot_start_time
AND T.slot_end_time;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
t.
If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
Thanks,
Karinne.I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
Stu -
Sequence structure and Latch action
Dear Sir or Madam,
I have a sequence with commands in each frame. Is there a way to have a
LATCH ACTION, between frames??.
Thanks in advance for your any help.
Sincerely,
Luis Diaz
[email protected]I would recomend that you get rid of the sequence structures and use a state
machine. A State machine will give you a much more powerful and flexible
program. Browse the example programs available at the Resource Library of
NI's Developer Zone zone.ni.com). There is even an example called Pause/Resume
& State Machine.
"Kevin B. Kent" wrote:
>Luis Diaz wrote>> Dear Sir or Madam,>>>> I have a sequence with commands
in each frame. Is there a way to have a>> LATCH ACTION, between frames??.>>>>
Thanks in advance for your any help.>>>> Sincerely,>>>> Luis Diaz>> [email protected]>>Not
quite sure what you mean here.>You can pause between each frame, there are
2 ways to do this.>Add a frame AFTER the frame to pau
se>1) put in a timer
(Wait MS) you can hardcode this wait or have>a value that the user can enter.>2)
put in a while loop and have a button to proceed, or use some sort of>logic.>>All
this will do is send the commands and then wait for the timer to expire>or
the loop to end.>>A more elegant approach is to use a state machine. This
is a combination of>a case structure inside of a while loop. You have much
more control over the>>sequence of events and it is much easier to read and
debug.>>Again all this will do is wait between cases (if setup that way)>>Using
the state machine you can have a case return to itself which>is esentially
a LATCH.>>There are samples of the state machine at various locations.>>Let
me know if you need more help> Kevin Kent> -
My problem is that outputs of two cases(of the same case structure) are used at the same time to get a new number.
For example, output of case 1 times 20 plus output of case 2.
How to implement it? Thanks.There is only one case active at the time, you can't have two cases at the
same time, it would be a contradiction to the Case-structure (e.g. a Boolean
is either true or false or unknown, but never two states at a time).
But that's more a question of philosophy.
I think I know what you want to do!
You have to execute your Case-statement several times and store your several
Case-Outputs. You should use a Case within a For oder While-Loop (For or
While depends depends on your iteration condition: Fixed times or variable).
Then wire the Case-Outputs to the Loop-Outputs and enable Auto-Indexing.
Store your values in an array and scale and add the array after you have
collected all the Case-Outputs.
Another solution is to use a Shift-register of the While
or For to create a
running sum of the cases.
Which one do you prefer ?
Oliver Friedrich
"haodage" schrieb im Newsbeitrag
news:[email protected]..
> My problem is that outputs of two cases(of the same case structure)
> are used at the same time to get a new number.
>
> For example, output of case 1 times 20 plus output of case 2.
>
> How to implement it? Thanks. -
I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order. Any ideas, I've been playing with the idea but have had no luck, is this even possible?
Hi,
Please check it out the attached Vi.. Is this you need?
Sasi.
Certified LabVIEW Associate Developer
If you can DREAM it, You can DO it - Walt Disney
Attachments:
Event.vi 11 KB -
Using Case and Joins in update statement
Hi all,
I need to update one column in my table...but need to use case and joins...I wrote the query and it is not working
I am getting an error msg saying...the SQL command not ended properly...
I am not that good at SQL...Please help...
update t1 a
set a.name2=
(case
when b.msg2 in ('bingo') then '1'
when b.msg2 in ('andrew') then '2'
when b.msg2 in ('sam') then '3'
else '4'
end )
from t1 a left outer join t2 b
on a.name1 = b.msg1 ;
Waiting for help on this...!
Thanks in Advance... :)Another approach is to update an inline view defining the join:
update
( select a.name2, b.msg2
from t1 a
join t2 b on b.msg1 = a.name1 ) q
set q.name2 =
case
when q.msg2 = 'bingo' then '1'
when q.msg2 = 'andrew' then '2'
when q.msg2 = 'sam' then '3'
else '4'
end;which could also be rewritten as
update
( select a.name2
, case q.msg2
when 'bingo' then '1'
when 'andrew' then '2'
when 'sam' then '3'
else '4'
end as new_name
from t1 a
join t2 b on b.msg1 = a.name1 ) q
set name2 = new_name;The restriction is that the lookup (in this case, t2.msg1) has to be declared unique, via either a primary or unique key or unique index.
(You don't strictly need to give the view an alias, but I used 'q' in case you tried 'a' or 'b' and wondered why they weren't recognised outside the view.) -
Wiring inputs n outputs for case structure
Hi everyone...
I have a simple basic question...How to wired the correct tunnel for output in case structure.Because when I try to wire the build array to the case structure, It shown as white terminal....How how to make solid color terminal for output tunnel...Actually I forgot how to wire it correctly..so...I hope u guys can remind me again...thank u very much...
Attachments:
Cepat21.vi 43 KBHi Altenbach...
Thank u very much for ur
help.I'm always make a careless mistake.thanks to u guys.Now,I'm be able to display my
data into table something like attachment below.Actually I'm using IIOA
to parse the value into string...something like that...
V = 238.25 I = 23.82 P = 5676.12
V = 237.79 I = 23.78 P = 5654.28
V = 237.35 I = 23.74 P = 5633.54
V = 236.94 I = 23.69 P = 5614.09
V = 236.56 I = 23.66 P = 5596.12
V = 236.22 I = 23.62 P = 5579.80
V = 235.91 I = 23.59 P = 5565.29
V = 235.64 I = 23.56 P = 5552.72
V = 235.42 I = 23.54 P = 5542.22
V = 235.24 I = 23.52 P = 5533.88
V = 235.11 I = 23.51 P = 5527.78
V = 235.03 I = 23.50 P = 5523.98
V = 235.00 I = 23.50 P = 5522.52
V = 235.02 I = 23.50 P = 5523.40
V = 235.09 I = 23.51 P = 5526.62
V = 235.21 I = 23.52 P = 5532.16
V = 235.37 I = 23.54 P = 5539.95
V = 235.58 I = 23.56 P = 5549.92
V = 235.84 I = 23.58 P = 5561.99
Then I try to convert this string into numeric or dbl coz I want to
merge it with signal.So, it looks like complicated like u imagine.
Now,I have one other question.refer to my vi, I have used elapsed time
so that it will run from the start time until target time.But its only
can be determined in seconds.So, how can I modify it with using elapsed
time for day.I mean this prog will start on Monday for example n stop
at wednesday.It means it will run for 3 days...thank u very much...
Attachments:
build table1.PNG 36 KB
Cepat2122.vi 165 KB -
i updated my i pad with ease then updated my i phone and now apple does not recognise the i phone and then says there is no sim in the phone when there is one installed, can anyone help
See Here > http://support.apple.com/kb/HT1808
You may need to try this More than Once...
But... if the Device has been Modified... this will Not necessarily work. -
Shake the G5 case and listen to the coolant swoosh inside the LCS . . .
So I have a new G5 PPC with dual 2.7 & lcs
I'm familiar with them having reworked one already
This one has no signs of cyrstlization on the cpus (as seen with flash light . . havent removed the system yet)
No signs of water leakage on the pad etc . . .
Works great so far
However . . .
I pick up the case and shake it around lighlty and hear the cooling fluid swoosh around . . .
Is this normal or does it indicate the lcs system has already lost some fluid enough to swoosh around noisily like this?
Anyone else have a unit that does this?Im the original poster.
FInally removed the LCS
Its labeled as a panasonic and has 2 pumps
As I have it now I can turn it upside down and around and still notice the water noise
Again I would have thought these are filled to pressure and that there would be no water noise
Maybe I'm being to critical? I'm not sure
Is the slightest noise from these unacceptable?
There are no signs of leaks
Is there a danger of running it this way?
There are copper tubes at the top, so I imagine any air or vacumm would be at the top?
and nowhere near the cpu area?
What do I need to know in case I put off re-filing the unit for the time being? -
DAQ Assistant in subvi not updating output to DAQ board with each call...
Hi All,
I am calling a simple subvi that creates a user-defined number of pulses with "Square Waveform.vi." This square wave (with the given total number of pulses) is then used as an input to a DAQ Assistant controlling an analog output signal on a NI USB-6259 DAQ board. I am using Labview 8.5 right now.
However, each time I call this subvi from my main program, the output I measure from the DAQ board is identical to whatever I set in the first call (i.e., if i created two pulses in the first call, I get two pulses on every call, regardless of the input I feed to the subvi). The multiple calls to this subvi are made in sequential frames in a stacked sequence. I believe stacked sequences are frowned upon by good labview people, right? But putting that aside for the moment...
The "#-of-pulses" input I give to the subvi is updated in a subvi front panel number indicator and a graph of this waveform. Just not in the real output I measure from the board. Why is the hardware output being asserted (with the original input value) before this new number can reach the DAQ Assistant?
The sloppy fix to this is just to put that square wave creation code in my main program each time I need it. This does work and fixes my problem. However, I would like to use subvis to keep things clean.
I am not a good Labview programmer, but have used this software for a number of projects and am stumped by this. Any ideas?
Thanks,
JohnHi John,
I am running your code over here and seeing
the same results. I believe the problem is that the DAQ Assistant is
being called inside a loop (really a sequence structure, but
nonetheless more than once). Sometimes it is difficult to troubleshoot
the DAQ Assistant in cases like this--it is trying to be "smart" and
seems to be avoiding re-configuring its parameters inside the loop.
This is intended to improve loop speed for when customers are
performing continuous operations. In this case, it is performing a
finite generation, and the number of samples generated appears to carry
over from one loop iteration to the other.
It sounds
like you have discovered one workaround for this already: putting a DAQ
Assistant in each frame of the main VI. Two other options that come to mind are:
Use the lower-level DAQmx functions inside
the sub VI. Here you will have explicit control over when the task is
created and cleared, and when parameters are set. You can find
examples of how to use the DAQmx API in the Example Finder at:
Help >> Find Examples... >> Hardware Input and Output >> DAQmx
Write
a consistent amount of samples to the DAQ assistant by "zero-padding"
your signal. For example, instead of writing [10, 1010], try writing
[1000, 1010]. In this case, it wouldn't need to reconfigure the number
of samples to generate.
One lesson to take away here is
that the DAQ Assistant is good for basic functionality, but for more
advanced control over the execution and configuration of your task you
should learn to use the lower-level DAQmx functions. In this case it
sounds like the problem is actually a bug. I'll file a bug report, since the DAQ
Assistant is not checking for waveform timing changes even though your
timing is set to Use
Waveform Timing.
Thank you for pointing out this odd
behavior--out of curiosity which version of DAQmx are you using?
-John
John Passiak -
Can you move back to a previous frame in a sequence structure?
I have a VI that contains a sequence structure with seven frames. I would like to add a button on the front panel to allow the user to move back to the previous frame. Is this possible?
ThanksI don't think that's possible. Try replacing the sequence structure with a
state machine.
A state machine is a case statement embedded in a while loop. Each case
outputs at least an integer to indicate the next case to be executed and a
boolean to indicate if the while loop should continue. The integer is wired
to a shift register. The input side of the shift register is wired inside
the while loop to the conditional terminal of the case statement. Outside
of the while loop, the input side of the shift register would be wired to a
constant indicating the first case to be executed.
To mimic a sequence structure, each case would take the incoming integer and
increment it by one. To move back to the previous frame, the integer would
be decremented instead.
"Jeff - PP
L" wrote in message
news:[email protected]..
> I have a VI that contains a sequence structure with seven frames. I
> would like to add a button on the front panel to allow the user to
> move back to the previous frame. Is this possible?
>
> Thanks
Maybe you are looking for
-
DB Connect DataSource PSA records and DSO records are not matching...
Dear All, I'm working with SAP NetWeaver BW 7.3 and for the first time, I have loaded from Source System DB Connect. I have created a DataSource and pulled all records and found 8,136,559 records in PSA. When I designed and created DSO with Key Field
-
Dw keeps crashing. other applications also, except for acrobat.
i am using DW cs4, the error message: ordinal number 3765 could not be located in digital library link LIBEAY32.dll DW keeps crashing, and so does my PS and SB. only DW has an error message. What should I do?
-
Why won't YouTube play my Apple TV? It just displays a constant loading circle.
I've seen this question asked before with no replies. Does anyone know? I have subscriptions that play fine on my iMac, iPad, iPad Air and iPhone, but in the last couple of months I only get the loading circle on my AppleTV. Thanks.
-
Reg SRM 7.0 BP integration into Portal
Hi Experts, I have integrated SRM 7.0 BP into Portal. I have got all the business content provided by SAP. But, I am unable to view the preview of many iViews provided with the business content after the Busines Package integration. Wheneven I am try
-
Zen Micro Photo 6Gb .. When Will It Be In Canada.
<FONT color=#ff0099>hi... i was wondering if anyone knows when.. the zen micro photo will be for sale in canada... <FONT color=#ff0099>hope someone can help me out with this!!! <FONT color=#ff0099>please leave a message/comment... if you know anythin