|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
What you should do is choose an appropriate increment. If you use 0.01 instead of 1, your servo will work as you expect with 100 steps of travel. (This assumes that the rest of your code is correct. Things are scrunched enough that I can't really read it well.) |
|
#2
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
I will try changing the increment tomorrow, since school is closed today. |
|
#3
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
The camera still wont move. With light bulb on, the motor shows its position as .5, and when i press button 2, it decreases to .49. After executing once, i still have button 2 pressed down, so the value is .48.
Here is my Robot Main code, and my Camera code. The camera code is being called in Teleop Enabled, but when it runs without light bulb, the Camera Sub VI is "waiting to run". Why is this error occurring and how can I fix it? On a sidenote, for some reason when we deploy our code, the driver station reports that the robot is on Teleop enabled, then switches to "Watchdog not fed", then back to Teleop Enabled, and back to "Watchdog not fed", and then to Teleop Enabled, and back to "Watchdog not fed", and keeps following that loop. I am not sure why I am getting this error, and is interrupting our code execution. |
|
#4
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
You've put the teleop code into RobotMain rather than into the Team Code Teleop function. While this isn't horrible, it does mean that the code in teleop, the drive code, and the camera update code are all running in parallel.
Far worse, the code to read the Joystick 1, Ope the Drive and read Joystick 2 are running in parallel with what I'm assuming is the Begin VI which is offscreen. This will likely mean that the joystick references are bad. Anyway, before you write additional code, why not move the existing stuff into Teleop? Also, if you have errors due to multiple opens or referencing before opening, the Diagnostics tab should list those errors. Greg McKaskle |
|
#5
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
how else am i supposed to get the joystick references? in the begin vi, i intialized the joysticks and set a reference to them. In Robot Main, i get the reference. If i am not supposed to get the reference, how will i run tank drive? |
|
#6
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
If you get the reference inside the teleop VI, it is guaranteed that Begin has completed. If you get the references in Robot Main, how do you guarantee that Begin has set them?
If you need the refnum in Robot Main, you should just open it there rather than in Begin. If you are carful, you can of course keep writing the code the way you are, but moving the code from teleop to Robot Main didn't fix any bugs you had, and in fact will likely introduce them. The big green comments to the left of the diagram describe the typical way of modifying the framework. They are of course only suggestions, but maybe something you should read before making big edits. As for the location of the drive code. The easiest way to see how it should be done is to create a new project using the getting started window. Save it to a new location/name and inspect how it was originally done. You can also do this on a separate computer if you are unsure of where your current code is saved. Greg McKaskle |
|
#7
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
Joystick 1 should move Jaguar 1 only, and Joystick 2 should move jaguar 2 only(now on known as MODE1). The problem we are having is that Joystick 1 controls both jaguars, and joystick 2 sometimes(like 1 sec per every 5 seconds, but its more random) sends a signal to the jaguar. The code is here: http://i48.tinypic.com/sqqe8n.jpg So afterwards, we went back to our old code and tried to find out what was causing the error. And we have narrowed it down to two things. First, the references arent working properly. When I use a Joystick reference instead of opening a new joystick, the code goes into MODE2, and if we use open a new joystick instead of referencing it, the code goes into MODE1. You can see our begin.vi here(disregard the Robot Main.vi because it no longer works like that): http://i49.tinypic.com/24uycr8.jpg Although you can't fully see Begin.vi, the technique we used to reference the joysticks are the same. Basically: [USB1] --- [Joystick Open] ----[Joystick Set Ref.]====[error output array] ["Joystick 1"]-----------------/ Joystick 1 is the name of our reference, and I kinda drew out how our Joystick code in Begin.vi looks like. SO, the problem: We want MODE1(but no errors in the diagnostic tab), but we are getting MODE2 with no errors in the diagnostic tab(besides watchdog). Can someone please post or PM me some screenshots or code, because we are having major trouble with this. |
|
#8
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
When I look at the code Teleop code at : http://i48.tinypic.com/sqqe8n.jpg I see that each time it is called, 50 times a second, the joysticks are being closed, additionally, the drive is being opened and closed.
Move the Opens to Begin, the Closes to Finish, and see if that helps. By the way, you'll need to name and store the drive. Greg McKaskle |
|
#9
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
When we open the joysticks and the drive in begin.vi and reference them, the joysticks act funny and so does drive. Which is why i was wondering if anyone could post or PM any screenshots or code that could help us out. |
|
#10
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
|
|
#11
|
|||
|
|||
|
Re: Need help w/ moving Camera Servo motors.
Quote:
Im guessing Arcade Drive is originally in Teleop.vi because we never put it there. Anyways, we fixed the problem. The error was that the power cable was not properly connected to the Digital Sidecar. |
|
#12
|
|||||
|
|||||
|
Re: Need help w/ moving Camera Servo motors.
I just read your post. We have been doing the same thing with a servo, but with two preset positions and a button to toggle between them.
Here's a picture of our code: I put this in a sub-vi, called from teleop.vi. Two controls in teleop.vi are used to set the two angles of the servo. When you get them where you want, either make the current value the default value, (right-click and select Data Operations) or replace them with a constant of the same value. The green, boolean wire comes from the joystick button where it breaks out from the unbundle block. The Flip-Flop.vi is used to latch the button. I found the VI here on CD a while back, posted by one of the NI people. I don't recall the name or exact post, but it's been quite useful, once I made a few modifications to simplify it for our use. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HELP- Need Globe Motors ASAP | Brandon Holley | General Forum | 0 | 03-11-2009 10:37 |
| need help with motors | EagleMentor | Programming | 3 | 06-02-2009 17:37 |
| Need help with mini motors | R.C. | Motors | 11 | 03-07-2008 16:25 |
| help getting servo values from camera | ruddy | Programming | 12 | 30-11-2007 23:18 |
| Window Motors. Need help!!!! | Mohsin | Motors | 1 | 27-02-2004 13:05 |