![]() |
Re: encoder vs. motor
Quote:
Gnd goes to the outside PWM pin, where it's marked "Blk" The A and B outputs go to the inside pins. I don't remember which I/Os are used for the signals, but it will be documented in the readme.txt file and at the top of the encoder.c source file. -Kevin |
Re: encoder vs. motor
Quote:
|
Re: encoder vs. motor
Quote:
-Kevin |
Re: encoder vs. motor
in ifi_aliases.h, there is a reference to adc.h (#include <adc.h>). I looked in the directory with all the c and h, etc. files, and didn't find a file called adc.h. this is a problem, because the code won't compile with mplab untill I find out why it can't find that particular file. can I remove it from the ifi-aliases.h file?
this is the exact error message: "E:\Robotics\defaultcode\FrcCode\ifi_aliases.h :18: unable to locate 'adc.h'" |
Re: encoder vs. motor
This seems to occur frequently. Unless you didn't install MCC18 (which is a requirement), it should be there.
I believe adc.h is the first 'standard' include; so a misconfig is the most likely cause. Check to make sure MPLAB has the right include dir (by default it is C:\mcc18\h ). |
Re: encoder vs. motor
Quote:
or you can search for "adc.h" to get more hits. |
Re: encoder vs. motor
hi,
I've been going through a tutorial for using interrupts ("interrupts for dummies") and another one titled ("quadrature encoders"). this may be a vague question, I'm not sure. but what is "Port_B"? and what is "0xFF". also, what are state machines (based on the current encoder position). are they used to determine what part of the "cycle" the encoder is going through. lastly, just a thought, is does Port_B tell which of the 4 interrupts (4-7 was fired?), because these particular four are all identified under the "same name." it seems that Port_B is used to reference interrupts 4-7, and then the 0xFF, where "FF" identifies which of those four ports was interrupted? anything you can tell me to simplify this would be appreciated, thanks, Stephen P. |
Re: encoder vs. motor
also, if you could explain this segment of code.
Code:
#pragma code InterruptVectorLow = LOW_INT_VECTOR // put this code at address 0x182: what is the purpose of putting the "#" symbol in front of it 3: what are _asm and _endasm thank you so much for the help, Stephen. |
Re: encoder vs. motor
Stephen,
Quote:
Quote:
"Port_B" is a working copy of the input port where the state of the interrupt bits can be read. You need to take a snapshot because their value may change at any time. If, for example, interrupt 6 changes from a zero to a one and then quickly changes back to a zero before you get around to checking it's state, you're stuck servicing an interrupt without knowing which of the four inputs caused it. This is why I grab a copy of PORTB first off. "Old_Port_B" is the state of the port the last time an interrupt was generated. Because four inputs are mapped to one interrupt, you need this information to determine which of the four inputs changed and caused the interrupt. "Port_B_Delta" is the exclusive-or of the above two variables. The exclusive-or of two bits returns a one if the two bits are different, zero if they're the same. Later on, I check all four bits to see if they're a one, meaning that they've changed since the last interrupt was generated. You need to check each bit because one may have changed between the time another bit caused the current interrupt and the time you sampled PORTB. If you didn't do this, you might miss a valid interrupt-causing event, which is a really bad thing to happen. Quote:
Quote:
Quote:
-Kevin |
Re: encoder vs. motor
Stephen,
Quote:
Quote:
Quote:
-Kevin |
Re: encoder vs. motor
I was reading about extern and static variables. I realize that it's considered bad coding technique to declare extern variables, because they are declared outside functions. however, I need this variable available to interrupts.c and user_routines_fast.c. however, I only want this variable to have its value assigned once. where should I place a variable that can be used in both these files, and have the variables value (unsigned int phase = 1000) assigned only once. I did search on google, but it doesn't exactly tell me about how the structure of the default code is set up to work with and where to put such a variable so it will be available to these particular files.
by the way, the purpose of the variable, is so when interrupt #1 fires, 1 is added to its value, and when interrupt #2 fires, 1 is subtracted from its value. the reason it needs to be available to user_routines_fast.c, is because that is where I want to place my functions, as it would be confusing to have the interrupts.c file running a function controlling the robot and a function in user_routines_fast.c controlling the robot as well. thanks a lot, Stephen. |
Re: encoder vs. motor
Quote:
The variable should be declared in one file and extern'd in all the others you need it in. |
Re: encoder vs. motor
where does mplab ide 7.00 send the mcc18.exe compiler file? I did the default settings for the entire installation. where is this at? keep in mind that I don't have a mcc18 folder in the root of the drive. the mplab files were installed into the program files folder. thanks, Stephen.
|
Re: encoder vs. motor
Quote:
Quote:
|
Re: encoder vs. motor
I've been using Kevin Watson's interrupt template code. I want to have a variable increment every time the interrupt fires. that's not a problem. however, is there a static variable type available that I can use between files? I'm not aware of such a thing. also, does the code in interrupts.c execute first, or the code in user_routines_fast.c go first? this affects whether I use the interrupts.c file to handle the motor speed or the user_routines_fast.c file to handle the speed of the motor. if the user routines file comes second, that would be the case where I need the variable. I'm willing to bet there's an easier way, but this is what I've come up with so far. I would use Kevin's template for encoders but it supports two encoders for the wheels, when I want to use the one we already have set up on digitals 1 and 2 with one motor. we'll probably have to use his eventually on the wheels in addition to this encoder.
thanks, Stephen. |
| All times are GMT -5. The time now is 22:26. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi