Refnum Defining

I’m having difficulty with having my sensors read to my front panel. I know that the sensors function because they work in the front panel of the example VIs for digital inputs. I’ve managed to find an error message that tells me that the refnum I’m calling for my “get” statement does not exist. I had thought that I had created the refnum because I followed these instructions:

  1. In the Project Explorer window of the FRC robot project, within the
    Team Code folder under the RT CompactRIO Target, double-click
    the Begin.vi item to open the Begin VI.
  2. Select Window»Show Block Diagram or press the <Ctrl-E> keys to
    view the block diagram.
    Notice that references have already been set for Camera, Watchdog,
    Left and Right Motors, and Joystick 1.
  3. Add a Gyro Open VI to the block diagram below the Joystick 1 reference.
  4. Right-click the Analog Input terminal of the Gyro Open VI and select
    Create»Constant from the shortcut menu.
  5. Add a Gyro RefNum Registry Set VI to the block diagram to the right
    of the Gyro Open VI.
  6. Right-click the refnum name input of the Gyro RefNum Registry Set
    VI and select Create»Constant from the shortcut menu.
  7. Type the name you want to assign to this reference, such as Gyro 1.
  8. Wire the GyroDevRef output of the Gyro Open VI to the GyroDevRef
    input of Gyro RefNum Registry Set VI.
  9. Wire the error out output of the Gyro Open VI to the error in input
    of the Gyro RefNum Registry Set VI.

Is there some other step or setting for creating a refnum?

What you describe seems correct, but it would be a lot easier to verify if you posted a picture of your code.

Also show us the code where you’re doing the Get so we can make sure you’re doing that properly as well.

Here is the code. If you need more I’ll post it. I’m going to try to create a devref for something other than DIO today and see how that works.

UPDATE: I tried using a joystick devref and it gave me the same error in the error console.

Nothing strikes me as obviously wrong with what you posted. How are you running the code?

Because the image in the post is clipped, I can’t see what the switch statement has wired to it, but the sensor read and the indicator update are conditional. Is it possible that the code in that case of the switch isn’t running because of the logic wired to it?

Greg McKaskle

The case statement is definitely active. Other things in the case statement function correctly. I know that the error stems from a bad refnum because I created an indicator on the refnum call function and it told me that the refnum I was calling does not exist. I even went as far as to create a constant on the case structure for the case in which I have the sensor code because I was running low on new ideas.

Because the RefNum Get is outside the case structure, it seems it should be getting called - and the error makes me think it is. One thing to try might be to actually make a copy of the “Sensor” text constant wired to the RefNum Set, and wire that into the RefNum Get. This would be just to make sure the names are identical and there isn’t some hidden or nonprintable text.

It would be really helpful if the error message included the name of the refnum it couldn’t get. I can imagine helping a team at a regional having this problem where the main indication is an error on the diagnostics tab, and not really knowing where to start looking, especially if there are a lot of refnums.

It would probably be helpful if you posted your VIs, since often times you can find things wrong that you can’t see in a picture (at least until NI gives us LabVIEW 2009).

This is good advice, but I’ve tried this too! It didn’t seem to fix the problem.

Attached is my code and a picture of the error message.

http://i46.tinypic.com/2a8keqg.jpg

Encoder2.zip (254 KB)


Encoder2.zip (254 KB)

UPDATE: I have reinstalled LabVIEW with the update and it has not solved the issue. Additionally, I tried another laptop and that gave me the same error.

How are you running the code? I don’t see a Robot Main vi window open anywhere.

From the teleop loop. Should I be running it from main? i thought that running it from teleop wouldn’t be a problem as the other refnums didn’t return errors…

If you don’t run the Robot Main vi, the Begin vi doesn’t get called. I think that should adequately explain the problem you’ve been having.

This is your problem. The program you run is Robot Main and it calls all the other sub VI’s as they are needed or to run them.

Also your indicator is going to appear in the teleop front pannel not the driver station or robot main front pannels. You can have these front pannels open when the program is running though without any problems

Thanks for all the help. That seems to have fixed it.