SomeoneKnows
08-10-2007, 02:21
I'm working with the Vex and WPILib and have a question about configuring Analog / Digital ports. On page 33 of the WPILib programming document it talks about the 16 ports being split between analog and digital. It says the analog ports are the lower numbered ports below the split and the digital porta are the larger numbered ports. I looked at the Vex documentation and it doesn't seem to specify this split location. The Easy C Options->ControllerConfiguration feature shows ports 1 through 4 as default Analog Inputs but the Controller Configuration user interface will let me set all 16 ports to Analog Input.
What is the Analog/Digital split location the WPILib documentation is referring to?
Since the Easy C Controller Configuration will allow user definition of I/O ports why doesn't WPILib have a way to set this configuration?
Is there a way around the Analog port limit that WPILib claims?
Vince Thompson
Abrakadabra
22-10-2007, 00:52
Hi Vince,
Looks like traffic is a bit light in this forum lately. I just started working with WPILib this summer, and this one had me confused for a bit too. So, even if you've already figured it out, I thought an answer would be helpful for others who might hit the same issue.
The key is to look at the API.h header file. There you will see an function that for some reason is not mentioned in the .PDF documentation. DefineControllerIO() not only lets you specify the I/O direction for each port, but on the Vex also lets you specify as the first argument the number of analog channels to be used:
#ifdef _FRC_BOARD
void DefineControllerIO(unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4,
unsigned char p5, unsigned char p6, unsigned char p7, unsigned char p8,
unsigned char p9, unsigned char p10, unsigned char p11, unsigned char p12,
unsigned char p13, unsigned char p14, unsigned char p15, unsigned char p16,
unsigned char p17, unsigned char p18);
#endif // _FRC_BOARD
#ifdef _VEX_BOARD
void DefineControllerIO(unsigned char numberOfAnalogChannels,
unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4,
unsigned char p5, unsigned char p6, unsigned char p7, unsigned char p8,
unsigned char p9, unsigned char p10, unsigned char p11, unsigned char p12,
unsigned char p13, unsigned char p14, unsigned char p15, unsigned char p16);
#endif // _VEX_BOARD
The first n channels will be analog, where n is the first parameter of the Vex-specific function. Although I haven't actually tried it, I assume you could make all 16 channels analog in this way if you so desired.
Hope this helps!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.