|
Page 1 of 1
|
[ 3 posts ] |
|
| Author |
Message |
|
thunderstruck
Rookie
Joined: Thu Oct 16, 2008 8:22 pm Posts: 3
|
 Can't Synch Motors
Can anyone tell me why motors A and B won't synch? I can't seem to figure it out. I don't get any errors while running the program, but immediately when I turn it off it gives me an error that says it failed to update the slave...
#pragma config(Motor, motorA, , tmotorNormal, PIDControl) #pragma config(Motor, motorB, , tmotorNormal, PIDControl) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { while (true) { getJoystickSettings(joystick); if (joystick.joy1_y1 > 5 || joystick.joy1_y1 < -5) motor[motorD] = -joystick.joy1_y1; else motor[motorD] = 0; if (joystick.joy1_y2 > 5 || joystick.joy1_y2 < -5) motor[motorE] = joystick.joy1_y2; else motor[motorE] = 0;
nPidUpdateIntervalNxt = 10; nMotorPIDSpeedCtrl[motorA] = mtrEncoderReg; nMotorPIDSpeedCtrl[motorB] = mtrEncoderReg; nSyncedMotors = synchAB; nSyncedTurnRatio = 100; if (joy1Btn(2)) { motor[motorA] = 80; } else if (joy1Btn(3)) { motor[motorA] = -80; } else { motor[motorA] = 0; } } }[/color]
|
| Thu Oct 30, 2008 9:13 pm |
|
 |
|
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 537
|
 Re: Can't Synch Motors
Few Issues here... 1. You're missing the top line of your code. You need to define where your FTC hardware is connected on the NXT. You can generate this line by going into Motors and Sensor Setup. This is what's generating the error message when you run your code. 2. I tried the syncing out... it seems to be working by turning on both motors... but the "sync" part of it doesn't seem to be there. I'll have to investigate this a little more Edited Code:  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Motor, motorA, , tmotorNormal, PIDControl) #pragma config(Motor, motorB, , tmotorNormal, PIDControl) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { while (true) { getJoystickSettings(joystick); if (joystick.joy1_y1 > 5 || joystick.joy1_y1 < -5) motor[motorD] = -joystick.joy1_y1; else motor[motorD] = 0; if (joystick.joy1_y2 > 5 || joystick.joy1_y2 < -5) motor[motorE] = joystick.joy1_y2; else motor[motorE] = 0;
nMotorPIDSpeedCtrl[motorA] = mtrEncoderReg; nMotorPIDSpeedCtrl[motorB] = mtrEncoderReg; nSyncedMotors = synchAB; nSyncedTurnRatio = 100;
if (joy1Btn(2)) { motor[motorA] = 80; } else if (joy1Btn(3)) { motor[motorA] = -80; } else { motor[motorA] = 0; } } } |  |  |  |  |
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
| Fri Oct 31, 2008 4:16 pm |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
 Re: Can't Synch Motors
I cannot find anything wrong with the firmware. There is a bug in your program though. The code to setup motor synchronization should be moved outside of the loop. Whenever synchronization is setup it "resets" the synchronization state and starts over. You're running through the loop 100s (1000s?) of times a second and each time through the synchronization it looses the "history" needed to keep the motors in sync. Once I moved this outside the loop, everything works fine. For example, manually hold motor C and you'll notice motor A will slow down to keep speed with A. Here's the revised program.  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Motor, motorA, , tmotorNormal, PIDControl) #pragma config(Motor, motorB, , tmotorNormal, PIDControl) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { nMotorPIDSpeedCtrl[motorA] = mtrEncoderReg; nMotorPIDSpeedCtrl[motorB] = mtrEncoderReg; nSyncedMotors = synchAB; nSyncedTurnRatio = 100;
while (true) { getJoystickSettings(joystick); if (joystick.joy1_y1 > 5 || joystick.joy1_y1 < -5) motor[motorD] = -joystick.joy1_y1; else motor[motorD] = 0; if (joystick.joy1_y2 > 5 || joystick.joy1_y2 < -5) motor[motorE] = joystick.joy1_y2; else motor[motorE] = 0;
nPidUpdateInterval = 10; if (joy1Btn(2)) { motor[motorA] = 80; } else if (joy1Btn(3)) { motor[motorA] = -80; } else { motor[motorA] = 0; } } } |  |  |  |  |
|
| Mon Nov 03, 2008 4:17 pm |
|
|
|
Page 1 of 1
|
[ 3 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
|
|