View unanswered posts | View active topics It is currently Sat Sep 20, 2014 12:54 am






Reply to topic  [ 2 posts ] 
Twiching FTC robot problems 
Author Message
Rookie

Joined: Mon Sep 07, 2009 7:29 pm
Posts: 3
Post Twiching FTC robot problems
We've been trying to program our robot to move so far our code is:

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, PIDControl)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, PIDControl)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{
while (true)
{
getJoystickSettings(joystick);
motor[motorD] = joystick.joy1_y1;

if (joy1Btn(6))
{
motor[motorD] = -50;
}
else
{
motor[motorD] = 0;
}

}
}

The only reason it's -50 is because the motor runs backwards if we have it as 50 it runs backwards. Our main problem is if we try to add a second part to make the wheel's go backwards, or the other wheen in that case, it starts twiching when we press the the button. The code I posted works, but it only goes the one way. We want it preferable to go both ways on both wheels in stead of 1 way on one wheel, or get the joysticks driving it instead of buttons. No one on our team really knows how to program. So if anyone can help, that would be great :)


Mon Sep 07, 2009 7:47 pm
Profile
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Twiching FTC robot problems
As for the motor running backwards, just check the "Reverse Motor Direction" box in when you setup the motors, which should fix that. The crux of your problem is actually very obvious, if you consider what is actually happening. You are first telling it to get the value from the joystick's y1 position and assign it as a motor speed. There is nothing wrong in this, in fact it is entirely correct; however, you are then telling it to assign another motor speed based on the press state of a button. As long as that button is pressed, it is drawing "attention" if you will, and the press code is being executed (believe it or not, even when the button is being pressed, the motor is still twitching, you just don't notice it because it is being assigned, very briefly, a speed near 0); but, when the button is not pressed, it is not drawing attention, however, the joystick is. Even it is appears that the joystick is at its 0 position, chances are it is not, but is rather reading 1 or 2; that speed is momentarily getting assigned to the motor before it gets assigned 0 or as you would like, 50; the higher the speed you try to assign it in the else clause the bigger and more noticeable the twitch. And if you are trying to use the joystick while pushing the button, then you will definitely have problems.

I would recommend actually using one button to go forward and another to backward. And I would advise against trying to use buttons and the joysticks to control the robot, use either one or the other, but not both; otherwise you'll get screwy things like this happening. If you choose joysticks you don't have to worry about forward and back the center of the joystick is 0 so moving it down will move backwards.

So to start, try commenting out (put a "//" at the beginning of every line you want to comment out or to comment out a block put a "/*" at the beginning of the block and a "*/" at the end, no quotes on any of those) either the joystick code or the button code and see if that helps.

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Wed Sep 09, 2009 6:19 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.