Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   4-slot cRIO and default modules (http://www.chiefdelphi.com/forums/showthread.php?t=100682)

mikets 19-01-2012 21:51

4-slot cRIO and default modules
 
I am very confused about the new module arrangements. Our team bought the new 4-slot cRIO this year. We followed the new convention and put the Analog module in slot 1, Digital module in slot 2 and the Solenoid module in slot 3. But we are trying to figure out if the WPILib would have the correct modules by default so we don't need to explicitly specify the modules when instantiating sensors and switches. This is to make sure our robotics library still works because the code would call GetDefaultXXXModule() to determine where the modules are. I have downloaded the source code of the WPILib. The more I look at it, the more confused I am. It looks like it is still defaulting to the 8-slot arrangement. For example, SensorBase.cpp has the modulePopulation array initialized to the 8-slot arrangement. SensorBase.h also has the following declaration:
Code:

UINT32 SensorBase::m_defaultAnalogModule = 1;
UINT32 SensorBase::m_defaultDigitalModule = 4;
UINT32 SensorBase::m_defaultSolenoidModule = 8;

But when reading threads here, I got an impression that I don't need to explicitly specify the module slot. And I have an impression that even the 8-slot cRIO should have the new module arrangement the same as the 4-slot. If so, why is the code showing the old arrangement?

mikets 19-01-2012 22:21

Re: 4-slot cRIO and default modules
 
I loaded a modified version of last year's code to the robot and it gave me:
Quote:

ERROR: Allocating module that is out of range or not found: Analog Module 2 ...in GetInstance() in C:/WindRiver/workspace/WPILib/AnalogModule.cpp at line 38

ERROR: Allocating module that is out of range or not found: Digital Module 2 ...in GetInstance() in C:/WindRiver/workspace/WPILib/DigitalModule.cpp at line 36
And of course, the lines specified in the above message don't seem to have anything to do with the error.

aeniug2 19-01-2012 22:30

Re: 4-slot cRIO and default modules
 
Not sure if this is entirely related, but I know that nowhere in my teams code do we ever reference a specific module. We are using all the latest updates and etc.

If it helps at all, the cRIO imaging tool should show you if you have all the modules in the right slots.

mikets 19-01-2012 22:32

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by aeniug2 (Post 1109455)
If it helps at all, the cRIO imaging tool should show you if you have all the modules in the right slots.

They are in the right slots: 9201 in slot 1, 9403 in slot 2 and 9472 in slot 3. In fact, I just re-imaged the cRIO to make sure just in case I screwed up the first time.

aeniug2 19-01-2012 22:37

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109457)
They are in the right slots: 9201 in slot 1, 9403 in slot 2 and 9472 in slot 3. In fact, I just re-imaged the cRIO to make sure just in case I screwed up the first time.

Awesome. Reimageing can solve alot of problems... In fact, it solved all the major problems my team has had so far this year. :P

Anyways, I'm not sure I can help you much... The only sections of the WPILib.h source code I've ever studied in depth are the ones directly related to driving the robot, and receiving input from joysticks; among some other random stuff.

This might be a dumb suggestion, but have you tried just running the simpletemplate?

Joe Ross 19-01-2012 22:42

Re: 4-slot cRIO and default modules
 
I don't think you're looking at this year's code.

mikets 19-01-2012 22:51

Re: 4-slot cRIO and default modules
 
That's what I thought, but I got it off the latest from first forge.
http://firstforge.wpi.edu/sf/scm/do/...cts.wpilib/scm

mikets 19-01-2012 22:57

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by aeniug2 (Post 1109462)
have you tried just running the simpletemplate?

The simple template is not applicable to our robot. Our robot is using CANJaguar. So it doesn't use the PWMs on the digital sidecar.

aeniug2 19-01-2012 23:08

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109482)
The simple template is not applicable to our robot. Our robot is using CANJaguar. So it doesn't use the PWMs on the digital sidecar.

Ahhh... Interesting. Our team has never tried that out... I think we'll stick to pwms for now.

RufflesRidge 19-01-2012 23:13

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109474)
That's what I thought, but I got it off the latest from first forge.
http://firstforge.wpi.edu/sf/scm/do/...cts.wpilib/scm

I don't think that code is updated any more. Instead the source is installed by the update. Into C:\windriver\wpilib as a zip file if I remember right. I believe the update is just a self-extracting archive so you should be able to dig the source out of it by renaming it to .zip if you're on a Linux machine

aeniug2 19-01-2012 23:19

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by RufflesRidge (Post 1109491)
I don't think that code is updated any more. Instead the source is installed by the update. Into C:\windriver\wpilib as a zip file if I remember right. I believe the update is just a self-extracting archive so you should be able to dig the source out of it by renaming it to .zip if you're on a Linux machine

you do remember right :)
thats where I get the source code I read to learn more about motor control and joysticks.

mikets 19-01-2012 23:26

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by RufflesRidge (Post 1109491)
I don't think that code is updated any more. Instead the source is installed by the update. Into C:\windriver\wpilib as a zip file if I remember right. I believe the update is just a self-extracting archive so you should be able to dig the source out of it by renaming it to .zip if you're on a Linux machine

