![]() |
Odd counter problems
Ok well, I'm trying to run through a loop where it does
armcounter++; Armcounter is defined at the top of user_routines_fast.c. I try a print_f to print out armcounter but it gives [null] on the ifi_loader. My motors just keep running for ever because it doesn't ever have armcount equal to the number I supply. Any clues????? :confused::ahh: |
Re: Odd counter problems
you need to declare armcounter as a static int. Otherwise, it gets created and destroyed on the stack each time you enter and leave the function.
|
Re: Odd counter problems
Quote:
Code:
printf("\nArm counter: %i\n", (int)armcounter); |
Re: Odd counter problems
Quote:
PS What type is armcounter? |
Re: Odd counter problems
its a short.
|
Re: Odd counter problems
Quote:
|
Re: Odd counter problems
ok I did and now theres nothing there, its not printing anything.
|
Re: Odd counter problems
Quote:
Code:
printf("Test");--EDIT-- If it doesn't work then post your code and people can look at it. |
Re: Odd counter problems
1 Attachment(s)
It printed test but here it is. I'm using a basic auto right now so i can debug everything first.
|
Re: Odd counter problems
Quote:
--EDIT-- Try changing the %i in the printf to %d. |
Re: Odd counter problems
A few things I saw after glancing at it:
Code:
if (armcounter = 15) //will raise arm.Code:
if (armcounter == 15) //will raise arm.That said, I believe the code in its original form should have printf'd 15 over and over and over. Was it doing that, or just not printing anything? |
Re: Odd counter problems
Quote:
|
Re: Odd counter problems
Well the = was something i accidently did when moving it i had it in the code i was using. and btw its just not printing anything.
|
Re: Odd counter problems
Quote:
|
Re: Odd counter problems
Quote:
Code:
printf("Test\n"); |
Re: Odd counter problems
Quote:
|
Re: Odd counter problems
Well for the variable, it print Arm and then nothing after it.
|
Re: Odd counter problems
Could you paste the output from the code here?
|
Re: Odd counter problems
Well, I can't figure it out. It should work. Any suggestions, The Lucas?
--EDIT-- I know you're watching. :) |
Re: Odd counter problems
Obviously not. Try:
Code:
printf("Arm: %d", armcounter);If that doesn't work, I don't know what to do. Sorry. :( |
Re: Odd counter problems
1 Attachment(s)
Here is a screenshot.
|
Re: Odd counter problems
I edited my last post. Take a look at it. Sorry I can't be of any more help. :(
--EDIT-- Someone else will come along and figure it out I'm sure. :) |
Re: Odd counter problems
Ok now nothing is being printed Texan from what you said to put in.
-EDIT- its saying TestAmr, 15TestArm, 15TestArm over and over now |
Re: Odd counter problems
Quote:
|
Re: Odd counter problems
Well its counting now.
|
Re: Odd counter problems
Quote:
Catastrophy, is your problem fixed now that it is counting, or do you have more problems? |
Re: Odd counter problems
Quote:
|
Re: Odd counter problems
well the motors still arnt stopping.
|
Re: Odd counter problems
Quote:
If you are using the corrections that Rob posted, pwm06 will go forward for about 1/3 a second and then go in reverse forever. You also have a similar behavior for pwm07 (assuming you corrected the errors) |
Re: Odd counter problems
Quote:
Code:
if (armcounter == 15) //will raise arm.you said that the "motors weren't stopping" - of course they aren't: 0 is full reverse, 255 is full forward. if you want a motor to stop, set the PWM to 127. |
Re: Odd counter problems
Well i got it working i was messign with the code when i posted it so i accidently left stuff out. Thanks Tex helped a lot.
|
| All times are GMT -5. The time now is 05:59. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi