|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Encoder Problem.
So i am trying to get these encoders working,
http://www.grayhill.com/web1/images/...ncoder_63r.pdf Connected pin 1(encoder) to DigitalI/O in digital sidecar Pin Signal 1 Connected pin 2(encoder) to DigitalI/O in digital sidecar Pin Power 1 Connected pin 3(encoder) to DigitalI/O in digital sidecar Pin Signal 2 Connected Pin 5(encoder) to DigitalI/O in digital sidecar Pin ground 3 and here is the java code i am using to test Code:
public void disabled(){
Encoder TestEnc = new Encoder(2,1);
TestEnc.reset();
for(;;){
System.out.println(TestEnc.get());
Timer.delay(1);
}
}
I tested the encoder with an arduino and it seems to work fine. I switched to another digital sidecar and the problem persists. any ideas? cheers arun |
|
#2
|
||||
|
||||
|
Re: Encoder Problem.
You never call TestEnc.start();
|
|
#3
|
|||
|
|||
|
Re: Encoder Problem.
Changed code to :
Code:
public void disabled() {
Encoder TestEnc = new Encoder(2, 1);
TestEnc.reset();
TestEnc.start();
for (;;) {
System.out.println(TestEnc.get());
Timer.delay(1);
}
}
![]() |
|
#4
|
||||
|
||||
|
Re: Encoder Problem.
Try taking out the Timer.delay()
|
|
#5
|
|||
|
|||
|
Re: Encoder Problem.
Do you have access to an oscilloscope? They're really helpful with debugging encoder problems, and let you see if it's a code-side or electronics-side issue.
|
|
#6
|
|||
|
|||
|
Re: Encoder Problem.
I am pretty sure the encoder works cause it works fine on a arduino
|
|
#7
|
||||
|
||||
|
Re: Encoder Problem.
Quote:
And as long as you're doing that, use the voltmeter to check that channels A and B are cycling. |
|
#8
|
||||
|
||||
|
Re: Encoder Problem.
Try changing "TestEnc" to "testEnc". You're not supposed to capitalize variable names.
If that doesn't work:
|
|
#9
|
|||||
|
|||||
|
Re: Encoder Problem.
Quote:
I personally am a fan of capitalizing the first letter of a variable name to indicate it is a variable, and naming all macros in all capitals with underscores separating words to differentiate them. I've also seen incredibly structured variable naming methods that define everything about a variable in the name. For example, using three to six letter module name prefixes, and coding the type or units in (e.g. p for pressure, or kpa for kilopascals), or type of variable (e.g. m for map, c for calibration, etc.) and these work as well. It's really all personal preference, as long as you are consistent the compiler really doesn't care at all. |
|
#10
|
|||||
|
|||||
|
Re: Encoder Problem.
Agreed that capitalization won't change anything. Rearranging deck chairs on the Titanic, that is. I think the C++ convention of variables starting with lower case letters is to distinguish them from classes and functions with start with uppercase letters. Though this may be Java, which has the opposite standard, I think.
I think your reset and start calls need to be in the other order. I'd also suggest putting an extra println in your loop just to make sure you're actually getting into the loop and all that. Possibly with an increment just for kicks. I'd also recommend checking the outputs with a multimeter just to make sure that's not the problem. We have a different encoder board that's been fried and isn't good anymore. The only way you can tell is the output is constantly at 0.7V, never 0V or 5V as it should be. It's super easy to accidentally fry an output with static, so don't assume that it's still working fine just because it used to. Trust, but verify. |
|
#11
|
||||
|
||||
|
Re: Encoder Problem.
Quote:
|
|
#12
|
|||||
|
|||||
|
Re: Encoder Problem.
Quote:
If you measure across encoder pins 2 and 5, is it actually receiving 5 volt power? Is there a reason you initialize the encoder object with DIO 2 and 1 in that order, instead of 1 and 2? |
|
#13
|
||||
|
||||
|
Re: Encoder Problem.
Quote:
Quote:
Quote:
He did say that the encoder worked fine on an Arduino. |
|
#14
|
|||||
|
|||||
|
Re: Encoder Problem.
Quote:
Quote:
|
|
#15
|
|||
|
|||
|
Re: Encoder Problem.
Ok, finally debugged the problem - the cable which connects the digital side-car to the crio was not crimped properly? with pins etc switched around? changed that cable and everything works ok!!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|