|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
|||||
|
|||||
|
Re: PBASIC access to 1 pin only
Quote:
|
|
#3
|
||||||
|
||||||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
Quote:
Diego |
|
#6
|
|||
|
|||
|
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
|
|||
|
|||
|
Quote:
![]() 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
|
||||||
|
||||||
|
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
|
|||
|
|||
|
Re: Use feedback!
Quote:
Do you happen to have a picture of that kind of setup?Thanks! Really appreciate it! Diego |
|
#10
|
||||||
|
||||||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
Quote:
Is it possible for you to tell me which document it is in?Thanks, Diego |
|
#13
|
|||
|
|||
|
Re: Clarify please?
Quote:
![]() 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
|
||||
|
||||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |