Go to Post The main use of Chiefdelphi is self expression of what FIRST means to you. - Koko Ed [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 25-11-2007, 16:31
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
in case of EMERGENCY, is a loop of NOPs an option?

if I have no other option,
is it 'OK' or 'healthy' to make a large loop of NOPs
inside the autonomous loop?
__________________
Redefining the word "Rookie". (for 2 years now..)


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

  #2   Spotlight this post!  
Unread 25-11-2007, 17:05
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: in case of EMERGENCY, is a loop of NOPs an option?

Can you explain what goal you're trying to achieve by doing that? That way, we can help you figure out if you've chosen the best method.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
  #3   Spotlight this post!  
Unread 25-11-2007, 19:12
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?

hmm... as once said,
it's fun to solve hardware problems in programming,
I'm trying to precisely control a problematic motor, (taming the lion =] )
it has very little grip, and I'm afraid that by counting-the-cycles of a full autonomous loop,
I wouldn't be able to get it to the right position.

I was thinking about getting it to work, and by the next autonomous loop(s)
get it to stay in that position X operations (using NOPs).

now,
A. will that hurt the PWM operations? (but I guess not, as it supposed to be TIMER2(?) operated)

B. can it be bad in other ways?


Thanks,
Ran.

//just making emergency plans
__________________
Redefining the word "Rookie". (for 2 years now..)


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

  #4   Spotlight this post!  
Unread 25-11-2007, 20:42
whitetiger0990's Avatar
whitetiger0990 whitetiger0990 is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Earth
Posts: 157
whitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of light
Re: in case of EMERGENCY, is a loop of NOPs an option?

It's probably a bad idea. There are parts of the code which need to be run, and they don't like it if you hold onto the execution for too long.

It'd probably give you a Code Error on the OI. (same thing happens if you accidentally have an infinite loop)
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
  #5   Spotlight this post!  
Unread 25-11-2007, 20:50
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: in case of EMERGENCY, is a loop of NOPs an option?

If your trying to make a delay with nops, then you have to make sure you have the get_data and put_data functions in there.. actually you dont really even need nops..

Code:
void delay(int time)
{
  for (int i=0; i<time; i++)
  {
    GetData(); // dont remember the parameters
    PutData(); // dont remember the parameters
  }
}
That is completely untested but it should delay...
  #6   Spotlight this post!  
Unread 25-11-2007, 21:20
whitetiger0990's Avatar
whitetiger0990 whitetiger0990 is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Earth
Posts: 157
whitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of light
Re: in case of EMERGENCY, is a loop of NOPs an option?

bear24rw:
If you do that, wouldn't you have the same precision as just counting the loop already given to you?
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
  #7   Spotlight this post!  
Unread 25-11-2007, 21:24
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: in case of EMERGENCY, is a loop of NOPs an option?

precision of delay? yeah, but you could set up a timer and use that to do accurate delays
  #8   Spotlight this post!  
Unread 25-11-2007, 21:27
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?

I do not grasp how putting a delay in an Autonomous program will cause a motor to stop 'skipping'.

Is this an airplane servo?

Or by some stroke of... well... oddness... do you have a stepper motor your trying to run for an offseason project?

I'm lost...

-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
  #9   Spotlight this post!  
Unread 26-11-2007, 12:40
JesseK's Avatar
JesseK JesseK is online now
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,627
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
  #10   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
  #11   Spotlight this post!  
Unread 26-11-2007, 16:00
JesseK's Avatar
JesseK JesseK is online now
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,627
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
  #12   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..

  #13   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
  #14   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 09:31.

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