View Full Version : Auto Mode!!! WHOA...what tha?
teh_pwnerer795
29-11-2006, 23:45
OK guys ... i found out that ... if u do not redeclare all of ur inputs, outputs, and pwm values to neutral... they willl bounce from 0 to 254 in 0.0262 of a second.. contiuously!!!...WOW:P ... anyone .. noe why that is?? or is my robotic dieing on me :'( :(:(
Noah Kleinberg
29-11-2006, 23:53
Sounds like it could be a problem with your code? It would help if you could post the code in case that's the problem. You should try (if you haven't yet) loading the default code and seeing if the same problem happens, and also if this is happening on all of the PWMs or just the ones hooked up to your motors (or however you noticed this problem). You should also try another controller with the same code if you have an extra one somewhere, and then you'll know if it's a hardware problem or a software problem.
I thought not redeclaring them for automode just caused them to freeze in their current state?
Interesting.
Mike Betts
30-11-2006, 08:52
OK guys ... i found out that ... if u do not redeclare all of ur inputs, outputs, and pwm values to neutral... they willl bounce from 0 to 254 in 0.0262 of a second.. contiuously!!!...WOW:P ... anyone .. noe why that is?? or is my robotic dieing on me :'( :(:(
Noah is right. It is something that you have done in your code. The default code does not do this.
Regards,
Mike
teh_pwnerer795
30-11-2006, 18:32
lol, hm.. there isnt any code to post... im using the oringal code.... i hooked up the robot motors to the pwm01 and others that were acting up... nottin happed.. but it shows values on the controller... hm so i guess it may be hardware issues.... it works when i declare them (the varibles) all over again like in the default_routine....but i just thought it was kind of strange:P ...
bear24rw
30-11-2006, 19:19
Are you sure you are using code straight off www.ifirobotics.com or kevin.org/frc?
teh_pwnerer795
01-12-2006, 02:25
NO!! hahaha no actaully u do have to redeclare all the relay's pwms, inputs and outputs... this is because the controller will just remember the last stated value it was just received.... the only reason why i think this is cuz ... when in auto mode.... the values are not declared..so they are unsigned.. when asigned they keep that value.... get it? lolololol ... finally it makes sense
Alan Anderson
01-12-2006, 08:42
I suppose it's good that it makes sense to you. You're certainly not making much sense to me. Can you help me figure out what you're talking about?
When you say "controller", what do you mean? The Robot Controller (RC)? A Victor Speed Controller? Something else?
When you say "declare", what do you mean? The word has a specific use in C programs, but that doesn't seem to match how you're using it.
When you say "unsigned", what do you mean?
For that matter, what do you mean by "noe" and "nottin" and "IoIoIoIoI" (or is that supposed to be "101010101")?
Andy Baker
01-12-2006, 09:36
Pay no attention to him. I suggest that the moderators lock this thread as well, since no good will come of it.
Nope, I disagree.
Looking at all 10 of teh_pwnerer795's posts tells me that this person is in the middle of a project. While they need to improve how they ask questions, I believe they are sincere.
Andy B.
teh_pwnerer795
01-12-2006, 12:48
Wow, ok lock this post?...maybe i got off on the wrong foot?, and again no i do not have an IQ of a rock. And im srry if i cannot ask question to the best of my ablility because my skills lack in english class. Im srry to say that im not the brightest student in the world when it comes to robotics, but u dont make fun of someone when they are trying to learn and find out facts. Again i am srry for confusing anyone... or wasting anyones time with my posts..... my lololol, ne, w/, ... alll these things are msn short-cuts... i will try and not use them in the posts.....
When running in the user_routines_fast.c in auto-mode, all of the pwms, relays, digital/analog inputs are set to unsigned automaticaly.
example.
unsigned int pwm01;
unsigned int relay1_fwd;
Again, if u dont not redeclare all of ur varibles like in the user_routines.c the values that you state in user_routines_fast.c will stay at that value because their value has not been declared.
example.
pwm01 = pwm02 = pwm03 = pwm04 = 127;
digital_io_01 = digital_io_02 = digital_io_03 = 127;
relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
Once you finish redeclaring all of ur values for pwm's, relay's, and digital/analog inputs, they will not give the same problem like i had before.
The main reason how i found this out was this guy online told me
"Initialize all PWMs and Relays when entering Autonomous mode, or else it
will be stuck with the last values mapped from the joysticks. Remember,
even when Disabled it is reading inputs from the Operator Interface"
Again, I am very sry for any rudeness, or confusion i gave to anyone. Also i find that its quite rude how someone could have no sportsmanship in a SITE that helps people like me... HEY! i could be wrong? :eek: .... Maybe engineering inst for me if i got an IQ of a rock.
teh_pwnerer795
01-12-2006, 13:03
Here is an example of what would happen if you did not restate ur pwm's
NOT DECLARING
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
(pwm01 would stay at the value 0 when button is pressed. Once its unpressed, the value will stay at 0.)
DECLARING
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
(When button is pressed value will be 0. When it is unpressed, the value will be 127;)
MikeDubreuil
01-12-2006, 13:36
teh_pwnerer795,
I'm having a hard time understanding exactly what you mean. You are misusing special words in the programmer vocabulary. I would recommend you learn more about C programming fundamentals before you dive completely into the FIRST robotics code. Here is a good white paper (http://www.chiefdelphi.com/media/papers/1740) by Eugene Brooks on C programming for FIRST. It also might be a good idea to stop by the library or book store and pick up a book or two on the C programming language.
Alan Anderson
01-12-2006, 14:02
When running in the user_routines_fast.c in auto-mode, all of the pwms, relays, digital/analog inputs are set to unsigned automaticaly.
example.
unsigned int pwm01;
unsigned int relay1_fwd;
Again, if u dont not redeclare all of ur varibles like in the user_routines.c the values that you state in user_routines_fast.c will stay at that value because their value has not been declared.
That's not quite how it works. In C, when you "declare" a variable, you merely define what kind of values it can hold. The unsigned keyword means it never has negative values, and int means it is 16 bits in size (using the C18 compiler, anyway). An unsigned int can range in value from 0-65535.
(You may also set an initial value for the variable at the same time as declaring it, but you don't have to.)
What's confusing me most, though, is why you'd want to "redeclare" things like pwm01 or relay1_fwd. They are already defined in the ifi_aliases.h file, and they are shortcuts to pieces of the internal data structure used for communication between the master and user processors in the Robot Controller. The pwm outputs are actually declared for you as unsigned char, meaning they can have values from 0-255, and the relay outputs are single bits holding either 0 or 1. You should never try to redefine them.
The main reason how i found this out was this guy online told me
"Initialize all PWMs and Relays when entering Autonomous mode, or else it
will be stuck with the last values mapped from the joysticks. Remember,
even when Disabled it is reading inputs from the Operator Interface"
I believe you are misunderstanding the difference between "declare" and "initialize". To initialize a variable merely means to set it to a known value before using it. The pwm and relay variables are already declared for you; all you need to do is set them to safe values. His warning is for you not to assume anything about their value, and to make them explicitly what you want them to be.
Alan Anderson
01-12-2006, 14:13
Here is an example of what would happen if you did not restate ur pwm's
NOT DECLARING
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
(pwm01 would stay at the value 0 when button is pressed. Once its unpressed, the value will stay at 0.)
Unless something else assigns a different value to pwm01, that is correct.
DECLARING
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
(When button is pressed value will be 0. When it is unpressed, the value will be 127;)
Unless something else assigns a different value to pwm01, that is wrong.
You seem to be under the impression that "declaring" a variable works some magic that keeps setting it to a specific value. If you want pwm01 to always be 127 when the button is released, you'll have to do it yourself. Either
pwm01 = 127;
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
or
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
else
{
pwm01 = 127;
}
teh_pwnerer795
01-12-2006, 15:47
Unless something else assigns a different value to pwm01, that is correct.
Unless something else assigns a different value to pwm01, that is wrong.
You seem to be under the impression that "declaring" a variable works some magic that keeps setting it to a specific value. If you want pwm01 to always be 127 when the button is released, you'll have to do it yourself. Either
pwm01 = 127;
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
or
if (rc_dig_in01 == 0)
{
pwm01 = 0;
}
else
{
pwm01 = 127;
}
awesome thanxs alot
Adam Richards
01-12-2006, 16:15
Wow, ok lock this post?...maybe i got off on the wrong foot?, and again no i do not have an IQ of a rock. And im srry if i cannot ask question to the best of my ablility because my skills lack in english class. Im srry to say that im not the brightest student in the world when it comes to robotics, but u dont make fun of someone when they are trying to learn and find out facts. Again i am srry for confusing anyone... or wasting anyones time with my posts..... my lololol, ne, w/, ... alll these things are msn short-cuts... i will try and not use them in the posts.....
Again, I am very sry for any rudeness, or confusion i gave to anyone. Also i find that its quite rude how someone could have no sportsmanship in a SITE that helps people like me... HEY! i could be wrong? :eek: .... Maybe engineering inst for me if i got an IQ of a rock.My apologies for accidently misjudging you. Usually when someone uses miscellaneous phrases that don't make much sense when they're put together and the person has registered recently as well, they're commonly a spammer (i.e. the CD Spam Attack last year).
galewind
01-12-2006, 17:11
as an aside, there's a difference between DECLARING a variable and DEFINING it.
As Alan stated, pwm01 and p1_y are all defined in ifi_aliases.h
But defining a value is not the same as declaring it. Defining uses the assignment operator (=).
Additionally, the default code (that includes the camera code, at any rate), has a couple of lines in the User_Autonomous_Routines() function before the autonomous mode loop that effectively does initialize all of the pwm's and relays to 0. It effectively reads:
pwm01 = pwm02 = pwm03 = ... = 127;
relay1_fwd = relay1_rev = ... = 0;
Then inside of the autonomous loop (where the getdata and putdata lines are located), you would set your values for pwms inside of there.
And as stated, do NOT attempt to redeclare them, as they've already been #define 'd in ifi_aliases.h
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.