Thank you for reminding me. I used to get the source from there but ever since I enlisted to the first forge sources, I thought it would be the latest there but I guess I am wrong. But if the zip'd version is the latest (WPILibC++Source20120108rev2993.zip), then it is even worse because according to sensorbase.h, all modules default to slot 1!
Code:

        static UINT32 GetDefaultAnalogModule() { return 1; }
        static UINT32 GetDefaultDigitalModule() { return 1; }
        static UINT32 GetDefaultSolenoidModule() { return 1; }


RufflesRidge 19-01-2012 23:28

Re: 4-slot cRIO and default modules
 
That's because it's not a slot number. The whole paradigm for referencing the modules has changed to support the 4-slot cRIO. The 1st of each module (analog, digital, solenoid) in slots 1-3 is module 1 of that type. The 2nd instance (slot 4 on 4-slot, slots 5-7 on 8-slot) is module 2 of each type.

mikets 19-01-2012 23:39

Re: 4-slot cRIO and default modules
 
Ah I see. So in other words, all the methods involving modules (previously slots) are incompatible with previous versions. For example, for the gyro module, one of the constructors Gyro(UINT8 moduleNumber, UINT32 channel) is no longer compatible with the previous version Gyro(UINT32 slot, UINT32 channel). If I have old code that instantiate a gyro with a secondary Analog module in slot 3, for example. The code would look like Gyro(3, 1). But for this year, I have to put the secondary analog module in slot 5 (assuming a 8-slot cRIO) and initiate it with Gyro(2, 1). Does it sound about right?

Does it mean that I can no longer put the modules anywhere I want but it has to be "Analog, Digital, Solenoid, ???" in that order? Or the WPILib is smart enough so that I can put, for example, 3 analog modules anywhere, and I can address them by naming them 1 (1st instance of analog), 2 (2nd instance of analog) and 3 (3rd instance of anlog) since it can read the module ID in each slot.

Joe Ross 19-01-2012 23:44

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109513)
Does it mean that I can no longer put the modules anywhere I want but it has to be "Analog, Digital, Solenoid, ???" in that order?

You've never been able to put the modules anywhere you wanted. Analog were slots 1 &2 (rules dictated you had to use slot 1), Digital were slots 4 & 6 (rules dictated you had to use slot 4), Solenoid were 7 & 8.

RufflesRidge 19-01-2012 23:44

Re: 4-slot cRIO and default modules
 
That all sounds about right, other than that you could never put the modules wherever you wanted as far as I know. I believe it used to be Analog in 1 and 2 (may have been 1 and 3), Digital in 4 and 6 and solenoid in 7 and 8.

And yes, backward code comparability has not been maintained. All code that specifically referenced slot numbers (other than analog slot 1 which is 1 either way) must be updated to work in order to work with the new libraries and image.

EDIT: Just saw your edit. You must put Analog, Digital, Solenoid in that order in slots 1-3 on either cRIO (solenoid may be omitted). On the 4 slot, the 4th slot can be any module. On the 8 slot the pattern repeats with slots 5-7 with 4 and 8 left empty (any of the "extra" modules may be omitted, but the modules may not be shuffled around).

There's a description of the new paradigm in the C++ Getting Started Guide: http://firstforge.wpi.edu/sf/go/doc1197?nav=1

mikets 19-01-2012 23:46

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by Joe Ross (Post 1109517)
You've never been able to put the modules anywhere you wanted. Analog were slots 1 &2 (rules dictated you had to use slot 1), Digital were slots 4 & 6 (rules dictated you had to use slot 4), Solenoid were 7 & 8.

I meant "in theory". I am trying to understand the new paradigm, not that I really want to stick 3 analog modules in the cRIO.:)

mikets 19-01-2012 23:52

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by RufflesRidge (Post 1109518)
EDIT: Just saw your edit. You must put Analog, Digital, Solenoid in slots 1-3 on either cRIO. On the 4 slot, the 4th slot can be any module. On the 8 slot the pattern repeats with slots 507 with 4 and 8 left empty.

So again, just to make sure I understand it correctly. In theory, if I put three analog modules in the 8-slot cRIO, the first one in slot 1, the second one in slot 4 and the third one in slot 5 (I suppose this is still legal :)). I can address them by:
Code:

Gyro(1, 1);    //Gyro in slot 1, channel 1
Gyro(2, 1);    //Gyro in slot 4, channel 1
Gyro(3, 1);    //Gyro in slot 5, channel 1

Does it sound right? If so, they should have called it "instance" instead of "moduleNumber".

Alan Anderson 20-01-2012 00:37

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109522)
So again, just to make sure I understand it correctly. In theory, if I put three analog modules in the 8-slot cRIO, the first one in slot 1, the second one in slot 4 and the third one in slot 5 (I suppose this is still legal :)). I can address them by:
Code:

