Go to Post Starting from scratch is what makes it hard. - ChrisH [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2010, 17:33
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Need help w/ moving Camera Servo motors.

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.
Attached Thumbnails
Click image for larger version

Name:	untitled.JPG
Views:	106
Size:	122.0 KB
ID:	8588  
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2010, 22:12
Ziaholic's Avatar
Ziaholic Ziaholic is offline
Elec/SW Mentor
AKA: Marc
FRC #1164 (Project NEO)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2002
Location: Las Cruces, NM
Posts: 194
Ziaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the rough
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.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2010, 22:27
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by umangv620 View Post
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.
The valid range of values for Servo Set Position is from 0 to 1. If you try to set the servo position to something greater than 1, it will be coerced to 1. If you try to set it to something less than 0, it will be coerced to 0. Does that help explain what you're seeing?
Reply With Quote
  #4   Spotlight this post!  
Unread 10-02-2010, 00:06
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Need help w/ moving Camera Servo motors.

Sorry about the double post. Look below for my actual post.
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award

Last edited by umangv620 : 10-02-2010 at 15:54. Reason: double post.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-02-2010, 00:09
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by Ziaholic View Post
That picture shows a different VI in the background that sets the servo to zero. That could be your problem.
That is so weird. I think that is there because I might have copied the camera code directly into Robot Main because this is the first time I am using sub VIs. Even if it was something different, I am sure that the motor is only set to 0 when a button is pressed.I am pretty sure I didnt make a stupid mistake such as this, but I will look this up on thursday(snow day tmr).

Quote:
Originally Posted by Alan Anderson View Post
The valid range of values for Servo Set Position is from 0 to 1. If you try to set the servo position to something greater than 1, it will be coerced to 1. If you try to set it to something less than 0, it will be coerced to 0. Does that help explain what you're seeing?
So should I use Servo SetAngle instead? What range does that go from? 0 to 180 or -90 to 90?
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #6   Spotlight this post!  
Unread 10-02-2010, 08:19
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by umangv620 View Post
So should I use Servo SetAngle instead? What range does that go from? 0 to 180 or -90 to 90?
If you open up the SetAngle vi you can see how it works. It takes the angle and normalizes it to 0-359, then converts that to a number from 0 to 1 based on the angular range of the servo. The default range is 170 degrees.

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.)
Reply With Quote
  #7   Spotlight this post!  
Unread 10-02-2010, 15:53
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by Alan Anderson View Post
If you open up the SetAngle vi you can see how it works. It takes the angle and normalizes it to 0-359, then converts that to a number from 0 to 1 based on the angular range of the servo. The default range is 170 degrees.

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.)
Sorry about the double post and sorry about the code. Maybe I should have kept the lightbulb mode off so everyone could read the code more clearly.

I will try changing the increment tomorrow, since school is closed today.
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #8   Spotlight this post!  
Unread 12-02-2010, 18:27
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
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.
Attached Thumbnails
Click image for larger version

Name:	Code.PNG
Views:	63
Size:	95.1 KB
ID:	8644  
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #9   Spotlight this post!  
Unread 12-02-2010, 18:58
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
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
Reply With Quote
  #10   Spotlight this post!  
Unread 12-02-2010, 20:59
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by Greg McKaskle View Post
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.
I tried moving the tank drive code into the teleop vi, and i experienced a very rapid burst of "teleop enabled" and "teleop disabled". This may be from the faulty wiring into the digital sidecar we discovered later. Should the tank drive code be inside the case structure that is true/false based on the Joystick Read.vi or should it be outside that loop, but inside the other case structure loop encasing most of the teleop code?

Quote:
Originally Posted by Greg McKaskle View Post
Far worse, the code to read the Joystick 1, Open 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.
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?
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #11   Spotlight this post!  
Unread 13-02-2010, 04:07
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
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
Reply With Quote
  #12   Spotlight this post!  
Unread 13-02-2010, 18:03
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by Greg McKaskle View Post
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
We are getting the weirdest errors. So after moving the drive code into Teleop.vi, we noticed that when we push Joystick 1 foward, both motors move in opposite directions(1 Jaguar green, 1 jaguar blinking red), and Joystick 2 randomly turns Jaguar 2 blinking red or green(depending on the direction). (now on known as MODE2)

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.
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #13   Spotlight this post!  
Unread 13-02-2010, 19:13
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
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
Reply With Quote
  #14   Spotlight this post!  
Unread 14-02-2010, 00:19
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by Greg McKaskle View Post
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
Thats what we had. We were getting errors, so we deleted that part and opened the joysticks and drive in now robot main(not teleop) and closed it in robot main as well. When we do this, our joysticks function correctly.

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.
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote
  #15   Spotlight this post!  
Unread 15-02-2010, 02:31
ecnahc515 ecnahc515 is offline
Registered User
FRC #3192
 
Join Date: Jan 2010
Location: Oregon
Posts: 6
ecnahc515 is an unknown quantity at this point
Re: Need help w/ moving Camera Servo motors.

Quote:
Originally Posted by umangv620 View Post
Thats what we had. We were getting errors, so we deleted that part and opened the joysticks and drive in now robot main(not teleop) and closed it in robot main as well. When we do this, our joysticks function correctly.

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.
That probably means you opened up the same reference or something, more than once. It should work fine with the begin and finish VI's, while having your reference and settings in the teleop. If it isn't than you set something up wrong.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 08:54.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi