Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   Individual Control of Each Spike output ? (http://www.chiefdelphi.com/forums/showthread.php?t=93174)

de_ 03-03-2011 19:02

Individual Control of Each Spike output ?
 
Is it possible to individually control each output line of the spike so you could independently turn on & off 2 leds ? At this point I know you can turn both off or turn one on but that will automatically turn the other one off (and visa versa).

Vikesrock 03-03-2011 19:13

Re: Individual Control of Each Spike output ?
 
It is possible. How you do it depends on the programming language being used. In Labview the Enum used for the Relay set can be set to "Off" (both off) "On" (both on), "Forward" (one on, one off) or "Reverse" (opposite of forward).

SuperBK 03-03-2011 21:38

Re: Individual Control of Each Spike output ?
 
To do that you have to wire one LED to each spike output and the other end of each to ground (don't forget current the limiting resitor). Turning on the spike forward would light one LED, reverse would turn off the other.

de_ 03-03-2011 22:27

Re: Individual Control of Each Spike output ?
 
Hi

We program in Java. Unfortunately the last time I programmed was with the CPU (RC) prior to the CRio (and in C++) so I don't have much (any) experience with the Relay class in WPI Lib

Here's an example of what we want to do with one spike.

On one line have an (12v) Red LED connected and be able to turn it on and off without effecting the state of what is on the other line of the spike. On the other line, we want to have a white 12v led that we flash in software, again, not effecting the Red LED.

I guess I really should have posted this in programming.

Mr. Lim 04-03-2011 07:28

Re: Individual Control of Each Spike output ?
 
Code:

        myRelay.setDirection(Relay.Direction.kBoth);
       
        myRelay.set(Relay.Value.kOff); // M+ and M- = 0V
        myRelay.set(Relay.Value.kForward); // M+ = 12V, M- = 0V
        myRelay.set(Relay.Value.kReverse); // M+ = 0V, M- = 12V
        myRelay.set(Relay.Value.kOn); // M+ = 12V, M- = 12V

Wire as per instructed in posts above with grounds of your LED directly to power distribution.

Ether 04-03-2011 08:49

Re: Individual Control of Each Spike output ?
 
Quote:

Originally Posted by de_ (Post 1034347)
Here's an example of what we want to do with one spike.

On one line have an (12v) Red LED connected and be able to turn it on and off without effecting the state of what is on the other line of the spike. On the other line, we want to have a white 12v led that we flash in software, again, not effecting the Red LED.

I guess I really should have posted this in programming.

The two processes will have to cooperate to achieve what you want.

Let the 4 possible states of the Spike be:

1) both LEDs OFF
2) White LED OFF, Red LED ON
3) White LED ON, Red LED OFF
4) both LEDs ON

Then, to flash the Red LED on/off while the White one is OFF, you would alternate between states 1 & 2.

But to flash the Red LED on/off while the White one is ON, you would alternate between states 3 & 4.

So the process which flashes the Red LED cannot act independently from the process which flashes the White LED, and vice-versa. The processes must share information.

One way to do this would be to have each process just set a boolean flag to indicate whether its LED should be ON or OFF, and let a third process set the proper state of the Spike each time either of these booleans changes. Rather than having the third process chew up resources polling, you could use some sort of messaging supporting by the vxworks OS.




Joe Ross 04-03-2011 09:57

Re: Individual Control of Each Spike output ?
 
Quote:

Originally Posted by Mr. Lim (Post 1034452)
Code:

        myRelay.setDirection(Relay.Direction.kBoth);

        myRelay.set(Relay.Value.kOn); // M+ = 12V, M- = 12V


Have you tried this? It looks like kOn with direction kBoth will throw an exception.

Mr. Lim 05-03-2011 00:34

Re: Individual Control of Each Spike output ?
 
Quote:

Originally Posted by Joe Ross (Post 1034486)
Have you tried this? It looks like kOn with direction kBoth will throw an exception.

Ugh you are right. What a pain.

You're probably best duplicate your own custom Relay class, and modify the following to make it work...

Lines 220 to 228:

Code:

            case Value.kOn_val:
                if (m_direction == Direction.kBoth) {
                    m_module.setRelayForward(m_channel, true);
                    m_module.setRelayReverse(m_channel, true);
                } else if (m_direction == Direction.kForward) {
                    m_module.setRelayForward(m_channel, true);
                } else if (m_direction == Direction.kReverse) {
                    m_module.setRelayReverse(m_channel, true);
                }
                break;

:mad:


All times are GMT -5. The time now is 09:51.

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