|
Page 1 of 1
|
[ 5 posts ] |
|
Magnetic Sensor interference with NXT motor
Author |
Message |
abcde13
Rookie
Joined: Sun Jul 24, 2011 2:28 pm Posts: 2
|
 Magnetic Sensor interference with NXT motor
So, we are a veteran team, but we are newbies when it comes to the magnetic sensor. So unfortunately, we have come into a major problem. We have a claw run by an NXT servo, which grabs the magnetic ball and puts it in the goal. However, in order to detect the magnetic ball, a little 180 degree servo is attach with a small arm. When the magnetic sensor detects a magnetic ball, the servo brings down the arm to stop the ball, giving it enough time for the NXT claw to come into place. From there, the servo lifts up the arm, the ball rolls into the claw, and supposedly, it is scoring time. Here is the problem. Without the magnetic sensor code, during tele-op, the claw moves up and down fine. With the magnetic code in, the NXT motor responds erratically, and it almost sounds like it is breaking stuff (Luckily, it is not). Thus, the code:  |  |  |  | Code: #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop, reversed) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Servo, srvo_S1_C2_1, servo1, tServoStandard) #pragma config(Servo, srvo_S1_C2_2, servo2, tServoStandard) #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) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
task main() {
int threshold = 10;
while (true) { nxtDisplayTextLine(5, "Value is : %4d" + SensorValue[magnet]);
getJoystickSettings(joystick); if (joystick.joy1_y1 <= 5 && joystick.joy1_y1 >= -5) //Run drive motors { motor[motorD] = 0; } else { motor[motorD] = joystick.joy1_y1/2; } if (joystick.joy1_y2 <= 5 && joystick.joy1_y2 >= -5) { motor[motorE] = 0; } else { motor[motorE] = joystick.joy1_y2/2; } if(SensorValue[magnet] < 659 && SensorValue[magnet] > 654) //Magnetic servo stopper { servo[servo1] = 100; } else { servo[servo1] = 200; } if(joy1Btn(1) == 1) //NXT servo magnetic scorer { motor[motorB] = 40; } if(joy1Btn(2) == 1) { motor[motorB] = -60; } if(joy1Btn(1) == 0 && joy1Btn(2) == 0) { motor[motorB] = 0; }
if(joy1Btn(5) == 1) //Stacking crates { servo[servo2] = 0; wait1Msec(500); } if(joy1Btn(6) == 1) { servo[servo2] = 0; wait1Msec(500); }
} } |  |  |  |  |
Is it possible that there is some sort of magnetic interference going on, because I have isolated the problem just to when the code includes the magnetic portion or not. And please do tell me if something is inherently wrong with the code at first site, or if there is something I could improve to any of the button commands.
|
Sat Oct 08, 2011 10:53 am |
|
 |
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: Magnetic Sensor interference with NXT motor
Well, the magnetic sensor detects a magnetic field. The motor works because it has magnets in it. If the magnetic sensor is brought close to a motor, it will detect the motor's magnetic field. This is probably what is going on.
_________________ sudo rm -rf /
|
Sat Oct 08, 2011 11:23 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Magnetic Sensor interference with NXT motor
See what kind of data the sensor returns when you disconnect all the cables from the motors, and compare that to when the motors are connected. Sensors are imperfect and the world your robot travels through is full of interference. The trick is distinguishng the signal from the noise 
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Sat Oct 08, 2011 11:43 am |
|
 |
abcde13
Rookie
Joined: Sun Jul 24, 2011 2:28 pm Posts: 2
|
 Re: Magnetic Sensor interference with NXT motor
It is all good now guys. Apparently, everything wasn't working due to an extremely low charge in the nxt battery. I only realized this when the servo completely stopped working, and the nxt claw couldn't even lift a racquetball.
Thanks guys.
|
Mon Oct 10, 2011 10:06 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Magnetic Sensor interference with NXT motor
Ah yes, well that'd do it  The magnetic sensor is an analogue one, so battery voltage would definitely affect it. - Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Mon Oct 10, 2011 10:10 am |
|
|
|
Page 1 of 1
|
[ 5 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
|
|