Go to Post Don't over analyze every possibility. Studying a problem too much doesn't help any more than not studying it enough. - 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 26-11-2007, 12:40
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,661
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: in case of EMERGENCY, is a loop of NOPs an option?

You can't do for loops on the current controller iirc, but I programmed very little of it in the last 2 years.

nOPs are good enough in a jam, but you design the bot, sensors and programming other way -- the way that DOESN'T use timers/nops to get to where you want. nOPs usually lack consistency in mechanical control.
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub
  #2   Spotlight this post!  
Unread 26-11-2007, 15:17
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: in case of EMERGENCY, is a loop of NOPs an option?

Quote:
Originally Posted by JesseK View Post
You can't do for loops on the current controller iirc, but I programmed very little of it in the last 2 years.

nOPs are good enough in a jam, but you design the bot, sensors and programming other way -- the way that DOESN'T use timers/nops to get to where you want. nOPs usually lack consistency in mechanical control.
Easy partner... hardware timers are ONE OF THE best and most accurate ways of timing when code executes, or upon what interval. A must for true, high performance PID/LeadLie/StateSpace loops.

Uhm... but I'd still like to know... why do you want to make a for loop of nops?

One of the only times I've used one of these for FIRST is in my single-pin Parallax ultrasonic driver (posted here) to generate the keying pulse to trigger the ping, since it was a very short (just a few microseconds) pulse time, and would have been inefficient to set a timer and come back just to time such a short pulse. Actually, the amoount of time it takes to enter/exit an interrupt would have been longer than the duration of the pulse, so, the best option in that case was to create a for loop. It's important to note that nops are not needed in the for loop to make a spinlock/busy wait. only:

Code:
for(unsigned char delaycounts = 0; delaycounts < 10; delaycounts++);
But yeah i'm still wondering about what the long for loop has to do with making a motor not 'skip'... and how you make a motor 'skip'...

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #3   Spotlight this post!  
Unread 26-11-2007, 16:00
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,661
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: in case of EMERGENCY, is a loop of NOPs an option?

Quote:
Easy partner... hardware timers are ONE OF THE best and most accurate ways of timing when code executes, or upon what interval. A must for true, high performance PID/LeadLie/StateSpace loops.
I'm not trying to be rude; it's just that I've seen this in control systems projects in college, at my current job, and in FIRST robots who dead-reckon their autonomous.

Your controller generally has the same voltage inputs and has a low power consumption. Therefore, on a FIRST robot it can output the required PWM signal to the Victor regardless of the battery voltage. However, if the battery isn't always at the same exact voltage the actual amount the motor turns will be different every time you run autonomous.

In the original poster's case, nOPs are good in an emergency situation, however it is very dependant upon the battery manager of the team ensuring the robot has a juiced up battery every time. You'd be surprised how many times you start a match with "charged" 10-11v battery simply because there wasn't enough time to charge it between the last match and your current one or someone mixed the batteries up. It also takes several hours to go from 12v to the max 13.2v. The point is, over the course of a day you'll probably almost never get consistent voltages. For mechatronical timing to work as suggested, the power source MUST be constant. It works in a pinch, but it's generally bad engineering to do in the long-term.

I believe the easiest-to-design sensor in this case would be a black mark on the shaft with a light sensor/line detector in conjunction with a state machine in the code in order to determine when the shaft is at the correct position. This will consistently get you to the correct spot every time. You can reference some of the photos in FIRST: Behind the design, team 111's feedback sensors for the turret. If the shaft must do more than one full rotation, you can either try to account for that in the code or use a shaft encoder instead.
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub
  #4   Spotlight this post!  
Unread 26-11-2007, 18:04
3dude_2231's Avatar
3dude_2231 3dude_2231 is offline
no one messes with a Thingy =|
AKA: Menscher,Ran Menscher =]
FRC #2231 (Onyxtronix)
Team Role: Leadership
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Shoham, Israel
Posts: 233
3dude_2231 is a jewel in the rough3dude_2231 is a jewel in the rough3dude_2231 is a jewel in the rough
Send a message via MSN to 3dude_2231
Re: in case of EMERGENCY, is a loop of NOPs an option?

thank you guys for replying,

