|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
Variables Change randomly
PLEASE I CANNOT TAKE THIS ANYMORE
Any functions I create return seemingly random numbers for example I put the function unsigned int Motor_Limit (int motor) { static unsigned int lmnewmotor; if(motor >= 254) { lmnewmotor = 254; } if(motor <= 0) { lmnewmotor = 0; } } In ifi_code.c and a prototype in ifi_code.h. I call it with motor1 = Motor_Limit((int) motor1); where motor1 is a pwm value that may be invalid. IT ALWAYS RETURNS 1919!!!! WHYYYYYYYYYY Is this a bug, I have the sensors version and kevin's site said that it was relatively bug free. We have a demo tomorrow and whenever I try to run my code the robot goes int a spasm. |
|
#2
|
|||||
|
|||||
|
Re: Variables Change randomly
How do you know what the return value is? I once spent hours trying to debug a routine that seemed to be returning the wrong value, only to discover that the error was in the line of code that prints the value.
But upon further inspection, the problem with your code is rather obvious to someone who hasn't been staring at it for hours. You merely forgot to return the newly computed value. ![]() Last edited by Alan Anderson : 26-01-2008 at 20:07. |
|
#3
|
|||
|
|||
|
I cannot adequately express my frustration with myself and the people here who I asked to check this for error. Thank you for pointing out that I DIDNT HAVE IT RETURN ANYTHING AAAAAAAAAAAAA
![]() |
|
#4
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
I looked at the link that was provided for a version of C18 other than 3.15 but couldn't find it. Can someone point to me where it is? >.< Any help appreciated.
-- Hank |
|
#5
|
||||||
|
||||||
|
Re: New C18 3.0+ Compatible FRC Code
The link in the first post for C18 has both 3.10 and 3.15.
|
|
#6
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Hi Kevin,
Our robot this year is using four different omnis that need 4 different encoders. The problem is we need to use four encoders this year. We used the encoders 3-6. We noticed that 3-4 were working but 5-6 only gave 0's and 1's. After looking at the ISR's for the encoders 5 and 6 i realized that 3 and 4 only worked on rising edge interrupt but 5 and 6 worked on both. After i changed 5 and 6 to be like 3 and 4 they worked but i do not understand why. there are four variables that i am using, two of which you use that are not declared anywhere. They are Encoder_3_State, Encoder_4_State, Encoder_5_State, and Encoder_6_State. Do you know where these variables are declared. Also why are the encoder 3-4 ISR's different from the encoder 5-6 ISR's. Thanks in advance, Julian |
|
#7
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
Encoder channels one and two are optimized for velocity control and will generate the least number of interrupts per encoder count (one per encoder count). These channels may have problems in position control applications because they can be fooled into thinking that the encoder shaft is rotating if the shaft happens to stop very near a phase-A transition and then wobbles back and forth across that transition. Encoder channels three and four are optimized for position control. For these channels, software examines both transitions of phase-A and can't be fooled into miscounting the number of encoder counts. The downside to using these channels is that for a given encoder, they will generate twice the number of interrupts as channels one and two (two per encoder count). Encoder channels five and six are just like channels three and four, but offer the bonus of increasing the precision of your encoder by a factor of two for free. Unlike channels one through four, which will increment or decrement on each rising (zero to one) transition, these two channels will increment or decrement on both transitions of phase-A. In other words, if you attach a 64 count-per-revolution encoder to one of these two channels, you'll read 128 counts when you rotate the shaft exactly one revolution. |
|
#8
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Kevin.
I'm trying to get the camera code going with the new 3.0 code. I'm not receiving ACKs or NCKs so it fails at init state 3 return value 131. serial_ports.h/c looks ready to go for port2 9600 baud and interrupts. Integrated camera.c terminal.c and tracking.c without any issues. Anything obvious come to mind reagrding serial port initialization? Chad |
|
#9
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Try setting serial port 2 to 115200 baud. Dave |
|
#10
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
I've been running into an odd problem with encoders.
Encoder 1 works perfectly fine during the teleop period, but does not give me anything during the autonomous one. Encoder 2 works in both teleop and autonomous. The initialization functions is called during both the autonomous and disabled initialization routines. I am running your latest code build, as far I as know, with MPLAB 8 and C18 3.10. While the robot is shipped already, I'd love to hear if you have any suggestions for what to try. It could be that the encoder is working, and is giving the correct signals, but is always printing a zero in my debug statement, and the code that is executing makes me believe that it is seeing a zero (as the count). But when I print out the count in the teleop mode, I get numbers that make sense. |
|
#11
|
|||
|
|||
|
New C18 3.0+ Compatible FRC Code
Kevin
Do you have access to an Explorer 16 board from Microchip?? |
|
#12
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
|
#13
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
this was done to gain experience with the tools and processors... |
|
#14
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
I'll try with last year's board, if I can get the time (we removed our encoders from the bot for this reason). |
|
#15
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
-Kevin |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does the camera code suits to all versions of MPLAB and C18? | razer | Programming | 3 | 04-01-2007 14:50 |
| Trying to follow C18 interrupt context code... | dcbrown | Programming | 5 | 21-12-2006 09:01 |
| Error w/ FRC code | JamesBrown | Programming | 2 | 08-01-2005 16:17 |
| Programming code Fix FRC | Ferazel2001 | Programming | 6 | 08-02-2004 02:46 |
| FRC default code | hedgehogger | Programming | 2 | 21-01-2004 18:41 |