Go to Post If full body suits can be made to fit properly, why do we have so many robots with saggy bumper covers? - GaryVoshol [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2008, 12:25
Speaker47 Speaker47 is offline
Registered User
FRC #2198
 
Join Date: Jan 2008
Location: Canada
Posts: 6
Speaker47 is an unknown quantity at this point
Question IR_Sensor Programming

Hi we are second year team, in Canada, we got stuck in programming the IR_Sensor, and we like to know if there is any hints or guides to programming the sensor with any default code available if you have programmed an IR Sensor, and have valid code that really works we would be glad to recieve help on this programming issue.
We already have a code attached with is message, if you could please look in the fast loop and verify what's wrong and inform us about our recent problems with the IR we will be grateful. Thanks again fro your time
Attached Files
File Type: zip T_Drive_IR_Trigger_Edited.zip (205.7 KB, 116 views)
  #2   Spotlight this post!  
Unread 29-01-2008, 13:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: IR_Sensor Programming

I see some things I'd code differently, but it's hard to find anything "wrong" until you define two things. First, what is it supposed to do? Second, what does it do instead? Try to give as much detail as you can.

If I were to guess at the problem, I'd say that you're trying to control pwms 13 and 15 in two different places.
  #3   Spotlight this post!  
Unread 29-01-2008, 13:33
Speaker47 Speaker47 is offline
Registered User
FRC #2198
 
Join Date: Jan 2008
Location: Canada
Posts: 6
Speaker47 is an unknown quantity at this point
Re: IR_Sensor Programming

Ok we have a major issue with the IR_Sensor

In the fast loop, in user_routines_fast.c, the program of the IR_sensor is not working ven though we tried to use digital inputs, there is no signal on the rc_dig_in17, Does anone have a possible code of the IR_Sensor that our team can try on our bot>> Thanks Again
  #4   Spotlight this post!  
Unread 29-01-2008, 13:37
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: IR_Sensor Programming

The default code has digital input 17 as an output rather than an input.
Change this in user_routines.c, User_Initialization().
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #5   Spotlight this post!  
Unread 29-01-2008, 13:46
Speaker47 Speaker47 is offline
Registered User
FRC #2198
 
Join Date: Jan 2008
Location: Canada
Posts: 6
Speaker47 is an unknown quantity at this point
Re: IR_Sensor Programming

I tried switching it too input, when we do it,

Even after we print the value on rcdig_in17 after using the remote there is no response.
  #6   Spotlight this post!  
Unread 29-01-2008, 14:38
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: IR_Sensor Programming

Here's an example of a working IR program built on the default code.
http://team358.org/files/programming...or_example.zip

Everything is contained within user_routines.c, Default_Routine().

It expects the four IR digital inputs to be connected to digital inputs 15,16,17,18. If any are not connected properly it will not do anything (for safety reasons).

The user byte display on the OI will show 1, 2, 4, or 8 for the different IR commands received.
If you see anything else, then the digital pins are not connected properly.

P.S.
This code is set to work with a common ground (both the Robot Controller and the IR sensor powered from the same battery). If you are using a separate battery the code will need additional checks in two places for "15"
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 29-01-2008 at 14:50.
  #7   Spotlight this post!  
Unread 29-01-2008, 20:34
Speaker47 Speaker47 is offline
Registered User
FRC #2198
 
Join Date: Jan 2008
Location: Canada
Posts: 6
Speaker47 is an unknown quantity at this point
Exclamation Re: IR_Sensor Programming

We have tried, it with loading this code to the main microprocessor, and there is no response...

Anyway, is it possible for you to elaborate on what you mean by:


Quote:
The user byte display on the OI will show 1, 2, 4, or 8

I thought each port in the digital input ports should get a value of either 1 or 0 like a binary system?????
  #8   Spotlight this post!  
Unread 29-01-2008, 20:51
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: IR_Sensor Programming

On the Operator interface if you hit mode (middle button under the team number)one of the things that comes up is like "u015". You set the user byte to what you want that to display. The default code sets that to the backup battery voltage.
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
  #9   Spotlight this post!  
Unread 29-01-2008, 23:38
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: IR_Sensor Programming

What Will said.

That code plays a little trick with the digital inputs and combines the four (0 or 1) inputs into a single four-digit binary number, where each digit represents one of the four digital inputs.
So the numbers you get are:
Code:
binary  decimal
0000      0
0001      1
0010      2
0100      4
1000      8
If you get any other number it means the digital inputs aren't connected correctly. For instance, if the IR board isn't connected at all you will get
Code:
binary  digital
1111     15
So that can help you to debug bad connections and see it on your OI display.

P.S. When you first use the OI Select button to switch to User Mode you'll see "u015" or something similar displayed for a couple of seconds. This is the Master Code version loaded on the Robot Controller.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 30-01-2008 at 09:31.
  #10   Spotlight this post!  
Unread 30-01-2008, 18:57
Red Mage's Avatar
Red Mage Red Mage is offline
Owner of Holistic Omniscience
FRC #1546 (Chaos Inc)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 35
Red Mage is on a distinguished road
Send a message via AIM to Red Mage
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?
__________________
Don't Blink. Blink and you're dead. Don't turn your back. Don't look away. And don't Blink. Good Luck.
  #11   Spotlight this post!  
Unread 30-01-2008, 19:29
Speaker47 Speaker47 is offline
Registered User
FRC #2198
 
Join Date: Jan 2008
Location: Canada
Posts: 6
Speaker47 is an unknown quantity at this point
Thumbs down Re: IR_Sensor Programming

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
  #12   Spotlight this post!  
Unread 31-01-2008, 12:14
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: IR_Sensor Programming

Quote:
Originally Posted by Red Mage View Post
...a mysterious port j. We found where it is in the code but cannot understand how to use it.
Here's the background on the mysterious PORTJ.

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
You'll notice all the values we use come through some register, such as:
-- 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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 01-02-2008 at 10:23. Reason: tense
  #13   Spotlight this post!  
Unread 31-01-2008, 20:00
Speaker47 Speaker47 is offline
Registered User
FRC #2198
 
Join Date: Jan 2008
Location: Canada
Posts: 6
Speaker47 is an unknown quantity at this point
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??????
  #14   Spotlight this post!  
Unread 31-01-2008, 23:02
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
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++
2. Take a look at how they have the relays in the default code under the default_Routine() function
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
  #15   Spotlight this post!  
Unread 01-02-2008, 18:24
Red Mage's Avatar
Red Mage Red Mage is offline
Owner of Holistic Omniscience
FRC #1546 (Chaos Inc)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 35
Red Mage is on a distinguished road
Send a message via AIM to Red Mage
Re: IR_Sensor Programming

Quote:
Originally Posted by Mark McLeod View Post
Here's the background on the mysterious PORTJ.

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
You'll notice all the values we use come through some register, such as:
-- 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.
Thanks, unfortunately by this time Miss Reiss told us to focus on the pneumatics since we haven't done that yet.
__________________
Don't Blink. Blink and you're dead. Don't turn your back. Don't look away. And don't Blink. Good Luck.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 19:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi