Society of Robots - Robot Forum
Software => Software => Topic started by: moltrex84 on September 23, 2010, 12:24:35 PM
-
Hello Robotic community,
I’m trying to interface a simple encoder “NOT Quad” with an axon II.
I want to make my robot travel in a straight line, I know the logic involved but I don’t know how to interface the encoder with the axon II. What I have read, using an external interrupt is the port I should use. I need help of how to accomplish this. Is there any already created function that have been tested ??? Thanks for the help.
If you tell me how to see the changing number of the step of the encoder, I’ll post the final code to help others.
updateEncodersvar();
While (encoder_left > envoder_right)
{
updateEncodersvar();
Do_small_left();
}
While (encoder_left <envoder_right)
{
updateEncodersvar();
Do_small_right();
}
While (encoder_left == envoder_right)
{
updateEncodersvar();
Go_foward();
}
-
I want to make my robot travel in a straight line, I know the logic involved but I don’t know how to interface the encoder with the axon II. What I have read, using an external interrupt is the port I should use. I need help of how to accomplish this. Is there any already created function that have been tested ???
Its actually very simple. Create a project using WebbotLib Project Designer, and tell it to use a Quadrature encoder. Program it to use a quadrature encoder, too. But obviously, since you don't have a quadrature encoder, you only have one signal wire to hook up to the Axon. For the other wire (channel B), just short it to ground.
In the Edit Quadrature menu, check the 'Use interpolation?' box - very useful if your encoder has low resolution. It'll tell you what pins you can use.
As for your code, it won't work - although conceptually its right. Here is how I'd do it, using Fuzzy control logic.
//set control constant - increase this number to get it to turn faster
uint8_t constant=1;
//determine encoder error
encoder_difference=encoder_left-encoder_right;
//reset speeds
left_motor_speed=DRIVE_SPEED_MAX;
right_motor_speed=DRIVE_SPEED_MAX;
//if left goes too fast
if(encoder_left > encoder_right)
left_motor_speed=CLAMP(DRIVE_SPEED_MAX-encoder_difference*constant,DRIVE_SPEED_MIN,DRIVE_SPEED_MAX);//slow left down
//if right goes too fast
if(encoder_left < encoder_right)
right_motor_speed=CLAMP(DRIVE_SPEED_MAX-encoder_difference*constant,DRIVE_SPEED_MIN,DRIVE_SPEED_MAX);//slow right down
//tell robot to move
act_setSpeed(&left, left_motor_speed);
act_setSpeed(&right, right_motor_speed);
-
I have the WebbotLib Project designer but the tools option is not available ... i can't do tools/generate ...
for this option I have to purchase the software, need to create an account ... ????
... I have the webbotlib installed but I dont have a example to use the library ...
Does the Project designer show me a example of how to stores the values, update and reset the encoders ????
Thanks for you help ... :)
-
hmmm I download it again and I have the tools option now, maybe I had a older rare version ... but I will play with it ...
Now i can see the example code in the avr studio file ... I will play with it.
Thanks, any problem I'll be back to my favorite forum ...
-
I have done this, but I found a quad vex encoder so I I used the basic connection ... The issue is that I want to use a more reliable encoder, not a plastic encoder, no disrespect to vex ... its a wonderful piece of art to have 90 ticks per revolution in a plastic low cost quad vex encoder.
Questions:
1- What quad encoder do you recommend me to look up with the axon II ??? , I would like it to be a plug and play, so it can be powered by the axon II... If is not quad encoder to short the signal wire with the ground in channel B will that be the absolutely same code that I already have for the quad encoder???
2- Apparently sometimes the Option of tools in the WebbotLib doesn't appear, so I can not do tools /generate ... Does somebody Knows why and how to keep it enable???
3- Do you think a RFID reader working at ~900MHz will mess up the digital compass readings "its not going to be closed, but definitely in the perimeter" ??? Yes 900MHz a perimeter of 2-3 meters.
-
WebbotLib now has an interpolate function for encoders, which effectively increases the resolution of your encoder by a factor of 10 by assuming a relatively constant velocity. Give it a try.
1 - Any quad encoder will work. Both channels need their own pins on the Axon to be used as a quad encoder. If you don't want to use it as a quad, just don't connect channel B to anything (shorting it will fry your encoder).
2 - It works fine for me. You must have a board loaded for Tools to be accessible.
3 - A digital compass works on average magnetic fields, where RFID works on signals/frequencies transmitted. I highly doubt there will be interference. Just keep the RFID wiring (or any wiring for that matter) away from the compass!
-
Regarding the 'Tools' option....
Make sure you aren't confusing Board Designer with Project Designer.
Board Designer is for designing production boards and has no 'Tools' menu.
Project Designer is for creating your project based on a given board. And as Admin says you must have a Project open for the option to be valid.