Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Gear Tooth Sensor (http://www.chiefdelphi.com/forums/showthread.php?t=51840)

Zoom 14-01-2007 14:35

Gear Tooth Sensor
 
Hello
I need help programming the gear tooth sensors. I searched chiefdelphi but didnt find any thing that helped me. im looking for the program for the sensors. I came upon some posts but i couldnt get any thing for the sensors.

Also on the sensors there is j1 and j2 you have to wire them both. like one pwm cable for j1 and one for j2. from reading the manual i think the pwm cables go to rc_dig , right?

Thank you

Phalanx 14-01-2007 15:18

Re: Gear Tooth Sensor
 
First off, download and read Kevin Watsons encoder code and encoder FAQ
http://www.kevin.org/frc/encoder/
http://www.kevin.org/frc/frc_encoder.zip

To make his code work with the gear tooth sensors you need to remove the "Phase B" logic from it.

Second you wire them to digital I/O 1 and digital I/O 2 with a pwm cable. You also need to power them on a 12volt power supply as well.

See the 2007 Sensor Manual for more information.

Zoom 14-01-2007 15:32

Re: Gear Tooth Sensor
 
"Phase B" dont understand this?
"12volt power supply" for teh this do you mean like connecting a wire for the battery to the sensors. thx

JSonntag 14-01-2007 15:53

Re: Gear Tooth Sensor
 
1. "Phase B" refers to the code that determines which way the encoder is spinning. Since you are using a tooth sensor and not an encoder, this code will just cause problems.

2. to power on a 12volt supply, run a wire from one of your breaker panels.

Zoom 14-01-2007 16:17

Re: Gear Tooth Sensor
 
12 Volt Power with using a victor or just straight from there. What kind of a fuse should we use 40 AMP?

Also PHASE B logic, its located inside encoder.c file however I do not know which part to uncomment directly.

You guys have been a tremendous help so far.

JSonntag 14-01-2007 16:48

Re: Gear Tooth Sensor
 
Go directly from the fuse panel, not from a victor. I am not quite sure but i think you should use a 20 or maybe 30 amp fuse. the 40 amp fuses are for the motors.

The phase b pins are used in if statements so that it adds to the counter if it is moving forward and subtracts when moving backward. You basically have to replace it with code that will just add to the counter whenever an interrupt is fired off.

Something like this should work:
Code:

void Encoder_3_Int_Handler(unsigned char state)
{
if(state == 1)
{
Encoder_3_Count += ENCODER_3_TICK_DELTA;
}
}


Zoom 14-01-2007 17:57

Re: Gear Tooth Sensor
 
for the 12 volts on the board it says 12 and underneath it there is the letter w meanning the white cable goes there from the pwm cable. so we have to connect that whit cable to the fues to get 12volts.

Also the Encoder Handler's are differnet from 1 and 2. like everything above 2 are differnet. is tehre something special about them? thx for all the help.

JSonntag 14-01-2007 18:24

Re: Gear Tooth Sensor
 
The descriptions for the different encoder handlers are in the encoder_readme.txt file included with the code.

I am not sure exactly how to wire up the sensor since i have not yet wired it up myself and have not yet done the research on how to do so.

Phalanx 14-01-2007 22:39

Re: Gear Tooth Sensor
 
To wire the sensor...

Take one end of a pwm cable, and solder it to J2, the black wire to GB (ground-black) the red wire to 5R (+5 volts-red) the white wire to SW (signal white). Connect the other end of this pwm to digital I/O 1.

Take a 2nd pwm cable and solder it to J1, the black wire to GB, the white wired to (12W), the red wire is unused. Connect the other end to a 20amp circut on one of your atc breaker panels.

Mount the sensor from .5 to 2.75 mm away from the gear to be measured.

Repeat this for the second one except connect it to digital I/O 2.

As for the code...
Use encoder 1 and encoder 2, disable the others. Then remove the "Phase B" logic in the interrupt handler for encoder 1 and encoder 2.

If you need more help PM me and I will try to clarify it better

Zoom 15-01-2007 16:09

Re: Gear Tooth Sensor
 
Thx alot. il try to wire the senor.

Ultima 16-01-2007 15:02

Re: Gear Tooth Sensor
 
Our code looks something like this for Encoder 1 and 2

void Encoder_1_Int_Handler(void)
{
// Encoder 1's phase a signal just transitioned from zero to one, causing
// this interrupt service routine to be called. We know that the encoder
// just rotated one count or "tick" so now check the logical state of the
// phase b signal to determine which way the the encoder shaft rotated.
if(ENCODER_1_PHASE_B_PIN == 0)
{
Encoder_1_Count += ENCODER_1_TICK_DELTA;
}
}

#endif

#ifdef ENABLE_ENCODER_2

Would this work or not?

P.S. If I take away the #ifdef ENABLE_ENCODER_3 from the correct intrrupt would that correctly disable ENCODERS 3 -6. If not was would be the correct way for doing this.

Andrew Schuetze 16-01-2007 15:47

quadrature
 
Reading these posts seems to confirm my thoughts that this sensor doesn't provide rotation direction information. CW or CCW This of course does not render this a useless sensor as one is often powering the motor from which sensor data is being generated. Meaning you already know its rotation and just need rotational speed for closed-loop feedback.

Ultima 16-01-2007 18:41

Re: Gear Tooth Sensor
 
Well the sensor is quiet more usuful than that if we can get it to work.
It will provide us with a tooth count with which we can cross reference the speed of the motors and figure out what kind of a distance we traveled.


That is if we can get it to work =\

Alan Anderson 16-01-2007 21:10

Re: quadrature
 
Quote:

Originally Posted by Andrew Schuetze (Post 558243)
...one is often powering the motor from which sensor data is being generated. Meaning you already know its rotation and just need rotational speed for closed-loop feedback.

It took us a few tries last year to find and correct a small problem with this idea. When turning a small amount, the output from the direction PID can sometimes be too small to get out of the Victor deadband on one side of the 'bot but still drive the other side. What happens is that the entire robot moves forward, while the feedback routine is assuming it's turning in place. We had to ensure that we always applied a high enough control value to the Victors to actually make the motors move in the desired direction.

gnirts 16-01-2007 22:46

Re: quadrature
 
Quote:

Originally Posted by Alan Anderson (Post 558508)
[...] When turning a small amount, the output from the direction PID can sometimes be too small to get out of the Victor deadband on one side of the 'bot but still drive the other side. What happens is that the entire robot moves forward, while the feedback routine is assuming it's turning in place. [...]

A few questions:
  • How does the entire 'bot move forward with only one motor out of the deadband? I would think it would turn around that wheel.
  • In concert with the GTS, shouldn't the I term correct for this? (since the wheel in theory shouldn't be moving if the signal isn't enough to turn the motor)
  • Just out of curiosty, what is this PID loop for? Is it used during autonomous or driver control?
Thanks,
Robinson


All times are GMT -5. The time now is 02:07.

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