Go to Post However, the skill of calculating things by hand and sketching by hand is something that we should continue to teach the youth (until my netbook can run Inventor :D) - Zach O [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 19-02-2012, 18:20
ekgordon2 ekgordon2 is offline
Registered User
FRC #2022
 
Join Date: Jan 2012
Location: Buffalo Grove
Posts: 5
ekgordon2 is an unknown quantity at this point
US Digital E4P Encoder Not Giving Pulse Data

Here is the problem: after connecting a US Digital Encoder, it doesn't seem to be returning any pulse data.

I wired it up by attaching Ground, 5V, and Channel A to the three prongs at Digital IO port 5 on the digital sidecar, and then connected Channel B to the signal prong at Digital IO port 6.

Here is the code I used:
Code:
#include "WPILib.h"

Encoder *myEncoder;
myEncoder = new Encoder(5,6);
myEncoder->Start();
myEncoder->SetDistancePerPulse(1); // Just something for testing.

//To print on the NetConsole Screen:
printf("Speed: %f\n", myEncoder->GetRate());
Is there anything wrong with either the wiring or the code? Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2012, 22:11
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: US Digital E4P Encoder Not Giving Pulse Data

How are you turning the shaft the encoder is on? How long are you waiting between calling Start() and calling GetRate()? The rate might be slow enough that it's effectively zero. What does it return for the distance?
Reply With Quote
  #3   Spotlight this post!  
Unread 20-02-2012, 01:26
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: US Digital E4P Encoder Not Giving Pulse Data

Similar to Alan's comment - but if not obvious...you need to call "GetRate()" again and again in your OperatorControl() loop. Are you able to get printf() data via NetConsole? Or are you using SmartDashboard? If so, make sure you print out these items so you can get a sense of whether or not it is working properly. Also, if GetRate() is returning nothing of interest, I'd suggest calling GetRAW() and printing that out or plotting it on SmartDashboard. GetRAW should be an ever-increasing counter.

Now, if you're doing all that and it's not working, here's what we did to diagnose a bad hardware situation...

If your inputs from the Encoder are on digital IO's 5 and 6, plot the values of those digital inputs on 5 and 6 to ensure they are both changing when the shaft is spun. We found that one of our inputs was bad from the encoder and threw it in the trashcan.

Code:
// Testing encoder digital IO's without actually using the encoder class...
// This is a 'substitute diagnosis' for...
// Encoder enc(5, 6); which seems to be not working.
DigitalInput in1(5);
DigitalInput in2(6);
SmartDashboard* smarty = SmartDashboard::GetInstance();
int in1value, in2value;

while (IsOperatorControl())
{
  in1value = in1.Get();
  in2value = in2.Get();

  smarty->PutInt("In1", in1value);
  smarty->PutInt("In2", in2value);
}
If you don't get a text box (which can be turned into a plot/chart for easier viewing) which is changing from ones to zeros and back over and over again, then your encoder is hooked up wrong, plugged into the wrong slots/IOs, or dead/broken.

bob - Team 1967 - The Janksters
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
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 03:00.

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