Go to Post Boy, am I ever glad we decided not to use eggs as game pieces like I originally suggested... - dlavery [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 17-01-2002, 19:36
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
PBASIC access to 1 pin only

Hi all,

This is my first year in FIRST, so please bear with me

How can I output voltage to one of the PWM pins only? If I use SEROUT, I also have to specify all the other pins, including the relay pins. More specifically, I want to use the PWM command, which requires a pin. But I don't think the pin number for the argument is the same as the pin number on the RC...because the Software Handbook (.pdf) says that the Issac system (is it the PBASIC processor inside the RC?) has 8 analog outputs, but the RC has 16...

Thanks,

Diego

Last edited by diego25 : 17-01-2002 at 19:46.
  #2   Spotlight this post!  
Unread 17-01-2002, 19:50
Unsung FIRST Hero
Nate Smith Nate Smith is offline
FRC Key Volunteer Trainer
AKA: CrazyNate
no team
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Old Town, Maine
Posts: 1,029
Nate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to beholdNate Smith is a splendid one to behold
Send a message via AIM to Nate Smith Send a message via Yahoo to Nate Smith
Re: PBASIC access to 1 pin only

Quote:
Originally posted by diego25
Hi all,
How can I output voltage to one of the PWM pins only? If I use SEROUT, I also have to specify all the other pins, including the relay pins.
The PBASIC processor we actually program on the robot is not directly connected to the outputs of the Robot Controller, rather, it is run through an "output processor" within the RC. Therefore, you have to use the SEROUT command as shown within the default code to communicate with any of the outputs, relay or PWM. Due to the internal nature of the Innovation First Control System, the PWM command in PBASIC is not of much(if any!) use to us...just send a 0-254 value using SerOut to talk to the Speed Controllers...
__________________
Nate Smith
nsmith@smythsoft.com
12 seasons, 4 teams, and more time logged behind the scorekeeper's table than I care to remember...
returning for 2011? only time will tell...
  #3   Spotlight this post!  
Unread 17-01-2002, 20:30
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,631
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
See my Novi Presentation on Innovation First Hardware & Default Code.

Basically, the only direct access you have to the outside world is to flash a few LED's.

Anything more that requires going through the Master CPU on the Robot Controller.

You are the tail, you are not the dog.

Remember that and you will get along just fine.

Joe J.
  #4   Spotlight this post!  
Unread 17-01-2002, 20:36
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
Hm, yeah, that's what I was afraid of...

Ok, here's my problem:

I need some way to do timed output, i.e. output voltage for a certain amount of time only. I'm writing a program for a steering wheel. So when you move the joystick right, it turns right. When you move the joystick left, it turns left. I kind of have it working, but the problem I'm having is that I can't control HOW MUCH the motor (that turns the wheel) turns. I was thinking of using PWM and use its cycles argument to time it...but I guess that won't work. So, how would I be able to do this?

This is my current code - it is modified from the default program:

'Beginning stuff

p1_x_old VAR BYTE
PWM2 VAR BYTE
p1_x_old = p1_X
PWM2 = 127

Mainloop:

'SERIN, etc

'My code follows
IF ABS (p1_x_old - p1_x) < 2 THEN skip2

IF p1_x_old < p1_x THEN skip1
PWM2 = 200
p1_x_old = p1_x
GOTO skip3
skip1:
PWM2 = 60
p1_x_old = p1_x
GOTO skip3
skip2:
PWM2 = 127
skip3:

'limits, SEROUT, etc
GOTO Mainloop


I know I've got a bit of a logic error (i.e. it doesn't take into account how much the joystick moved), but I think I'll be able to solve that once I can get a timed output Or would a joystick-dependent voltage be the answer here?

Thanks!!

Diego
  #5   Spotlight this post!  
Unread 17-01-2002, 20:41
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
Quote:
Originally posted by Joe Johnson
See my Novi Presentation on Innovation First Hardware & Default Code.

Thanks, I'll check it out.

Diego
  #6   Spotlight this post!  
Unread 17-01-2002, 20:56
Kai Zhao Kai Zhao is offline
Registered User
#0686 (Bovine Intervention)
 
Join Date: Nov 2001
Location: Frederick, MD
Posts: 28
Kai Zhao is on a distinguished road
Send a message via AIM to Kai Zhao
3 ways (that I can think of):

-Make a counter. Crude example code below.
Count = Count + delta_t + 1
If count < (value)
PWM1 = 255
PWM2 = 255
goto end_drive
'if finished, do nothing
PWM1 = 127
PWM2 = 127
end_drive:

-Use the gyroscope and record your angular velocity (or is it acceleration?). Manipulate the data to suit your needs.

-What I call 'CSS'. Basically, it is a wheel with sensors on or near it. See this post: http://www.chiefdelphi.com/forums/sh...&threadid=1814
Instead of measuring forward velocity, you would want a "magic wheel" and have it pointed sideways. Or, you can make two and put them on either side of your robot and measure the difference.

I believe the last idea is the best, but it is also the most complex.
  #7   Spotlight this post!  
Unread 17-01-2002, 21:17
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
Quote:
Originally posted by Kai Zhao
3 ways (that I can think of):

-Make a counter. Crude example code below.
<snip>

-Use the gyroscope and record your angular velocity (or is it acceleration?). Manipulate the data to suit your needs.

-What I call 'CSS'. Basically, it is a wheel with sensors on or near it.
<snip>
Yup, I was thinking about putting a counter type of thing also. But I was afraid that each iteration of the mainloop will have different running times and therefore the amount of output will also be variable. Therefore, it won't be able to center again, when the joystick is in the middle. But again, these are just my useless newbie instincts so I'm going to try this tomorrow when I get to school

About the 'CSS', I don't think I'll do it that way...I'd like to keep the robot simple; it's just my first year, so I don't want to make it too complicated and end up with a non-working robot.

Thanks,

Diego

Last edited by diego25 : 17-01-2002 at 21:20.
  #8   Spotlight this post!  
Unread 17-01-2002, 21:19
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,631
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Use feedback!

I don't think you will not be successful at what you are trying to do by just timing the outputs.

You really need to use feedback.

Have a potentiometer (pot) give your program the true position of the steering.

Compare the pot value to the desired value. Calculate the sign and magnitude of the error. Multiply the magnitude of the error by a gain (you may want to multiply it by a constant and divide it by a power of 2, i.e. shift the result right N bits, this will give you the abiltiy to have a gain between 1 and 2 for example). Then if the error is greater than zero add this scaled error to 127 to get the appropriate PWM output. If the error is less than zero subtract the scaled error from 127 to get your appropriate PWM output. You have to be careful about going under 0 or over 254 with your PWM output.

Anyway, this is a very simple feedback loop (called proportional feedback). It works pretty well, especially for steering (trust me I know this to be true).

Have your finger on the e-stop button (you all have built a yellow dongle with an e-stop button haven't you?) as you test your code because it is easy to have the steering go insane while you debug your code. You have to get the gain to have the right sign AND you have to have the gain set large enough but not too large. There are a lot of places to stub your toe, but the destination is worth the trip.

Good luck.

Joe J.
  #9   Spotlight this post!  
Unread 17-01-2002, 21:47
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
Re: Use feedback!

Quote:
Originally posted by Joe Johnson
You really need to use feedback.

Have a potentiometer (pot) give your program the true position of the steering.

<snip>

Anyway, this is a very simple feedback loop (called proportional feedback). It works pretty well, especially for steering (trust me I know this to be true).
I see, I see. How would I hook up the potentiometer, though? The potentiometers that I've worked with, are small, designed for small electronic circuits...so I can't really imagine how I can hook it up to the steering wheel. I'll check tomorrow if we've gotten any potentiometers from Innovation First and try to figure it out from there Do you happen to have a picture of that kind of setup?

Thanks! Really appreciate it!

Diego
  #10   Spotlight this post!  
Unread 17-01-2002, 22:16
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,631
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Using a pot for a sensor is a very well documented practice in the FIRST manual and in the Innovation First documentation.

We have 100K pots at our disposal. Put 5V from the sensor port on one side of the 100K pot, ground the other side, send the wiper to the sensor pin of your hearts desire.

It is as simple as that.

As to pictures, ask around, you would have thought our swerve motors last year were related to Princess Di for all the pictures folks took of them ;-)

