Go to Post We're college students. We appreciate free. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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 24-02-2004, 18:34
dez250 dez250 is offline
54... What a good number!
no team
 
Join Date: Dec 2002
Rookie Year: 2000
Location: Upstate NY / Manchester, NH
Posts: 1,721
dez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond reputedez250 has a reputation beyond repute
Send a message via AIM to dez250
Potentiometer Question, we need help!

The programming group of my team wanted me to post the following question to see if anyone might recognize the problem.

"My programmers and I have been having a bit of a time trying to get the potentiometers on our robot to work. the two joystick drives are working properly, but a third analog input on p3_y (using pins 1 and 6) and a pot on the robot itself (assigned using pot = Get_Analog_Value(rc_ana_in01); ) are both giving me values ranging from -3000 to 20000. Unless I'm horribly misinformed, this can't be right. I imagine there's a function or two I'm missing that would format the input properly, but I can't find what it is. Any ideas?"
__________________
#5

-Michael Dessingue
  #2   Spotlight this post!  
Unread 24-02-2004, 20:17
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
Re: Potentiometer Question, we need help!

You don't use the function Get_Analog_Value() to get the analog values from the OI. They are received by the control system by the GetData() function (or whatever it is), and are already available to the programmers. The Get_Analog_Value() function is used to read analog values from the RC's analog input pins.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #3   Spotlight this post!  
Unread 24-02-2004, 20:22
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: Potentiometer Question, we need help!

You're right using Get_Analog_Value(rc_ana_in01); . Now I dont really remember how this is done, but we had the same problem. I can help you with this much, it should not be declared as a 10 digit number or whatever, you just want a 2-3 digit number. I'll try a rough example, it might click in some of your brains.

int analog1; /*This is declared up in the program)


analog1 = Get_Analog_Value(rc_ana_in01) << 2);

/*end*/

Something like that. Somebody correct me or explain better. Sorry I'm out of my brains right now. . But I hope this gets you somewhere at this moment.
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #4   Spotlight this post!  
Unread 24-02-2004, 21:36
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: Potentiometer Question, we need help!

Here's what you do.
If the pot is hooked up on port3 on the y-axis try this.

int pot;
pot = p3_y;

You only use the GetAnalogValue() func when you are reading values from the controller (as previously mentioned).
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
  #5   Spotlight this post!  
Unread 24-02-2004, 21:58
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Re: Potentiometer Question, we need help!

Quote:
Originally Posted by dez250
The programming group of my team wanted me to post the following question to see if anyone might recognize the problem.

"My programmers and I have been having a bit of a time trying to get the potentiometers on our robot to work. the two joystick drives are working properly, but a third analog input on p3_y (using pins 1 and 6) and a pot on the robot itself (assigned using pot = Get_Analog_Value(rc_ana_in01); ) are both giving me values ranging from -3000 to 20000. Unless I'm horribly misinformed, this can't be right. I imagine there's a function or two I'm missing that would format the input properly, but I can't find what it is. Any ideas?"
Are you printing these values to see that range? Did you cast your variable -- e.g., printf ("Pot values is: %d\n", (int) pot_value);

Quote:
it should not be declared as a 10 digit number or whatever, you just want a 2-3 digit number. I'll try a rough example, it might click in some of your brains.

int analog1; /*This is declared up in the program)
...
analog1 = Get_Analog_Value(rc_ana_in01) << 2);

Something like that. Somebody correct me or explain better. Sorry I'm out of my brains right now. . But I hope this gets you somewhere at this moment.
It should be (on the RC) a 10 *bit* number (0-2^10-1). You may want to convert this to an 8 bit number for some reason (compatible with pwm outputs), in which case you can shift it. However, it should still be a positive 10 bit value lacking such a conversion.

It seems most likely that the problem is a lack of casting -- I assume the variables are declared as unsigned integers, in which case it can't be a negative number (though it might print out as such without proper casting).

Last edited by mtrawls : 24-02-2004 at 22:59.
  #6   Spotlight this post!  
Unread 09-03-2004, 04:23
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Potentiometer Question, we need help!

Your 10 bit ADC value may be left justified in the 16 bit integer (in the most significant bits). To right justify the ADC value, add this statement to your initailization:

Code:
	ADCON2bits.ADFM = 1; //Right justify the 10 bits in all ADC
More info on this register is availiable on page 215 of 380 of the PIC 18 datasheet (Lit #39609b) on the Microchip website. Hope it helps you Mike.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
  #7   Spotlight this post!  
Unread 09-03-2004, 07:15
Unsung FIRST Hero
Al Skierkiewicz Al Skierkiewicz is offline
Broadcast Eng/Chief Robot Inspector
AKA: Big Al WFFA 2005
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1996
Location: Wheeling, IL
Posts: 10,798
Al Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond repute
Re: Potentiometer Question, we need help!

Dez,
I am no help in programming but I did want to make sure that you have the pot connected correctly. The RC wires the pot between +5 and ground with the wiper going to the analog input. The OI does not use the ground return, just simply a series varying resistance.
__________________
Good Luck All. Learn something new, everyday!
Al
WB9UVJ
www.wildstang.org
________________________
Storming the Tower since 1996.
  #8   Spotlight this post!  
Unread 09-03-2004, 08:55
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: Potentiometer Question, we need help!

Quote:
Originally Posted by TeknoBramha
analog1 = Get_Analog_Value(rc_ana_in01) << 2);

/

I think your 'shift' is the wrong way - that is a shift left, which will push the 10 bit ADC input up to a 12 bit number;

usually you want to knock the Analog inputs down to 8 bits from 10, a shift right (arrows to the right) >>2;

:^);
  #9   Spotlight this post!  
Unread 09-03-2004, 13:03
pryoplasm's Avatar
pryoplasm pryoplasm is offline
Pit Crew/Electrical
AKA: Russ
#0069
 
Join Date: Jan 2004
Location: Quincy, Ma
Posts: 73
pryoplasm can only hope to improve
Re: Potentiometer Question, we need help!

Quote:
Originally Posted by Al Skierkiewicz
Dez,
I am no help in programming but I did want to make sure that you have the pot connected correctly. The RC wires the pot between +5 and ground with the wiper going to the analog input. The OI does not use the ground return, just simply a series varying resistance.

i agree, sounds like a problem with the mounting. also, this is a 10 trun potentiaometer, right? if it is bigger, that could explains some of the funky values...
__________________
Cut these eyes, but I will see,
Kiss these lying lips for me,
Stroke this skin, and I will kneel,
Brutalize me, I will heal...
-KMFDM
  #10   Spotlight this post!  
Unread 29-03-2004, 11:14
TomJoseph TomJoseph is offline
The Pirate
#0247 ('Da Bears)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Michigan
Posts: 3
TomJoseph is an unknown quantity at this point
Send a message via ICQ to TomJoseph Send a message via AIM to TomJoseph
Re: Potentiometer Question, we need help!

Quote:
Originally Posted by KenWittlief
I think your 'shift' is the wrong way - that is a shift left, which will push the 10 bit ADC input up to a 12 bit number;

usually you want to knock the Analog inputs down to 8 bits from 10, a shift right (arrows to the right) >>2;

:^);
You'll also want to typecast it into an unsigned char, just for safe keeping:
Code:
unsigned char pot1;
pot1 = (unsigned char) (Get_Analog_Value(rc_ana_01) >> 2);
  #11   Spotlight this post!  
Unread 18-04-2004, 23:03
Neal Turett Neal Turett is offline
Registered User
#0201
 
Join Date: Nov 2002
Location: Rochester Hills
Posts: 34
Neal Turett is on a distinguished road
Re: Potentiometer Question, we need help!

If you want to read a value from a potentiometer wired into where the p3_y would normally be, you can just access p3_y. The OI handles the analog-to-digital conversion and returns an 8bit value, in the form on an unsigned char.

If you are reading a value from your inputs
Code:
Get_Analog_Value(rc_ana_in01)
is the correct function. This will return a 10-bit number. To scale this to 8 bits, only read the bits 2-9. The simplest way to do this is divide by 4. The syntax to output this is
Code:
printf("Label: %3d", (int)(Get_Analog_Value(rc_ana_in01) / 4))
Hope this helps.
  #12   Spotlight this post!  
Unread 25-08-2004, 13:53
Sparks333's Avatar
Sparks333 Sparks333 is offline
Robotics Engineer
AKA: Dane B.
FRC #1425 (Wilsonville Robotics)
Team Role: Alumni
 
Join Date: Feb 2004
Rookie Year: 2003
Location: Wilsonville, Oregon
Posts: 184
Sparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of light
Send a message via AIM to Sparks333
Re: Potentiometer Question, we need help!

I would like to point out that this is an electronics thread. Is programming moving in on our turf?

-Sparks
__________________
ICs do weird things when voltage is run out of spec.

I love to take things apart. The fact that they work better when I put them back together it just a bonus.

http://www.ravenblack.net/random/surreal.html
  #13   Spotlight this post!  
Unread 25-08-2004, 14:32
Matt Attallah's Avatar
Matt Attallah Matt Attallah is offline
Now at sub 14's in a 5000lb vehicle
AKA: Maher Attallah
FRC #0005 (Robocards)
Team Role: Alumni
 
Join Date: Sep 2001
Rookie Year: 2000
Location: Detroit area, Michigan
Posts: 1,660
Matt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond reputeMatt Attallah has a reputation beyond repute
Send a message via AIM to Matt Attallah Send a message via MSN to Matt Attallah Send a message via Yahoo to Matt Attallah
Re: Potentiometer Question, we need help!

The more the merrier!!

I think it's all right for a slip up here and there...
__________________
That rug really tied the room together...
  #14   Spotlight this post!  
Unread 25-08-2004, 14:50
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Potentiometer Question, we need help!

The OI pots are only 8 bits; chars. The Analog inputs are 10 bits. so you do this:
Code:
unsigned char JoyPot;
unsigned int BotPot;
unsigned char BotPot2; //For comparison with the joystick

JoyPot = p3_y;
BotPot = Get_Analog_Value(rc_ana_in01);
BotPot2 = (unsigned char)(BotPot >> 2);
BotPot2 is now 8 bits; it can be used to compare with JoyPot.

By the sound of it, they're using signed long, which is 2-4 times larger than necessary (not to mention signing, which is a little weird).

[And I agree that this thread is a little misplaced]
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
MIM's question of the day on programming. Gene F Programming 3 24-02-2004 16:32
A question about control system options computhief263 Control System 7 04-02-2004 14:46
MnM EASY Question of the Day Winners! Mike Bonham General Forum 22 03-05-2002 21:21
Chief Delphi Site Question Mike Bonham General Forum 1 16-02-2002 22:18
Rookie Programmer has question about the default code DanL Programming 3 26-01-2002 19:59


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

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