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).

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).

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.

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.


        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.

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.

**

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:


            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: