Go to Post We can build it... we have the technology...better than it was before... Better...stronger...faster.... more PINK - Barry Bonzack [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2003, 17:06
PBoss PBoss is offline
Registered User
#1212
 
Join Date: Jan 2003
Location: Nowhere
Posts: 9
PBoss is an unknown quantity at this point
sensor doesn't work

I just hooked up the sensor as described by First, wiring the two digital outputs to switch 15 and 16 and also wrote the following command statement:
if rc_sw15 = 1 then p2_y=150
if rc_sw16 = 1 then p4_y=150
But when I turn the robot on and try different surfaces, the sensor doesn't do anything, it doesn't turn p2_y=150
Help!
  #2   Spotlight this post!  
Unread 29-01-2003, 17:18
mjt902 mjt902 is offline
Registered User
#0902
 
Join Date: Apr 2002
Location: Heritage High School
Posts: 31
mjt902 is an unknown quantity at this point
i don't think you can set p2_y to a set speed. what you want to do is set your actual drive to a set speed.

when you set p2_y to a set speed, it immediately switches back to whatever position the joystick is in, probbly around 127. therefore 127 is sent to the serout line.

this is what you want:

if rc_sw15 = 1 then drive_L = 150

or whatever drive variable you are using
__________________
Top Ten Reasons to Procrastinate:
1.
  #3   Spotlight this post!  
Unread 29-01-2003, 17:24
Goya Goya is offline
Registered User
#0019 (Big Red)
 
Join Date: Jan 2003
Location: Greenwich, CT
Posts: 35
Goya is an unknown quantity at this point
Send a message via AIM to Goya
You can use the p1_y, p2_y values in the default code. The SEROUT command maps the p1_y, p2_y values to the actual PWM outputs.

As for the code above. It sounds a lot like a wiring problem.

Remember -
Blue/Brown = Power and Ground
White/Black = Inputs

Pick either White or Black and wire it up. DONT USE BOTH!!!!

White-wired sensors return a 1 if they detect something and a 0 if the detect nothing. Black-wired sensors are exactly opposite.

The code would be correct for a white-wired sensor on rc_sw15 + rc_sw16.
  #4   Spotlight this post!  
Unread 29-01-2003, 17:32
mjt902 mjt902 is offline
Registered User
#0902
 
Join Date: Apr 2002
Location: Heritage High School
Posts: 31
mjt902 is an unknown quantity at this point
Yes, you can use the p1_y or p2_y but it CHANGES TO WHATEVER THE REAL VALUE IS FROM THE JOYSTICK. When your program runs, it sees your joystick at roughly 127, and then your code changing it to 150. This makes is continually switch from 127 to 150 to 127.

you could set your wheel to make p1_y = 150 but it's safer, and (although this is coming from someone completely insane and mentally unstable) easier to use your drive variable.
__________________
Top Ten Reasons to Procrastinate:
1.
  #5   Spotlight this post!  
Unread 29-01-2003, 18:02
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by mjt902
Yes, you can use the p1_y or p2_y but it CHANGES TO WHATEVER THE REAL VALUE IS FROM THE JOYSTICK. When your program runs, it sees your joystick at roughly 127, and then your code changing it to 150. This makes is continually switch from 127 to 150 to 127.

you could set your wheel to make p1_y = 150 but it's safer, and (although this is coming from someone completely insane and mentally unstable) easier to use your drive variable.
Not true. p1_y is not "bound" to the joystick. It only gets updated when you do a SERIN. Otherwise, it acts like any other normal variable. Likewise, setting PWM1 to a value won't actually change the value sent to the motor until you do a SEROUT.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #6   Spotlight this post!  
Unread 29-01-2003, 18:29
mjt902 mjt902 is offline
Registered User
#0902
 
Join Date: Apr 2002
Location: Heritage High School
Posts: 31
mjt902 is an unknown quantity at this point
So what you are suggesting this guy do is not put SERIN in the mainloop??
That makes sense and clears me up on a few things. Thaks for the gentle and insightful correction.
__________________
Top Ten Reasons to Procrastinate:
1.
  #7   Spotlight this post!  
Unread 29-01-2003, 18:38
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by mjt902
So what you are suggesting this guy do is not put SERIN in the mainloop??
That makes sense and clears me up on a few things. Thaks for the gentle and insightful correction.
NO!!!!! If you don't do a SERIN, delta_t will never get updated. Nor will any of your sensors, etc.

All I'm saying is that as long as you don't do a SERIN between the p1_y=150 and the SEROUT, p1_y can be used as a normal variable. For example:

DO
SERIN...

if rc_sw15 = 1 then p2_y=150
if rc_sw16 = 1 then p4_y=150

SEROUT...
LOOP

Until the code reaches the next SERIN, p2_y/p4_y will still have the values 150.


Back to the problem: my guess is that you have the incorrect sensor wire hooked up. You can use either, but your code needs to match. To see if this is the problem, try doing a debug? rc_sw15 right after the SERIN and see if it changes.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #8   Spotlight this post!  
Unread 29-01-2003, 18:39
Goya Goya is offline
Registered User
#0019 (Big Red)
 
Join Date: Jan 2003
Location: Greenwich, CT
Posts: 35
Goya is an unknown quantity at this point
Send a message via AIM to Goya
Quote:
Originally posted by mjt902
So what you are suggesting this guy do is not put SERIN in the mainloop??
That makes sense and clears me up on a few things. Thaks for the gentle and insightful correction.
Was that sarcastic?

p1_y is only a variable. It is not bound to the joystick. For simplicity in the default code, the value of this variable at the end of the mainloop is transfered to the motor via SEROUT.
Closed Thread


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
Problems of the mind... effecting work Gadget470 Chit-Chat 20 18-11-2003 11:56
Fall work shops Macdaddy549 General Forum 4 02-10-2003 15:51
Edit doesn't work on original title posts??? Elgin Clock CD Forum Support 6 12-03-2003 17:30
Who knows how the motors [I]really[/I] work? Wetzel Chit-Chat 5 13-02-2002 21:50
Does anyone on this board work at home depot? mnkysp6353 General Forum 2 30-12-2001 13:27


All times are GMT -5. The time now is 13:56.

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