Going back to LV this year after a short stint in C++ (even though I like C++ better). Trying to use the Cypress board on last year’s bot with somewhat identical programming statements for purposes of education.
In C++, I extracted up to 12 Digital values for control of the arm, even though they were hooked up to the Analog pins. I want to do the same with LV, but I can only get 8 from the dedicated Digital I and 8 from the dedicated Analog IO.
I want to convert the Analog I into a usable boolean value for cascading logic statements. After poking around a little bit, I am thouroughly stumped.
The “less than” function is a single VI. It will convert an analog value into a boolean one. If that’s not what you’re asking for, I don’t understand your needs.
If you don’t want the gratuitious “2.5” cluttering up the block diagram, you can easily make your own SubVI that takes a voltage input and produces a boolean output, and you can make its icon just large enough to have room for a single input and a single output.
Is there a reason you prefer not to take advantage of the additional digital inputs available in Enhanced Mode?
If you connect the cluster of 8 channels to a single < icon, as in Mark’s picture, you can then unbundle the comparison results. Another useful trick is to convert clusters to array in order to be able to loop over them more easily with a loop.
Looking at your C++ code, I don’t think you were "over-read"ing analog to get digital. I think you used the enhanced I/O to configure all 16 digital i/o to inputs and used the enhanced IO to read them.
The config VI you mentioned has help that explains its purpose …
“This VI returns sets the mode of each digital channel. All 16 channels can be inputs with configurable pull up/down resistors and can be driven as outputs. Some channels have additional capabilities as listed in the mode ring. Additionally, this VI configures the PWM and encoders for the I/O device connected to the driver station.”
You have the choice of doing the configuration using the dialog on the DS, or on the robot’s code, whichever you think will be more predictable. You can also reconfigure during the match, via the robot code, but that would be unexpected.
The other VIs in the palette allow you to configure the other types of I/O and set/get the various values.
It is a dense little thingy, so feel free to ask questions if you have them.
Setting the digital mode is done with the Enhanced Set Digital Config VI. As with lots of WPILib, if the summary description doesn’t make sense, the most obvious way to determine how it works is probably to open its panel. The attached image shows that there are sixteen selectors with options generally of Input (high, low, or floating), Output, and sometimes other functions such as PWM (first four channels), or Analog comparator (last two channels). If you right click on the terminal of the original icon and create a control or constant, it will bring along all of those enum selectors. You can also copy/paste it to the calling diagram. As mentioned in the other post, you can also do this once on a DS, and it will save the settings to its ini file and use them the next time. If you have a shared DS, the robot config may make more sense, but otherwise, I’d probably do the DS, since it is the closest to the Cypress board and the rest of the driving switches, etc.
To extract data from the digital inputs, you use the Get Enhanced Digital Input VI, and it returns an array of sixteen values. There can be up to sixteen inputs. If you haven’t configured a pin to be an input, then the value for that position is not all that useful and may in fact be misleading.
Okay, now I have a realitively big issue that is not stopping me any, but may be an issue in the future.
In the Teleop VI, with the Set Enhanced Digital Config VI, with the Enum Cluster pulled out as a control to the Front Panel of the Teleop VI, the values continioulsy reset:eek: after I close the Teleop VI after I am done with it.
Is this an error with LV, or something hardwired in the Set Config VI that I don’t want to mess around with?
You need to make any and all controls changes the permanent default by clicking on:Edit -> Make Current Values DefaultYou can also click on individual controls and make just one or a couple change, instead of all of them.
That’s so you can play all you want with the controls, but you won’t destroy the original settings until you really want to.
If I understand you correctly, that’s a problem with the default value of the cluster. Set the cluster to have the values you want it to retain, then right click on it and under Data Operations, choose Make Current Value Default. LV should then retain that data for the cluster.