![]() |
Need help w/ moving Camera Servo motors.
1 Attachment(s)
I am trying to move the Camera Servo Motor(Axis 2 - plugged into PWM 5 w/ Jumper) through Joystick 2(USB 2). I want it so when I press button 2, the camera should face down, and when I press button 3, the camera should face up.
I attached my current code for the Camera. Both the Joystick(Joystick 2) and the Servo(Camera Motor) are both initialized in the begin.vi, and both closed in finish.vi. The Camera.vi is being called in Robot Main.vi inside the giant while loop. Right now, when I run the code, the Servo motor does not move at all, so i decided to debug it by running the code in light bulb mode. What I noticed was that the initial position was 0.00, and after subtracting 1(moving it down), the new position was still 0.00. I don't know why the position is not being updated for every time the loop executes and moves it down. |
Re: Need help w/ moving Camera Servo motors.
That picture shows a different VI in the background that sets the servo to zero. That could be your problem.
|
Re: Need help w/ moving Camera Servo motors.
Quote:
|
Re: Need help w/ moving Camera Servo motors.
Sorry about the double post. Look below for my actual post.
|
Re: Need help w/ moving Camera Servo motors.
Quote:
Quote:
|
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.) |
Re: Need help w/ moving Camera Servo motors.
Quote:
I will try changing the increment tomorrow, since school is closed today. |
Re: Need help w/ moving Camera Servo motors.
1 Attachment(s)
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. |
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 |
Re: Need help w/ moving Camera Servo motors.
Quote:
Quote:
|
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 |
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. |
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 |
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. |
Re: Need help w/ moving Camera Servo motors.
Quote:
|
| All times are GMT -5. The time now is 11:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi