View unanswered posts | View active topics It is currently Tue Sep 30, 2014 7:00 pm






Reply to topic  [ 7 posts ] 
Samantha Module 
Author Message
Rookie
User avatar

Joined: Thu Oct 04, 2012 8:51 pm
Posts: 22
Post Samantha Module
So, my team has downloaded the NXT firmware on the Samantha module. We can connect a controller through the Samantha Field Control system, to the NXT which is connected to the Samantha module. But when we run a program on the NXT, and we use the controller connected to the computer using the Samantha Field Control system, the robot does nothing. We are using Robotc, and the name of the teleop file is the exact same name of the file we are trying to run. Does anyone know if we're making some simple mistake?


Tue Nov 13, 2012 11:26 pm
Profile
Rookie
User avatar

Joined: Thu Oct 04, 2012 8:51 pm
Posts: 22
Post Re: Samantha Module
If we don't have to use the Samantha Field control software and there is some other way, please tell me.
:breakcomputer:


Thu Nov 15, 2012 5:52 pm
Profile
Rookie
User avatar

Joined: Thu Oct 04, 2012 8:51 pm
Posts: 22
Post Re: Samantha Module
Turns out it was a simple mistake.
But, when we connect to the Samantha module, and use the remote, the robot doesn't move smoothly. It is very jerky and uneven.
Anyone know whats wrong? Help?


Thu Nov 15, 2012 9:33 pm
Profile
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post Re: Samantha Module
Could you please post the code so we can make sure it's not a programming error?

I've never had this problem over Samantha. Debugging programs over a wired connection with an older version of RobotC used to do something that sounds like what you're describing (if you didn't select the "Teleop Running" bullet in the Joystick Control debugger window).


Fri Nov 16, 2012 3:28 am
Profile
Rookie
User avatar

Joined: Thu Oct 04, 2012 8:51 pm
Posts: 22
Post Re: Samantha Module
I will see if it's about checking the teleop program box.
I'm pretty sure it's not a problem with the code, but here it is:



pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
#include "JoystickDriver.c"


task main()
{
while(true)
{
getJoystickSettings(joystick);
if(joy1Btn(7) == 1)
{
motor[motorD] = -100;
}
else
{
motor[motorD] = 0;
}
if(joy1Btn(8) == 1)
{
motor[motorE] = -100;
}
else
{
motor[motorE] = 0;
}
if(joy1Btn(5) == 1)
{
motor[motorD] = 100;
}
else
{
motor[motorD] = 0;
}
if(joy1Btn(6) == 1)
{
motor[motorE] = 100;
}
else
{
motor[motorE] = 0;
}
}
}


Fri Nov 16, 2012 8:03 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Samantha Module
Alder wrote:
If we don't have to use the Samantha Field control software and there is some other way, please tell me.
:breakcomputer:

We use Bluetooth when testing our code. It works fine.


Fri Nov 16, 2012 9:23 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 580
Post Re: Samantha Module
Code:
pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
#include "JoystickDriver.c"


task main()
{
while(true)
{
getJoystickSettings(joystick);
if(joy1Btn(7) == 1)
{
motor[motorD] = -100;
}
else
{
motor[motorD] = 0;
}
if(joy1Btn(8) == 1)
{
motor[motorE] = -100;
}
else
{
motor[motorE] = 0;
}
if(joy1Btn(5) == 1)
{
motor[motorD] = 100;
}
else
{
motor[motorD] = 0;
}
if(joy1Btn(6) == 1)
{
motor[motorE] = 100;
}
else
{
motor[motorE] = 0;
}
}
}


The issue you are seeing with your code here is a fairly common one; you are turning the motors on in one if/else statement pair, and then immediately turning them off in the next one. For instance:

Code:
if(joy1Btn(8) == 1)
  {
    motor[motorE] = -100;
  }

else
  {
    motor[motorE] = 0;
  }

if(joy1Btn(6) == 1)
  {
    motor[motorE] = 100;
  }
else
  {
    motor[motorE] = 0;
  }


These two sets of if/else statements are conflicting. If button 8 is pressed, motorE is set to a power level of -100, but since button 6 is not pressed, the motors are then set to a power level of 0. If button 6 is pressed, the code will first check to see if button 8 is pressed and turn the motors off, then turn the motors on with a power level of 100 when it checks for button 6 being pressed. Since the code is (correctly) in an infinite loop, the program will rapidly switch between turning the motors on and off which results in the jerky movement you are seeing.

An alternative, better way to map motor speed to the buttons is:

Code:
if (joy1Btn(6) == 1)
  {
    motor[motorE] = 100;
  }

else if (joy1Btn(8) == 1)
  {
     motor[motorE] = -100;
  }

else
  {
     motor[motorE] = 0;
  }


This code first checks button 6's value and turns motor E on to a power level of 100 if it's pressed; else, if button 6 is not pressed it checks button 8's value and turns motor E on to a power level of -100; else, it turns the motors off if neither button is pressed.

For this one, I suggest taking a look at our video curriculum trainer which walks through coding principles and covers everything from the basics all the way up to advanced remote control features (including what we've talked about here). It's definitely worth looking through if you are new to ROBOTC, robotics, or coding in general and can be a great reference tool for advanced programmers.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Nov 16, 2012 9:55 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.