Gyro(1, 1);    //Gyro in slot 1, channel 1
Gyro(2, 1);    //Gyro in slot 4, channel 1
Gyro(3, 1);    //Gyro in slot 5, channel 1

Does it sound right? If so, they should have called it "instance" instead of "moduleNumber".

Not right. No modules are supported in Slots 4 or 8 of an 8-slot FRC-cRIO.

mikets 20-01-2012 00:41

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by Alan Anderson (Post 1109552)
Not right. No modules are supported in Slots 4 or 8 of an 8-slot FRC-cRIO.

You said no modules are supported in slot 4 or 8. Is it because it's not allowed by the rules or is it because the code won't accept anything in slot 4 or 8?

Joe Ross 20-01-2012 09:54

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109554)
You said no modules are supported in slot 4 or 8. Is it because it's not allowed by the rules or is it because the code won't accept anything in slot 4 or 8?

The code doesn't support it because the hardware (FPGA) doesn't support it.

mikets 20-01-2012 13:24

Re: 4-slot cRIO and default modules
 
Sorry about beating the dead horse but I am just curious about why the cRIO has the extra slot and the FPGA does not support it. It seems to me the extra slot is very useful especially in the 4-slot cRIO. For example, it is quite easy to run out of digital I/O channels with encoders taking 2 channels each, teams may want to stick another digital module in slot 4, for example.
Also RufflesRidge mentioned slot 4 of the 4-slot cRIO can take any modules.

Mark McLeod 20-01-2012 13:40

Re: 4-slot cRIO and default modules
 
You can stick whichever module you need in slot-4 of the cRIO FRC II.
The older cRIO FRC I, was just given the 3+0+3+0 pattern as a design choice. We are unlikely to mix the two up.

The FPGA is really full with all it's been given to do.
Excess capacity got sucked up to benefit us in other much more potentially useful ways.

All resources are limited in one way or another.
Engineering is designing and choosing between the optimal tradeoffs for our application.

Bryscus 20-01-2012 17:00

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109522)
So again, just to make sure I understand it correctly. In theory, if I put three analog modules in the 8-slot cRIO, the first one in slot 1, the second one in slot 4 and the third one in slot 5 (I suppose this is still legal :)). I can address them by:
Code:

Gyro(1, 1);    //Gyro in slot 1, channel 1
Gyro(2, 1);    //Gyro in slot 4, channel 1
Gyro(3, 1);    //Gyro in slot 5, channel 1

Does it sound right? If so, they should have called it "instance" instead of "moduleNumber".

You must have grown up only on a Windows machine. Windows only supports (without weird hacks) absolute paths for shortcuts. If you had grown up with Linux you would have used the symbolic links method (relative paths - module numbers not slot numbers). Then the code wouldn't have to be changed :).

Speaking of dead horses...this is just wrong. :deadhorse: LOL

- Bryce

mikets 20-01-2012 17:29

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by Bryscus (Post 1109902)
You must have grown up only on a Windows machine. Windows only supports (without weird hacks) absolute paths for shortcuts. If you had grown up with Linux you would have used the symbolic links method (relative paths - module numbers not slot numbers). Then the code wouldn't have to be changed :).

Actually, I grew up with punch cards and unix :)

Mark McLeod 20-01-2012 18:10

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by mikets (Post 1109930)
Actually, I grew up with punch cards and unix :)

Luxury...

Greg McKaskle 20-01-2012 21:42

Re: 4-slot cRIO and default modules
 
I hope I don't add to the confusion, but it is worth mentioning that the cRIO FPGA is reprogrammable. In its day job, it can have 8 32-bit digital modules if you like, and it is also possible to compile in a slot manager that will map the slots dynamically and make it truly plug-n-play. But, all of this is dependent on the FPGA, and the FRC FPGA uses fixed slots and has a ton of flexibility in what the pins can do.

Greg McKaskle

Bryscus 21-01-2012 21:17

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by Mark McLeod (Post 1109977)
Luxury...

I've never had the fun of programming a machine with switches and push buttons, but some co-workers have shared many a story about entering bootloaders this way (and even more arcane methods).

- Bryce

mikets 21-01-2012 22:20

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by Bryscus (Post 1110851)
I've never had the fun of programming a machine with switches and push buttons.

I've done that too with the PDP-11.

BitWizard 30-01-2012 01:28

Greg, we were planning to go with two analogs in slots 1 and 4, and two digitals in slots 2 and 3 on a 4-slot cRIO. We're ordering a 4-slot specifically for that purpose. Are you saying we can't do this. We have no pneumatics this year.

Chris

Alan Anderson 30-01-2012 01:48

Re: 4-slot cRIO and default modules
 
Quote:

Originally Posted by BitWizard (Post 1116313)
Greg, we were planning to go with two analogs in slots 1 and 4, and two digitals in slots 2 and 3 on a 4-slot cRIO.

Sorry, Chris, but slot 3 will support a solenoid module and nothing else. Only slot 4 is capable of taking any of the 3 kinds of modules used in FRC.


All times are GMT -5. The time now is 12:32.

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