From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing Data ; Array?

Solved!
Go to solution

Hi guys i need help!

So i have a program that will detects an analog input(5v) and proceed to do an action.

The problem i'm facing is that when i apply a 5v while the program is running half-way it will not be able to detect the 5v , it will only detect when i apply it when the program is running at the point of my DAQassistant5 (analog input; i see it with Highlight Execution).

Basically it works as a "live-time detection" thing, what i want to achieve is that whenever i press the switch button(applying analog input 5v) it will detect it and run the action next time the program re-runs it (my program runs in a while-loop).

I read up on array functions but still unsure of which one to use and also not sure if array is the right choice to go.



*i attached the vi. , take a look at the DAQassistant5 part !

0 Kudos
Message 1 of 17
(4,249 Views)

Hi,

 

Whether you need to acquire data continuously or when ever you want you will trigger the data.

Whether your code needs to check voltage value every time and need to take action or it has to check voltage at initial stage and based on that you need to continuously perform you action.

 

If Continuos data acquisation is needed, try to Read the voltage in a separate thread and Pass the value to the Action Thread.

0 Kudos
Message 2 of 17
(4,197 Views)
Solution
Accepted by topic author Roamingburger

@Roamingburger wrote:

Hi guys i need help!

So i have a program that will detects an analog input(5v) and proceed to do an action.

The problem i'm facing is that when i apply a 5v while the program is running half-way it will not be able to detect the 5v , it will only detect when i apply it when the program is running at the point of my DAQassistant5 (analog input; i see it with Highlight Execution).

Basically it works as a "live-time detection" thing, what i want to achieve is that whenever i press the switch button(applying analog input 5v) it will detect it and run the action next time the program re-runs it (my program runs in a while-loop).

I read up on array functions but still unsure of which one to use and also not sure if array is the right choice to go.



*i attached the vi. , take a look at the DAQassistant5 part !


Hi
 

I suggest to go for queue architecture,  since DAQ acquisition has to be placed in seperate thread. so that it will keep acquiring the data.

I done few changes in your code. but it need more work. I hope you will be doing it. 

1. Try to use Event structure for User Interaface related stuffs. 

2. Dont run your loops continuous without need since it will take your process.

3. If your DAQ is supporting Digital Input go for it since you need only 0 or 1 . analog sampling is not required.

4. Try using DAQmx. Express VI is ok but DAQmx will alow you to do more stuffs.

5. Error Handle is needed if wrong password or wrong username is given popup saying reenter ...

6. and so on.

 

Happy Programming.

Kindly go through the attachment. Once again you need to do more fix in this code. I just started it.

Thanks & Regards

Varaprasath M
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 3 of 17
(4,174 Views)

@Varaprasath wrote:

@Roamingburger wrote:

Hi guys i need help!

So i have a program that will detects an analog input(5v) and proceed to do an action.

The problem i'm facing is that when i apply a 5v while the program is running half-way it will not be able to detect the 5v , it will only detect when i apply it when the program is running at the point of my DAQassistant5 (analog input; i see it with Highlight Execution).

Basically it works as a "live-time detection" thing, what i want to achieve is that whenever i press the switch button(applying analog input 5v) it will detect it and run the action next time the program re-runs it (my program runs in a while-loop).

I read up on array functions but still unsure of which one to use and also not sure if array is the right choice to go.



*i attached the vi. , take a look at the DAQassistant5 part !


Hi
 

I suggest to go for queue architecture,  since DAQ acquisition has to be placed in seperate thread. so that it will keep acquiring the data.

I done few changes in your code. but it need more work. I hope you will be doing it. 

1. Try to use Event structure for User Interaface related stuffs. 

2. Dont run your loops continuous without need since it will take your process.

3. If your DAQ is supporting Digital Input go for it since you need only 0 or 1 . analog sampling is not required.

4. Try using DAQmx. Express VI is ok but DAQmx will alow you to do more stuffs.

5. Error Handle is needed if wrong password or wrong username is given popup saying reenter ...

6. and so on.

 

Happy Programming.

Kindly go through the attachment. Once again you need to do more fix in this code. I just started it.



Thanks for the help and advices Varaprasath!!

I actually changed the analog input to Digital input(and that actually solved one of my problem:having random voltage detected at times ).

 

But still one problem for me is that my DAQasssistant will not send the value(1) when pressed while the program is running half-way and i'm not sure how the queue architecture can help on this issue.(i read up on the LABview Help already)

0 Kudos
Message 4 of 17
(4,100 Views)

Did you gone through the code which I attached in previous message.

 

also check this What is Queue ?

 

 

Thanks & Regards

Varaprasath M
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 17
(4,082 Views)

@Varaprasath wrote:

Did you gone through the code which I attached in previous message.

 

also check this What is Queue ?

 

 


Yea i did went through the code you attached, and tried it out but doesn't seems to work(i tried pressing the switch button once at a random time and waited for it but there's no logic 1 detected)
Or do i have to touch up on the queue connections?

and thanks for helping, appreciate it !

 

0 Kudos
Message 6 of 17
(4,047 Views)

@Roamingburger wrote:

@Varaprasath wrote:

Did you gone through the code which I attached in previous message.

 

also check this What is Queue ?

 

 


Yea i did went through the code you attached, and tried it out but doesn't seems to work(i tried pressing the switch button once at a random time and waited for it but there's no logic 1 detected)
Or do i have to touch up on the queue connections?

and thanks for helping, appreciate it !

 


 

 

 

 

 

 

 

Q.png

 

Try to understand how Q Works, It will be easy for you to complete your task.

you can drag and drop this code Snippet into your block diagram.

Thanks & Regards

Varaprasath M
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 7 of 17
(4,024 Views)

Missed DAQmx clear Task. Handle the error in such a way that clear task and Q Destroy should happen even if their is an internal error occurance. I left that part for you.

Q2.png

Thanks & Regards

Varaprasath M
Certified LabVIEW Architect
Certified TestStand Architect
Message 8 of 17
(4,019 Views)

Hi Roaming,

 

I'm not familiar with your express VI, but it looks like you should be on the right track. A couple of points:

  • Boolean Crossing PtbyPt should be initialized, otherwise you may miss the first button press.
  • Are you sure that the DAQ assistant outputs 5-5.99V when it is high? It won't output something like 4.93V? I would change the range to be larger if it is just high-low data.
  • Depending on how fast the loop is running, is it possible that a button is pressed and depressed before the data is read? This would result in a missed button press as well.
0 Kudos
Message 9 of 17
(3,976 Views)

Hi Varaprasath

 

when i'm using the DAQ Digital i/o sometimes it detects logic1 even when i did not press the button but it doesn't happen when i'm using DAQassistant, 

is that a problem with my hardware or something else?

 

edit: i disconnected my hardware from myDAQ but it still shows logic1 at times 

0 Kudos
Message 10 of 17
(3,935 Views)