![]() |
internal demons?
We're at our wits end! Two of my C++ students and I are programming with the banner sensors to control wheel rpms. The program will run correctly for a few runs and then inexplicably decide to switch motor outputs ( from pwm01 to pwm02 or whatever we have them set to) and inputs from the light sensors . This has been happening for several weeks. I have redownloaded the master control program, swapped controllers, used different digital inputs ( 6 and 7 or 1 and 2) to no avail. Has anyone had this happen to them before?
Thanks!! Team 539 programming group |
Re: internal demons?
Runtime errors are seldom, if ever, inexplicable.
Usually occur when memory gets hammered. Check to see if a string or array is getting written to past its declared end. |
Re: internal demons?
It's very difficult to help you without any specifics. Please post the section of code where you think the problem is. Or better yet, zip up all the .c and .h files and attach them to your post.
The limited description you have given really sounds like a software problem. But you won't get any real help without posting the code. Quote:
|
Re: internal demons?
First impulse is that you're using a high priority interrupt. Anything can go wrong when you do. Post any code related to interrupts, if you use them. This is assuming you're using interrupts with them, of course. I suppose there's no guarantee of this.
|
Re: internal demons?
Thanks for the replies to my vague question. Specifically what I'm seeing is outputs switched in the printf statements. Does anyone know of a good place to find info on them?
Example : (We are trying to print motor speed and banner sensor output) printf ( "%d/n", " pwm01 = ", pwm01 ); printf ( "%d/n", " rc_dig_01 = ", rc_dig_01 ); Output pwm01 = 1 rc_dig_01 = 145 // these numbers are switched How do we rewrite the printfs to get what we want? Thanks! |
Re: internal demons?
Quote:
Code:
printf(" pwm01 = %d/n", pwm01); |
Re: internal demons?
Quote:
Code:
printf(" pwm01 = %d\n", pwm01); |
Re: internal demons?
Quote:
First, that doesn't look like proper use of the printf function. I think you meant to write this: Code:
printf ( "pwm01 = %d/n", pwm01 );Secondly, you still haven't given very much information. You'll notice that all the replies so far (including my own) have been guesses and speculation. Please post the whole function at a minimum. However, if you post all the code, I guarantee that someone here will fix your problem for you right away. |
Re: internal demons?
Here is a pretty good explanation of the printf() function.
http://colton.byuh.edu/courses/tut/printf.pdf |
Re: internal demons?
Quote:
intended to be formatted with %d, to an int. Byte sized things get pushed on the stack as bytes, while printf is expecting an int. This is a vagary of the C18 compiler environment for the robot controller, and is non-standard. This addresses bad values printed by printf, but probably not the trouble you are trying to debug... |
Re: internal demons?
Quote:
So then, the proper code would be: Code:
printf ( "pwm01 = %d\r", (int)pwm01 ); |
Re: internal demons?
Quote:
|
| All times are GMT -5. The time now is 04:42. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi