Go to Post [In FIRST]...Arab and Israeli students speak on the same level, because they are alliance partners. - Tottanka [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-03-2011, 20:14
TomH's Avatar
TomH TomH is offline
Registered User
FRC #0087
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2009
Location: New Jersey
Posts: 53
TomH has a spectacular aura aboutTomH has a spectacular aura aboutTomH has a spectacular aura about
Encoder and Ultrasonic Help

A few of us got together the other day and worked on a few different things. Two of those things were quad encoders and a ultrasonic sensor.

We had readouts for both but only one seemed to be giving a readout of a value. We were only able to count up to 256ish on one encoder though. How would we properly code and wire these encoders so they could work properly?
Below is some of the code that we have been using to test:

Quote:
import edu.wpi.first.wpilibj.Encoder;

Encoder encoderleft;
Encoder encoderright;

encoderleft = new Encoder (4,5);
encoderright = new Encoder (6,7);
double inchesPerPulse = 0.1;*


double lDistance = encoderleft.getDistance();
int lCount = encoderleft.get();

double rDistance = encoderright.getDistance();
int rCount = encoderright.get();

*Values for inches per pulse is a random number-Asterisks not in real code
As mentioned above, our ultrasonic sensor didn't seem to want to work at all. We were getting infinity on our readouts, and only values when we messed around with the pwm connections. How would we code and wire up the ultrasonic so that it would work as well?
Below is some of the code we used to test:

Quote:
import edu.wpi.first.wpilibj.Ultrasonic;

Ultrasonic ultrasonic1;

ultrasonic1 = new Ultrasonic (8,9);

System.out.println("Ultrasonic distance = " + ultrasonic1.getRangeInches());
Any help is greatly appreciated, and thanks in advance.

-Tom H

Last edited by TomH : 25-03-2011 at 20:20.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-03-2011, 21:57
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Encoder and Ultrasonic Help

What ultrasonic sensor are you using? The ultrasonic class is meant to be used only with a certain model - most teams are using MaxBotix sensors, and for those all that is used is the AnalogInput class.
__________________
Attending: MN Duluth Regional
Reply With Quote
  #3   Spotlight this post!  
Unread 25-03-2011, 22:05
TomH's Avatar
TomH TomH is offline
Registered User
FRC #0087
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2009
Location: New Jersey
Posts: 53
TomH has a spectacular aura aboutTomH has a spectacular aura aboutTomH has a spectacular aura about
Re: Encoder and Ultrasonic Help

We are using the Vex Ultrasonic sensors
Reply With Quote
Reply


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


All times are GMT -5. The time now is 12:35.

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