for you curious guys, we lost one of our sensors at the regional
(a magnetic sensor, giving us logic '1' whenever 2 magnetic plates are near).
(un)fortunately, autonomous didn't work right anyway, so it wasn't a problem =/
I was thinking, .....if we had to make a quick solution...............

now, I'm thinking more of using an unused TIMER (3 I think is unused by us)
with a prescaler, and multiply that period,
so nothing goes wrong.

we might just as well prepare extra sensors, but it could take some time to fit them.
__________________
Redefining the word "Rookie". (for 2 years now..)


Israeli Off Season Games: WINNERS!
check out this cool project I'm into..

  #5   Spotlight this post!  
Unread 27-11-2007, 11:52
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: in case of EMERGENCY, is a loop of NOPs an option?

Okay... but why use nops? You really should (and its more stable this way) write your code re-entrantly, so that it can freely loop as the system lends itself to.

Personally, even when dead-reckoning a machine, I like to write a script executer so I have a simplified language i can quickly write autonomous scripts in (case in point, the debut of RALFF on our sweet 2006 adaptive autonomous mode) and lets you have multiple programs loaded that are switch-selectable at match time with either jumpers, toggle switches, or (my favorite) a hex-wheel encoder. Its a nice system... all you have to do is sit down with your strategist/driver and work out strategies that you like for autonomous, write the scripts, and give them a 'playbook'.

Well, i'm getting off track. For you to schedule things to happen, you can do something as simple as this if you want, now this is dirty but I think gets you where you want, again, if I were you I'd go ahead and just write the script executor, but, here we go:

Code:
//variable
unsigned int time = 0;

//inside User_Autonomous_Code

time++;
if (time < 10)
{
  //do things that happen until 10 time counts (or until .254 seconds if using frc controller)
  pwm01 = pwm02 = 200; //drive forwards-ish
}
else if (time < 100)
{
   //do things that happen until 100 time counts (or 2.54seconds)
   pwm01 = 100;
   pwm02 = 200;  //spin for a while
}
//etc.
That should do what you want I think... and yes, it is very very true that an encoded tire is always better than a dead-reckoned one.

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #6   Spotlight this post!  
Unread 27-11-2007, 15:39
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: in case of EMERGENCY, is a loop of NOPs an option?

NOPs are often used in assembly language programming where a very (very! a microsecond or two!) short, predictable delay which is some multiple of the CPU clock instruction time is needed. I've used these when talking to peripheral devices at bus speeds ... there isn't enough time to configure or even check a timer value, just enough to execute a few NOPs. Usually interrupts are OFF as well - to avoid unexpected extra time.

I don't think that will be useful here ...

a) in a for-loop with an index that counts up to some large number, the NOP makes a poor-man's timer. But if you stay in the loop for a too long (> 26 msec) without a PutData(), there is the risk of the Code Error light coming on and your program being terminated, as whitetiger0990 said.

b) don't you need to check the autonomous bit in the loop too?

c) the IFIRobotics FAQ on Victor Speed Controllers states that the Victor updates at about 120 Hz, so the fastest it will accept updates is every 8 msec. This seems to be your limiting factor.

d) last year we had a too-small motor on our arm prototype, and yes it had zero holding power and we had to keep kicking it to resist gravity pulling the arm down. After a few seconds of this, the motor began to smoke! The moral of the story: use a different motor, with gearing high enough to provide the "holding power" that you need.

I'm guessing your desire for a quick-and-dirty solution to timers relates to the amount of code that would have to be found and commented in or out as you were making your between-match fixups. You might also want to consider using EasyC and WPILIB - MUCH easier to use timers/etc ...

mike


PS - another use of NOPs (back in the dim, dark past) was to leave extra space in the executable part of the program so as to PATCH in extra code manually through front-panel switches. I guess that's not the case here unless you are writing self-modifying code!
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
Segway to offer financing option Jon K. Dean Kamen's Inventions 5 02-06-2006 12:13
Show Avatar option broken devicenull CD Forum Support 0 12-02-2006 23:17
Check All option on Recent Activity Configuration sanddrag CD Forum Support 0 29-01-2006 22:35
The 'nuclear option' has been averted JoeXIII'007 Chit-Chat 19 24-05-2005 20:28
The Chat Option Ragin_Kage Chit-Chat 2 04-03-2002 01:19


All times are GMT -5. The time now is 00:17.

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