LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

controlling digital io

Im new to this so this may be a silly question. I have 3 8 bit ports I want to be able to turn each bit on and off in sequence I cannot find an easy way to do this. I thought I could do something like using a for loop index to tell a daq component what bit to turn on but im having no luck. could someone please point me in the right direction on how to do this. Thanks
0 Kudos
Message 1 of 11
(3,634 Views)

Not sure what you mean....

you mean turn bit 1 on then off, then turn bit 2 on then off?

Or turn bit 1 on, then 2, then 3, etc... THEN turn 1 off, 2 off, 3 off, etc...

________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 2 of 11
(3,633 Views)
Turn bit 1 on then off, turn bit 2 on then off, turn bit 3 on then off and so on
0 Kudos
Message 3 of 11
(3,629 Views)

I think 2 for loops would work. The outer for loop set to 8 interations (numbers of bits) and the inner set to two (on, off). Inner loop would use a shift register initilized to ON, then flip it to OFF on the next interation.

Used in a sub VI called three times.

 

________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 4 of 11
(3,620 Views)
You can use one loop, Wire a 1 to a shift register.  on each loop, use the rotate function to rotate the bit through the bitfields.  Then either convert the number to an array of bools, or if your device supports it write the value directly to the port......


Message Edited by tartan5 on 04-22-2008 11:28 AM

Message Edited by tartan5 on 04-22-2008 11:29 AM
Download All
0 Kudos
Message 5 of 11
(3,601 Views)
If you want to independly control each DI/DO, you can use lines instead of ports. A port consists of 8 or 32 lines.
That`s done where you create your task, e.g. on for each line (so you have 32 tasks instead of 3).

Felix
0 Kudos
Message 6 of 11
(3,576 Views)
First off I appreciate all of your responses. Please excuse my apparent lack of knowledge with this software. In the software I used to use I could do what I want with two function blocks but since it has been discontinued Im trying to switch over to labview. Let me explain what I want to do in more detail. I am using a DAQcard-DIO-24 to control 6 solenoids which fire air cyclinders to press buttons on a remote control. I want to turn on bit 1 for 1 sec then turn it off, turn on bit 2 for 1 sec and turn it off and so on pressing each button one at a time. I tried to use the daq assistant and set it up for 6 digital lines out. when I try to feed anything in on the data input I get the error the the number of tasks dont match the channels in the data.
0 Kudos
Message 7 of 11
(3,544 Views)

Hi Vmrak,

Perhaps you could post your vi?

Also, just for clarification, are you saying bit 1 on 1 second, all off 1 second, bit 2 on 1 second, all off 1 second; OR

Bit 1 on 1 second, then bit 1 off and bit 2 on 1 second, then bit 2 off and bit 3 on 1 second......

In other words do you need all bit to go off before you turn a new bit on?

 

0 Kudos
Message 8 of 11
(3,537 Views)
I guess, you configure with the assitant 1 Sample (on demand), that's what I tried with my own hardware. Then your assistant will have a data input that requires an array of boolean. As you just have a single line, this array should contain only one element.
Additional tips: You can simply copy the assistant for switching off after 1 sec. In that case the easy way is to use a flat sequence with a wait 1000 in the middle frame. The nicer way would be a delay as in the OpenG-Tools and using the error wires data flow for that.

Felix
0 Kudos
Message 9 of 11
(3,532 Views)
I cant post it right now im not at my work station. and it is your second case bit 1 on one second then turn off,  bit 2 on one sec then turn off I am just pressing each button momentarilly in sequence. Maybe where I am lost is in controlling the daq assistant I have it setup for 6 digital outputs but I dont understand what I have to put in the data input to turn on each output individually. When I use the daq assistant test function I can turn on the outputs so I know my hardware is ok.
0 Kudos
Message 10 of 11
(3,523 Views)