|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: IR_Sensor Programming
Hi, this isn't about your code but Mark McCleod mentioned at his workshop a mysterious port j. We found where it is in the code but cannot understand how to use it. Any help?
|
|
#2
|
|||
|
|||
|
Hi,
We got the code to work, the only problem was that after each case segment the pwms needed to be generated, which is why it wasn't working. The code only works in PORTJ for us, and all the digital inputs need to be read at one time, for the IR to work. We are working on a few modifications, to the code...Finally, the code can be put anywhere.... However, we are running into further issues, if anyone one could help us find a way in MPLAB to time how long motors need to be on (Milliseconds)... So, basically, the equivalent of the "wait" function in EasyC. We need to know this for our autonomous code, that we want to run in our bot. Thank You For All Your Help |
|
#3
|
|||||
|
|||||
|
Re: IR_Sensor Programming
Quote:
The robot system variables we use (e.g., rc_dig_in18) are just aliases for connections or "windows" into the real PIC hardware. In the hardware, 8-bit registers are wired to hold the constantly sampled state from the pins (or the output state we want) and our aliases are just simpler ways to look at individual bits within these registers, one bit per digital I/O pin. If you look in the file ifi_aliases.h you'll see these aliases defined for our 18 digital inputs: Code:
#define rc_dig_in01 PORTBbits.RB2 #define rc_dig_in02 PORTBbits.RB3 #define rc_dig_in03 PORTBbits.RB4 #define rc_dig_in04 PORTBbits.RB5 #define rc_dig_in05 PORTBbits.RB6 #define rc_dig_in06 PORTBbits.RB7 #define rc_dig_in07 PORTHbits.RH0 #define rc_dig_in08 PORTHbits.RH1 #define rc_dig_in09 PORTHbits.RH2 #define rc_dig_in10 PORTHbits.RH3 #define rc_dig_in11 PORTJbits.RJ1 #define rc_dig_in12 PORTJbits.RJ2 #define rc_dig_in13 PORTJbits.RJ3 #define rc_dig_in14 PORTCbits.RC0 #define rc_dig_in15 PORTJbits.RJ4 #define rc_dig_in16 PORTJbits.RJ5 #define rc_dig_in17 PORTJbits.RJ6 #define rc_dig_in18 PORTJbits.RJ7 -- PORTB for the interrupts on digital inputs 1-6 -- PORTH for inputs 7-10 -- PORTJ for inputs 11-13 and 15-18 -- PORTC for input 14 We can use any of these registers we wish or just use the aliases everyone's accustomed to. PORTH also has four pins grouped together that we could easily use by masking out (using the "&" operator) the other upper four bits in that register. The demo code wants only the last four bits of PORTJ (15-18), so a simple way to eliminate the other unwanted values is to just truncate them by shifting the four bits we want to the right thereby pushing the four bits we don't want out of the variable altogether, e.g., 10001111 >> 4 becomes 00001000 The trick demonstrated with PORTJ allows the code to capture all the pin values at once in an instant of time. It just illustrates the potential window of error that could occur if the IR sensor changed the signals while we were testing them one at a time. P.S. The excrutiating detail on PORTJ is described in the PIC18F8722_data_sheet.pdf that came on the CBOT compact disk in the KOP. Last edited by Mark McLeod : 01-02-2008 at 10:23. Reason: tense |
|
#4
|
|||
|
|||
|
Re: IR_Sensor Programming
Great the PortJ problem is fixed Thanks Alot....
But We have other difficulties, 1. We need to find a way to time how long the motors will run in autonomous, something like the "wait" function in Easy C.. 2. Also, can anyone tell me how to turn on and off relay motors that I might use in autonomous?????? |
|
#5
|
||||
|
||||
|
Re: IR_Sensor Programming
1. Add a counter or something similar:
Code:
if(x<100)
pwm01=pwm02=150;
if(x>100
pwm01=pwm02=127;
x++
|
|
#6
|
||||
|
||||
|
Re: IR_Sensor Programming
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming in Python and Explaination of Programming | roboxking | Programming | 22 | 07-01-2008 16:08 |
| programming motors with programming kit | BorisTheBlade | FIRST Tech Challenge | 4 | 01-11-2005 19:03 |
| programming | great_one411 | Programming | 2 | 15-02-2003 08:59 |
| programming | great_one411 | General Forum | 1 | 14-02-2003 11:28 |
| Programming | archiver | 2000 | 1 | 23-06-2002 22:34 |