Go to Post Kids should already be motivated to build the best robot they can, and learn as much as they can. They shouldn't need extra incentives. - Matt382 [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
  #16   Spotlight this post!  
Unread 29-01-2003, 21:08
Greg McCoy's Avatar
Greg McCoy Greg McCoy is offline
boiler up!
FRC #3940 (CyberTooth)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Kokomo, IN
Posts: 484
Greg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond repute
Send a message via AIM to Greg McCoy
Yes! He explained it better than I did. One thing that I would add is if you are really strained for RAM is that you could keep the counter a byte and if you need numbers bigger than the byte will supply, just add steps until you get the length you need.
  #17   Spotlight this post!  
Unread 29-01-2003, 22:59
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
Once again you correct me!!! Oh, I'm lazy anyway but thanks for the free code. Only one question have I:
where'd you get the 8 from in SELECT(loopCntHigh<<8 + loopcnt)

i think you and i are on the same page (only i'm on a different plane) , and its great learning from you!!!
The 8 will shift it left by 8 bits, leaving enough space for the byte (8-bits) to fill in the newly created free space.

Here's an example:

Assume loopCntHigh is 3 (0011 in binary), meaning we've looped through 256 values of loopCnt 3 times.
Assume loopCnt is 199 (11000111).

Then: loopCntHigh<<8=001100000000
Add loopCnt: 001111000111, which is 967. This makes sense as 256*3+199=967.

Does that make any sense? Bit shifting operations are always messy, but sometimes they are the easiest solution to problems like this (a single number spanning multiple variables).
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #18   Spotlight this post!  
Unread 30-01-2003, 08:46
Caleb Fulton's Avatar
Caleb Fulton Caleb Fulton is offline
Z = Z^2 + C ......WHEEEE!
AKA: aXvXiA
#0461 (West Side Boiler Invasion)
Team Role: College Student
 
Join Date: Dec 2002
Location: West Lafayette, Indiana
Posts: 205
Caleb Fulton has a spectacular aura aboutCaleb Fulton has a spectacular aura aboutCaleb Fulton has a spectacular aura about
Send a message via AIM to Caleb Fulton
Rob: Is there a place online that documents the mathematical limits of PBasic?

I ask because I like your bytevariable<<8+nibblevariable trick
__________________
  #19   Spotlight this post!  
Unread 30-01-2003, 20:54
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 Caleb Fulton
Rob: Is there a place online that documents the mathematical limits of PBasic?

I ask because I like your bytevariable<<8+nibblevariable trick
Depends on what limits you are talking about. The Stamp manual from Parallax contains all the math operators, etc that the Stamp supports, but it doesn't give many good examples of how you would use most of it.

For me, I've picked most of it up doing a LOT of C/C++ stuff, much of which includes bit-operations such as this. Randall Hyde's assembly language tutorial (http://webster.cs.ucr.edu/Page_asm/A..._ArtofAsm.html) has some really good info on binary math and logic, but it isn't exactly and easy read. Like always, I'm available to answer any questions anybody comes up with, so feel free to drop me a PM or email.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #20   Spotlight this post!  
Unread 01-02-2003, 15:29
Mike537Strategy Mike537Strategy is offline
Registered User
#0537 (Charger Robotics)
 
Join Date: Jan 2003
Location: Sussex Wisconsin
Posts: 25
Mike537Strategy is an unknown quantity at this point
I'm trying to use the original timer code from the first thread in a simple dead reckoning pattern. My code has the time calculator directly after the SERIN, has 2 lines of code changing the wheel numbers for the SEROUT, then the SEROUT. It loops this until realtime = whatever time I want. It goes forward, turns right, forward, right, forward, right, then forward. The problem is that after the first forward (Which works perfectly), it just turns right until I turn off the robot. Any ideas why? The variables are the same as the default, delta_t is declared and set to 1 in intilization. The forums aren't being nice and the SERINs are all on one line in the actual code.

Code:
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   p1_y = 254
   p2_y = 0
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 1
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   p1_y = 254
   p2_y = 0
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 1
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   p1_y = 254
   p2_y = 0
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 1
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
__________________
"Charging into the future, one game at a time." - Team 537 motto
  #21   Spotlight this post!  
Unread 01-02-2003, 16:32
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
Don't forget to reset realtime to 0 between your sections. Or, you could change the "loop until realtime=1" to "loop until realtime=3". From quickly looking over your code, I'd guess that this is the problem.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #22   Spotlight this post!  
Unread 02-02-2003, 20:40
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Question Why make it so hard on yourselves

why are all of you making it so hard on yourselves?
just put the time counting loop at the beginning of your autonomous mode, then use if/then statements relating realtime and time. Why repeat it 7 times throughout your code along with serin again and again? plus, why worry about counting for 1 min 45 sec? unless i am extremely mistaken, the auton mode is only 15 seconds long, and i doubt you want to run your robot autonomously after that because no matter how godly of a programmer you are, human senses, adaptability, and recognization will always outdo straight computer logic.

-Anthony
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year
  #23   Spotlight this post!  
Unread 03-02-2003, 23:52
wwrye wwrye is offline
Registered User
#0057 (Leopards)
 
Join Date: Jan 2003
Location: Houston
Posts: 18
wwrye is an unknown quantity at this point
Angry redundance

Mike, what is up with all the identical code, don't you think you could go with the flow of the main loop and just do something like this:
Code:
':::Timer variables
cntr_cycles 	VAR byte
seconds		VAR nib '15 sec timer,make byte for more time

seconds = 0           'same as your realtime variable
cntr_cycles = 0       'same as your time variable

...

if auton_mode = 1 then do_auton

	'non autonomous code	

	
goto skip_auton
do_auton:

':::15 second TIMER::
	if cntr_cycles >= 38 then update_timer

	goto skip_update_timer
	update_timer:
		seconds = seconds + 1
		cntr_cycles = 0
	
	skip_update_timer:

		select seconds
			case <6  'until seconds = 5
				drive_R = 180	'put drive commands accordingly
				drive_L = 180
			case <11 
				drive_R = 127
				drive_L = 127
			case <16
				drive_R = 64
				drive_L = 190	
		endselect

	cntr_cycles = cntr_cycles + 1 + delta_t
	'debug ?cntr_cycles, tab, ?delta_t, tab, ?cntr_cycles, cr
':::15 second TIMER::
Questions/comments, pm me
  #24   Spotlight this post!  
Unread 05-02-2003, 13:12
Steven Carmain Steven Carmain is offline
Bit Twiddler
FRC #2832
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Westland, MI
Posts: 92
Steven Carmain will become famous soon enough
A problem is your mixing syntaxes. The goto in the beginning is 2.0, but select case is 2.5
__________________
2017 - Team 2832 Mentor
2016 - Team 6013 Mentor
2002-05 - Team 45 Software/Electrical

A robot is like a campfire: it takes a while to bulid it, and then everyone surounds it!
A world without standards is chaos. A world with standards is chaos.
  #25   Spotlight this post!  
Unread 05-02-2003, 17:45
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 Steven Carmain
A problem is your mixing syntaxes. The goto in the beginning is 2.0, but select case is 2.5
There is no problem with his code. You can mix 2.0 syntax into the 2.5 without any problems. It would be better from a style perspective to have said:

if auton_mode=1 then
'auto code goes here
else
'normal here
endif

but it isn't wrong to do it the other way.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #26   Spotlight this post!  
Unread 06-02-2003, 22:33
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
You don't need to worry abou the timing, just take your "cue" for the fifteen seconds from when auton_mode changes to zero and comp_mode (or something like that) changes to 1.
__________________
"Lock the Doors"

NASA chief flight director Leroy Cain on the loss of Columbia's signal.
  #27   Spotlight this post!  
Unread 07-02-2003, 01:11
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 Morgoth
You don't need to worry abou the timing, just take your "cue" for the fifteen seconds from when auton_mode changes to zero and comp_mode (or something like that) changes to 1.
But if you're doing dead-reckoning, you need to know how many seconds have passed so far so that you know what you should be doing.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #28   Spotlight this post!  
Unread 07-02-2003, 19:17
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
Ahhhh, now I understand. Thanks for the insight. We are going to follow the line so I didn't think of that.
__________________
"Lock the Doors"

NASA chief flight director Leroy Cain on the loss of Columbia's signal.
  #29   Spotlight this post!  
Unread 08-02-2003, 10:32
Greg McCoy's Avatar
Greg McCoy Greg McCoy is offline
boiler up!
FRC #3940 (CyberTooth)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Kokomo, IN
Posts: 484
Greg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond repute
Send a message via AIM to Greg McCoy
There are many ways to skin the cat, but some ways are better than others
  #30   Spotlight this post!  
Unread 08-02-2003, 15:00
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
Quote:
Originally posted by rbayer
But if you're doing dead-reckoning, you need to know how many seconds have passed so far so that you know what you should be doing.
Not necessarily the number of seconds, but rather the amount of time(program cycles work here) your program has been running...and it's easy enough to have a program you can "train"...i'm going to be putting together a white paper sometime later in the season about the autonomous training system I came up with for a team that I got asked to help...
__________________
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...
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
Timing of nats for next year Ian W. Championship Event 13 03-03-2003 18:28
Way back there. Size of Nationals, and a solution archiver 2001 23 24-06-2002 03:28
what is or isn't a timing belt? archiver 2001 6 23-06-2002 23:26
two sided timing belt archiver 2001 3 23-06-2002 22:34
Dual Sided Timing Belts Lachuck894 Technical Discussion 9 14-01-2002 10:10


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

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