Channel 3 out of range on Digital Input - EASY C


We downloaded our latest code and things were not working.

When we go to the terminal window the following scrolls continuously until the Easy C program “blows up”.

Channel (3) out of range on digital input

At this point we have removed everything from the cortex (all wires on Digital and Analog input/outputs). The problem repeats.

Is there something wrong with the Cortex/Joystick/Something?

Any advice would be greatly appreciated.:frowning:

I think channel 3 is an analog input.

Hello piniontwister,

Can you give us more details about what you’re trying to use with port 3? What sensor are you using? Are you plugged in to the analog or digital side? If you could post your code, that would be great as well.

I thought he was talking about the joystick channel 3.

It sounds like you are trying to read a digital port that is set for output (or write to an input), make sure the controller configuration is setup correctly. The default for the cortex is digital ports 1 to 8 as input, 9 to 12 as output.

Just so you know, it happens even if I pull EVERYTHING out of the A/D ports. Maybe something in the code? Or my computer? I just don’t know. I swapped many items already to try and isolate the cause. The first thing I pulled out was all inputs into the cortex (Joystick, Cortex).

I downloaded new code. Wrote a quick program. Changed batteries (ALL OF THEM).

Next step was to change computers that I am using.

I won’t be able to do any more testing until boys come home after school. Nothing special in the code so I am posting it. Any ideas would be appreciated.

It’s what I said it was, you have set digital 3 as an output for pneumatics yet you also try and read from it, one example.

#include "Main.h"

void ArmToFloor ( void )
      int ArmFloor; 

      ArmFloor = GetDigitalInput ( 3 ) ;
      while ( ArmFloor == 1 )
            ArmFloor = GetDigitalInput ( 3 ) ;
            ArmDown ( ) ;
      ArmStop (   ) ;

So when the code tries to read from digital 3 it throws the exception.

From your configuration it looks like the port above should be 5.

Another case here.

#include "Main.h"

void SwitchSides ( void )
      int SwitchBumper; 

      SwitchBumper = GetDigitalInput ( 3 ) ;
      if ( SwitchBumper == 0 )
            Forward ( ) ;
            Wait ( 2500 ) ;
            StopDrive ( ) ;

guessing that should be port 7 or 8.

Recheck all the ports you are using, this is where code full of “magic numbers” hurts you, the best approach is to define constants once in the code and then refer to everything by name rather than number.

Got it!!!

We completely rewired the robot and moved wires around. Grabbed our old code and stuck it in changing just a few lines for motors figuring we could leave our many user functions alone. We were wrong.

We will start with a new project and go from there.

Thanks for “wasting” your time on our stupid mistake. Our short cut was not too short after all.

We will also refer to motors by reference rather than number to help solve this problem in the future.

Thanks for all that you do for VEX!!

Happy to help, it’s not “wasting” my time and I’m sorry if the tone of my post implied that. I don’t think you need to start from scratch, these were the only instances I found and it was simple just to use “find” to search for these (search on things like GetDigitalInput). Define the ports you are using (for example, #define ARM_SENSOR_FLOOR 5 ) and then if the robot needs rewiring for whatever reason there is just one place in the code that needs to be changed.

Oops - I didn’t mean to imply anything other than our own stupidity. I am the one that feels I wasted your time on our stupid mistakes. Trust me - I read lots of posts here on this forum and we are all better off for having someone like you here to help.

Sincerely, thanks for all that you do here at the VEX Forum.