Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Set Digital out (http://www.chiefdelphi.com/forums/showthread.php?t=76505)

Comatose 04-04-2009 20:48

Set Digital out
 
I've been tweaking our code and have run into a snag. I'm trying to get the eighth digital output to be able to go on and off without affecting the first. It seems the Set Dig Out vi uses a binary number to do this, which requires setting the first digital out to become zero, but at different times I want the first digital out to be on and vice versa. Is there a way of doing this, or has labview overlooked a large flaw in setting digital outs. Btw, we've only found this because if you run 2 controls on a digital output like this, it become erratic whether or not to stay on.

Thanks,

Comatose

DonRotolo 04-04-2009 21:11

Re: Set Digital out
 
I'm not a programmer, and so this may not be at all helpful, but I speak Binary.

Let's say you have bits one through eight and you want to set them.

Setting Bit 1 looks like this: 00000001
Setting bit 8 looks like this: 10000000
Setting both looks like this: 10000001

The first number is 1 (01h), the second number is 128 (80h), the 3rd number is 129 (81h).

So, if bit 8 is set on and all the rest are off, you're sending 80h. To turn Bit 1 on without affecting bit 8, send 81h.

As another example (work this out on paper) Bits 1, 5 and 8 on = 91h, and 1 and 5 only is 11h. Get it?

EDIT: I see it uses a binary number like 10000001, so convert the hexadecimal values in my example above to binary.

Cuse 04-04-2009 21:13

Re: Set Digital out
 
It sounds like you are manually specifying a value for only Digital Output 7, converting it to an array, and sending that value to the SetDigOut VI. This could create problems, as doing that would (I think) default the other, unspecified values in the array to false, creating the situation that you have described. Instead, you'll need to use the GetDigOut VI first to obtain the current state of all your DigOuts. Convert the array to a cluster, unbundle it, and build a Boolean array, using DigOuts 0-6 for elements in the array, and specifying your 7th DigOut however you'd like as per your code. Then send the rebuilt array into the SetDigOut VI. I did a little experimentation and this worked for me, so hopefully it will solve your problems.

JasonF 13-04-2009 21:43

Re: Set Digital out
 
Maybe I am not understanding the question completely

But If you have an Array of data already that is changing Simply use a "Replace Array Subset", set the index to 7 (DIO 8 on the DS) and the new element to True or False. This will leave the rest of the data in the Array untouched, changing only the 1 element

Other wise build your array with Boolean Values. Using the Set DIO DS VI drop a "build array" In, expand it to 8 Elements (0-7) and then use Constants on the Last Output and whatever outputs you are not using for False. Then pass your data into the Outputs that fluctuate.

I Hope this helps, if not send me a message or something, I have been working on the DIOs for the past couple days...

Jason

kamocat 13-04-2009 22:01

Re: Set Digital out
 
Quote:

Originally Posted by JasonF
If you have an Array of data already that is changing Simply use a "Replace Array Subset", set the index to 7 (DIO 8 on the DS) and the new element to True or False. This will leave the rest of the data in the Array untouched, changing only the 1 element

Make sure that when you do this, you use a shift register or feedback node so the array values are retained for the next iteration

JasonF 13-04-2009 22:19

Re: Set Digital out
 
Quote:

Originally Posted by kamocat (Post 850214)
Make sure that when you do this, you use a shift register or feedback node so the array values are retained for the next iteration

Good point,
Thanks for the catch
:D


All times are GMT -5. The time now is 10:39.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi