Log in

View Full Version : Code error?


niagra127
12-02-2008, 21:58
Alright our team has been trying to run a motor through a pwm with the buttons on the joystick.

if (p1_sw_aux1 = 1 && p1_sw_aux2 = 0)
{
pwm10 = 255
}
else if (p1_sw_aux1 = 0 && p1_sw_aux2 = 1)
{
pwm10 = 0
}
else
{
pwm10 = 127
}

This returned nothing on the motor and we are positive the motor runs.
We also tried just using pwm10 = 255 to see if anything would happen and we got absolutely nothing in return. The motor just constantly sits there, we think its an electrical problem but we are still getting told its a programming error. If this is true can anyone tell us what it is we are doing wrong?

Eugene Fang
12-02-2008, 21:59
Alright our team has been trying to run a motor through a pwm with the buttons on the joystick.

if (p1_sw_aux1 = 1 && p1_sw_aux2 = 0)
{
pwm10 = 255
}
else if (p1_sw_aux1 = 0 && p1_sw_aux2 = 1)
{
pwm10 = 0
}
else
{
pwm10 = 127
}

This returned nothing on the motor and we are positive the motor runs.
We also tried just using pwm10 = 255 to see if anything would happen and we got absolutely nothing in return. The motor just constantly sits there, we think its an electrical problem but we are still getting told its a programming error. If this is true can anyone tell us what it is we are doing wrong?


in the if then, you have to use two = signs (like this ==)

niagra127
12-02-2008, 22:01
We have tried that as well and it returned nothing. (I am not at our coding laptop and do not have a copy of the code with me so I am throwing the code out from memory.)

Eugene Fang
12-02-2008, 22:08
when you turn the robot on, what do the victor lights do? if they are blinking orange, then you should check the pwm wires to make sure they're fully in

Eugene Fang
12-02-2008, 22:09
We also tried just using pwm10 = 255 to see if anything would happen and we got absolutely nothing in return. The motor just constantly sits there, we think its an electrical problem but we are still getting told its a programming error

just to clarify, that means u just put pwm10 = 255 without any if-then statements right?

Eugene Fang
12-02-2008, 22:10
did you copy paste the code from the actual code? or did you just type it up as an example. because you are missing semi-colons at the ends of your lines, too.

niagra127
12-02-2008, 22:14
I believe it may be the victors, i remember seeing orange lights but the electric team said it was normal. Yes, i meant without any if statements, and i just threw it out from memory. I never can remember those semi colons XD

Eugene Fang
12-02-2008, 22:16
http://ifirobotics.com/docs/ifi-v884-users-manual-9-25-06.pdf

take a look at the third page. it describes what the lights mean and how to troubleshoot the victor

Alan Anderson
12-02-2008, 22:18
Step back from the immediate problem a bit and make sure the larger environment is okay. Are you certain you're downloading the newly created .hex file? Are you even certain you're successfully compiling the program in the first place? In addition to the incorrect equality test, the code you posted has some missing semicolons that I would have expected to cause syntax errors.

niagra127
12-02-2008, 22:19
We had been messing with the pwm cords prior to the testing, as we didn't know for sure which way they were supposed to go in. We may not have put it in fully.

Thank you

Eugene Fang
12-02-2008, 22:21
We had been messing with the pwm cords prior to the testing, as we didn't know for sure which way they were supposed to go in. We may not have put it in fully.

Thank you

Yea, make sure the black side of the pwm is lined up with the B on the victor, and that the pwm's are in firmly. good luck!

SuperBK
13-02-2008, 08:52
Sorry to ask the obvious question but,
pwm10? Are you sure you did not mean pwm01?

Try putting in a printf and then let the loader open the terminal window after programming. Leave the programming cable on. (Its a good idea to put blocks under any drive wheels while running with a computer connected to the robot)
Add this line
printf("p1_sw_aux1 = %d, p1_sw_aux2 =%d\r", p1_sw_aux1, p1_sw_aux2);

What buttons are you pressing? The trigger is p1_sw_trig, and the thumb switch is p1_sw_top, I don't think the aux inputs are connected to anything on the joystick.

As for setting the motor to 255, every time in the loop it should always go.


Brian

niagra127
13-02-2008, 20:35
Yes i mean pwm10 thats the pwm we are using, and we have tested the aux buttons they are attached to buttons on the top of our joystick. Today we went back and looked and found that we hade a bad victor, we are getting that fixed now. Thank you to all who helped.