Joe J.
  #11   Spotlight this post!  
Unread 17-01-2002, 23:32
s_alaniz s_alaniz is offline
Registered User
#0057 (Leopards)
 
Join Date: Jun 2001
Location: Houston, Tx
Posts: 73
s_alaniz is an unknown quantity at this point
Clarify please?

Diego,
I can't tell what it is you're trying to accomplish. Are you trying to limit how far the wheel turns? Or do you want to trigger a sequence that holds the wheel turned for some amount of time and then returns to straight? Sorry, I'm a bit muddled ... I read through your program and it looks like as long as the joystick continuses to change the stering motor moves, but as soon as it stops and stays within the former cycle value +- 2 it stops moving...it works almost like a computer mouse. kind of strange but..ok... so what exactly do you want it to do?

Best Wishes


Steve Alaniz


"Did you know Einstein once stuck out his tongue for a picture?" - Hilary Forth
"Probably expressing his opinion of housework" - Sally Forth as she unloads a washing machine.
  #12   Spotlight this post!  
Unread 21-01-2002, 08:39
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
Quote:
Originally posted by Joe Johnson
Using a pot for a sensor is a very well documented practice in the FIRST manual and in the Innovation First documentation.
Sorry, I'm new to this and I wasn't able to find any documentation on using pots for a sensor in the FIRST Manual. And I checked out the documentation at Innovation First's website but couldn't find it either Is it possible for you to tell me which document it is in?

Thanks,

Diego
  #13   Spotlight this post!  
Unread 21-01-2002, 08:42
diego25 diego25 is offline
Registered User
#0897
 
Join Date: Jan 2002
Location: Toronto, Ontario
Posts: 10
diego25 is an unknown quantity at this point
Re: Clarify please?

Quote:
Originally posted by s_alaniz
Diego,
I can't tell what it is you're trying to accomplish. Are you trying to limit how far the wheel turns? Or do you want to trigger a sequence that holds the wheel turned for some amount of time and then returns to straight? Sorry, I'm a bit muddled ... I read through your program and it looks like ...
<snip>
so what exactly do you want it to do?
Yeah, I know, my program doesn't do what I wanted it to do; that's why I'm asking here

If the joystick is halfway left, I want a motor to turn 45 degrees and stop. If the joystick is all the way left, I want the motor turn till 90 degrees and stop. Basically I'm trying to write a program for a steering wheel.

Thanks,

Diego
  #14   Spotlight this post!  
Unread 21-01-2002, 10:55
s_alaniz s_alaniz is offline
Registered User
#0057 (Leopards)
 
Join Date: Jun 2001
Location: Houston, Tx
Posts: 73
s_alaniz is an unknown quantity at this point
program

Yep, the advice you were given is correct. You need some kind of sensing of the wheel position to impliment the scheme you're looking at. Potentiometer is the proven way to go, I'll look for a scheme we used for an arm sensor last year. We've dismantled the robot so it's hit and miss.


Best Wishes

Steve Alaniz






" Computers are taking over? Good! Let THEM try to figure all this out for awhile..." - Sally Forth
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
PBASIC ARCTAN function Greg Ross Programming 14 11-05-2003 12:28
Obscure PBASIC for RoboEmu rbayer Programming 1 28-03-2003 23:57
PBasic 2.5 vs. 2.0 Anthony Kesich Programming 6 09-02-2003 22:06
Diagrams for wiring of 15 and 25 pin connectors archiver 2000 2 23-06-2002 23:03
Subtotaling in PBASIC? Ian W. Programming 17 02-02-2002 20:22


All times are GMT -5. The time now is 09:59.

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