09-07-2010 09:41 AM
I have 2 different VI's that work perfect seperately but combined not so much. I am using the USB-6009 to send a digital out to control pneumatic cylinders. The other VI uses can messages to tell me which buttons are being closed. How can i redesign my VI to control say "Buttons 1-3 and it wont move on to buttons 4-6 until it recieves the message that buttons 1-3 have been pushed?" This way i can shut down the test if buttons stop working or something breaks. It sounds easy enough to do
Solved! Go to Solution.
09-08-2010 08:41 AM
Hi chris12345,
Can you post a screenshot or your code to help visualize your situation a little better?
Regards,
09-08-2010 08:46 AM
I want to run the first daq assistant, then read the can bus, and then just repeat this cycle until the loop is finished. I am running the test 250,000 times once i get a whole loop finished and its workinig great.
09-08-2010 09:11 AM
Hi chris12345,
You should definiately consider a state machine. This will provide you the most flexibility and scaliability. Post back if you have questions!
Regards,
09-08-2010 10:05 AM
Hey Dustin,
I tried the state machine and it just stays in the first state and doesnt go to the next one. The whole idea behind this is that the first state makes all the cylinders retract, then next state makes 3 engage and hit 3 different switches. The next state waits for the CAN message to show the 3 were pressed, then engages the next 3 and so on. I do appreciate your help but I am a hardware guy, not so much a software guy. Everything else works except the labview part, ha. I took the first daq assistant out of the state machine, but in the state machine the daq assistant runs before the can message is called. I attached the first 3 states and let me know what else i can do to make this work?
09-08-2010 10:19 AM
Hi chris12345,
In your state machine you want to define a state for each action that needs to take place. It looks like you have done this. What you need to do next is tell the state machine upon exiting a state what the next state it needs to go to by writing the approprite state to your shift register. This way you can control on a per state basis what the next state should be. If you take a closer look at the example I posted you will see that you can even make decisions and go to a specific state based on some condition that you define within the state.
You can download this example to see more how the state machine works. I reccomend running it in highlight execution mode. Using this button in LabVIEW.
Let me know how this goes!
Regards,
09-08-2010 11:16 AM
Great now i am getting a framing issue once the pneumatics engages, i try to read the can and i get error 1073807253 or 1073807252. I took the next step out, which in the case structure, would be 1 because i still could not get it to switch during the cycle. Where do i need to tell it specifically to go in order?
09-08-2010 11:23 AM
Hi chris12345,
This is what it look like in the example I linked to in the last post.
The shift register saves a value from the last iteration of the while loop. Here you are telling the state machine to to go to the Stop state on the next iteration. The reason you are not moving states is because you have wired your shift register straight through your loop so your next state value never changes. Were you able to run the example I posted in highlight execution mode?
Regards,
09-08-2010 11:34 AM
I couldnt run it because of an error, but when i use this shift register if only stays at that value i put in. Im getting so frustrated i am not thinking i guess. If i put a 1 in the first case it goes to case 1, if i put in a 0 for the 1st case it never goes to 1 after 0 has finished
09-08-2010 03:32 PM
hey chris12345,
you should wire the first case you want to run when the VI runs to your left-most shift register. Then inside the case, you need to break the wire and create a constant for the next case you want to run.
for instance,
if you want to run "0" when you start, wire a constant "0" to the left-most shift register, then
inside the case structure, place another constant "1" and wire that out to the right-most shift register.
you will see that case "0" runs then it will attempt to run case "1"...
and so on and so forth.
does that help?
-gaving