Go to Post We are making this up as we go along - please don't confuse us by telling us the way that it really should be done. - dlavery [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 10:44.

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