Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   wiring and programing our optical encoders (http://www.chiefdelphi.com/forums/showthread.php?t=82060)

michael1991j 06-02-2010 18:25

wiring and programing our optical encoders
 
hello
we are trying to set up our us first optical encoders. unfortunately there is nothing in the manual that I could find on how to do this task. now I have gone though the chief Delphi forum's and found a article that explained how to set up the encoders. from what it said is that I had to hook up our encoder by getting a two three pin cable and wire them like this

ground
power
signal a

then get another cable and put signal b on the other cable on the signal slot


and then plug them into our digital side cars
now if I have this set up right would anybody know happen to know how I would program this in c++. just to have it output the angle.

thank you

Tom Line 06-02-2010 19:23

Re: wiring and programing our optical encoders
 
WPILIB provides an encoder class (I believe) that can be used with the encoders.

It should count in "ticks". Not degrees. So you'll have to find out how many "ticks" are in one revolution of your encoder, and use that to convert to degrees.

In addition, the encoders are not "absolute" encoders. They do not have a zero-position that stays the same. Essentially, every time you fire up your code the zero will be in a different location. So if you are trying to use the encoders for absolute positioning, you either have to buy an absolute positioning encoder, make sure you set your mechanism in the same location every time and then zero it, or use a potentiometer suited to the application.

michael1991j 06-02-2010 20:13

Re: wiring and programing our optical encoders
 
does my wiring look correct i do not know

apalrd 06-02-2010 20:41

Re: wiring and programing our optical encoders
 
Yes it does.

michael1991j 06-02-2010 23:24

Re: wiring and programing our optical encoders
 
hmm i wonder if it is somthing am doing wrong then

this is how i stated my code:

I state this inside my main class
Encoder encoder(1, 2, true);

and then in my teleop loop
I say
float tick = encoder.GetDistance() ;

printf("tick:%4.2f /n",tick );

and what i am getting is

tick:
tick:
tick:
.... and when I move my gear box i get no input
now i did noticed there is a spot for a jumper on the digital side car on the digital input sides do i need to put a jumper in there. the probem when i do that everything become nonresponsive until i remove it so does anybody know what am i doing wrong

Kingofl337 06-02-2010 23:51

Re: wiring and programing our optical encoders
 
try
initTeleOp(){
encoder.SetDistancePerPulse(.025); //this actually depends on your wheel size, gear ratio, encoder CPR
encoder.Start();
}


PeriodicTeleop(){
INT32 tick = encoder.GetDistance();

printf("tick:%4.2 /n",tick );

)

This should get you started

michael1991j 07-02-2010 00:12

Re: wiring and programing our optical encoders
 
thank you very much I will try it

Alan Anderson 07-02-2010 00:58

Re: wiring and programing our optical encoders
 
Quote:

Originally Posted by michael1991j (Post 914892)
\now i did noticed there is a spot for a jumper on the digital side car on the digital input sides do i need to put a jumper in there. the probem when i do that everything become nonresponsive until i remove it so does anybody know what am i doing wrong

I don't know what "spot for a jumper" you're talking about. Can you describe it more fully? Your program says you have the encoder connected to DIO1 and DIO2. As long as the Digital Sidecar has good power, you shouldn't need to do anything else with the wiring.

michael1991j 07-02-2010 02:35

Re: wiring and programing our optical encoders
 


if you look at where circled in this picture you will see a + or - in that area

longrange 07-02-2010 02:43

Re: wiring and programing our optical encoders
 
Those are spare power connectors

michael1991j 07-02-2010 12:13

Re: wiring and programing our optical encoders
 
ok so that wouldnt power the digital io you needed jumpers for moters

Tom Line 07-02-2010 15:01

Re: wiring and programing our optical encoders
 
The only time that you need to worry about a jumper on the digital side car (and someone can correct me here if I'm wrong), is when you are plugging in a servo.

What you did with the jumper was to jump power straight to ground - you short circuited the entire board. You are lucky it has built in protection or you would have fried it.

Please try to read through the various controls manuals provided by First if you haven't already. They provide a great starting point for someone new at this. Also, try to use punctuation and capitalization. It's hard enough to read through the hundreds of posts - don't make it any harder!

Alan Anderson 07-02-2010 15:08

Re: wiring and programing our optical encoders
 
Quote:

Originally Posted by michael1991j (Post 914980)
if you look at where circled in this picture you will see a + or - in that area

If you connected those two pins together, you shorted power and ground. That would certainly make everything else stop working.


All times are GMT -5. The time now is 01:59.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi