Go to Post when things start to get a little stressful, "FIRST: Fun Is Required. So Tolerate!" - Rich Kressly [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-2004, 08:51
pagemauck pagemauck is offline
Registered User
#0437
 
Join Date: Oct 2003
Location: richmond, va.
Posts: 25
pagemauck is an unknown quantity at this point
help! Am really stuck!!!!

Have been trying for a week to get digital input while in autonomous mode. After the Getdata line in void User_autonomous_Code we have

if (rc_dig_in06 == 0) pwm01=255: else pwm01=127;

We have the light sensor hooked up to digital input #6. It appears to be working and we have adjusted sensitivity on it. We have also swapped out the sensor. Simple lines like pwm01=255; work fine in our program. I have tried moving this line in all places in the program but it doesn't help.

My students want to write code to read wheel speed using this sensor, but I am frustrated I can't get input.

Any ideas would be very much appreciated!!!
  #2   Spotlight this post!  
Unread 29-01-2004, 10:10
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: help! Am really stuck!!!!

I dont know if your code is correct or not, but I do know that in the past, if you set a pwm output to 255 then all sorts of weird and bizarre things happened.

I think the pwm output SW that is buried in the code where we dont see it uses pwm values of 255 to define the start of the data stream, so if you set a pwm to 255, the output stream starts over, putting variables where you didnt intend them to go.

I havent heard that this is no longer true - but it really did make the bot totally wack out if you did it last year, so its possible this is why its not doing what you want.
  #3   Spotlight this post!  
Unread 29-01-2004, 10:17
pagemauck pagemauck is offline
Registered User
#0437
 
Join Date: Oct 2003
Location: richmond, va.
Posts: 25
pagemauck is an unknown quantity at this point
Re: help! Am really stuck!!!!

Quote:
Originally Posted by KenWittlief
I dont know if your code is correct or not, but I do know that in the past, if you set a pwm output to 255 then all sorts of weird and bizarre things happened.

I think the pwm output SW that is buried in the code where we dont see it uses pwm values of 255 to define the start of the data stream, so if you set a pwm to 255, the output stream starts over, putting variables where you didnt intend them to go.

I havent heard that this is no longer true - but it really did make the bot totally wack out if you did it last year, so its possible this is why its not doing what you want.
We set the pwms to 255 ( isn't this the max allowable speed?) in regular code and I thought it worked OK. I'll change this and try it , though.
  #4   Spotlight this post!  
Unread 29-01-2004, 10:22
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: help! Am really stuck!!!!

lat year you had to be careful to limit them to 254 max - Im not sure its the same with the new RC, but unless an expert pipes-in and says otherwise, its worth a try.
  #5   Spotlight this post!  
Unread 29-01-2004, 10:23
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,820
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: help! Am really stuck!!!!

Quote:
Originally Posted by pagemauck
Have been trying for a week to get digital input while in autonomous mode. After the Getdata line in void User_autonomous_Code we have

if (rc_dig_in06 == 0) pwm01=255: else pwm01=127;

We have the light sensor hooked up to digital input #6. It appears to be working and we have adjusted sensitivity on it. We have also swapped out the sensor. Simple lines like pwm01=255; work fine in our program. I have tried moving this line in all places in the program but it doesn't help.

My students want to write code to read wheel speed using this sensor, but I am frustrated I can't get input.

Any ideas would be very much appreciated!!!

There are a couple of things wrong with the line as you posted it. The value 255 is invalid and there should be no colon after "254". It really should be:

Code:
if (rc_dig_in06 == 0) 
  pwm01=254;
else 
  pwm01=127;

or if you really like to run things together:

if (rc_dig_in06 == 0) pwm01=254; else pwm01=127;
To help you debug it add:

printf("input 6 = %d\n", (int) rc_dig_in06 );

You can at least see and confirm the functioning of the light sensor.

If you'd like to send your code, PM me and I'll help you debug the problem further.

[edit]
Corrected my error (thanks Dav). I wasn't thinking straight this morning.
[/edit]
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 29-01-2004 at 11:47.
  #6   Spotlight this post!  
Unread 29-01-2004, 10:26
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
Re: help! Am really stuck!!!!

Quote:
Originally Posted by pagemauck
Have been trying for a week to get digital input while in autonomous mode. After the Getdata line in void User_autonomous_Code we have

if (rc_dig_in06 == 0) pwm01=255: else pwm01=127;

We have the light sensor hooked up to digital input #6. It appears to be working and we have adjusted sensitivity on it. We have also swapped out the sensor. Simple lines like pwm01=255; work fine in our program. I have tried moving this line in all places in the program but it doesn't help.
Your code looks fine (except for the ":" but I assume that is a typo)

Digital inputs are "IN" by default. Is there any chance you initialized that bit for output and forgot it? That is PORTB6, which is one of the "change of state" interrupt inputs.

Does your light sensor have active outputs? I.e. is it a banner sensor? If you are using analog output device (e.g. an off-the-shelf photo-reflex sensor) you need to be aware of the type of input you are driving. It turns out the PIC processor has a variety of input types that depend upon which input pin you are using. In particular, port B pins are TTL and not suitable for analog inputs. Other bits are "Schottky" and *are* suitable for direct drive by an analog input. Anyway, that is a minor issue to be addressed *after* you figure out the basic code.

Last edited by Larry Barello : 29-01-2004 at 10:30.
  #7   Spotlight this post!  
Unread 29-01-2004, 11:32
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: help! Am really stuck!!!!

Quote:
Originally Posted by Mark McLeod
...and there should be no colon (or semicolon) after "254". It really should be:

Code:
if (rc_dig_in06 == 0) 
  pwm01=254
else 
  pwm01=127;

or if you really like to run things together:

if (rc_dig_in06 == 0) pwm01=254 else pwm01=127;
umm... no. There should be a semicolon after the 254 - it is the end of an instruction. the correct format is this:

Code:
if(rc_dig_in06 == 0)
    pwm01 = 254;
else
    pwm01=127;
(you can always rearrange that however you wish with tabs, spaces, and line breaks)

Remember, the if-else statement is a control structure, and thus does not count as part of a single instruction. The two instructions here are "pwm01 = 254" and "pwm01 = 127", each of which needs to be ended with a semicolon as shown.

You may have been confused with the colon because of the if-else shorthand notation - for instance, the code below does the exact same thing as the longer if-else below:

Code:
pwm01 = ( rc_dig_in06 ? 127 : 254 );
if you are new to programming, though, stick with the longer if-else statement, as it is easier to read and use.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)

Last edited by deltacoder1020 : 29-01-2004 at 11:36.
  #8   Spotlight this post!  
Unread 29-01-2004, 12:11
pagemauck pagemauck is offline
Registered User
#0437
 
Join Date: Oct 2003
Location: richmond, va.
Posts: 25
pagemauck is an unknown quantity at this point
Re: help! Am really stuck!!!!

Thanks for the ideas. My colon was a typo. I meant a semi-colon which works fine in all of the other statements we have. The light sensor we are using is the same one as last year which worked great with PWBASIC and the old controller. I guess I was wondering if we were doing something stupid ( which the 255 sounds like it is ).
  #9   Spotlight this post!  
Unread 29-01-2004, 12:38
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: help! Am really stuck!!!!

255 is one of those snakes

with fangs

that dont really stand out until it bites you :c)
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
guy stuck in toilet! robot180 Chit-Chat 8 14-11-2003 22:27
Radisson Inn Astrodome Mike Martus Championship Event 49 13-05-2003 21:03
Has any one stuck a drill motor in the FP trans? Lotownvw Motors 15 21-04-2003 23:57
any one stuck @ home instead of nats? Robocardgrl5 Championship Event 22 28-04-2002 08:13
Gm Patrick Canale Championship Event 87 25-06-2001 11:13


All times are GMT -5. The time now is 02:04.

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