Penguin turning 90 degrees left and right
Capt.Kerry
Posts: 28
Hi, am trying to scan left and right with the Penguin and PING)) sensor. I can use the "heading" value to find out where the Penguin is pointing and its easy to add or subtract 90 to establish what direction to scan to.·How·would I then store that (those)·values without it getting overwritten each time the penguin checks its current heading as the program loops?
Thanks for any suggestions.
Thanks for any suggestions.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Sorry, new at all this so am stealing bits from other programs and trying to jam them together!
Basically for the moment just trying to get the Penguin to sense his heading using a subroutine which polls the compass and converts it to degrees and stores it in a variable called Heading
'
Read Compass Heading
ReadCompass: ' Compass reading subr
HIGH Enable ' Send reset command to HM55B
LOW Enable ' P4 controls HM55B's /Enable
SHIFTOUT Compass, Clock, MSBFIRST, [noparse][[/noparse]Reset\4]
HIGH Enable ' Start HM55B measurement
LOW Enable ' P4 controls HM55B's /Enable
SHIFTOUT Compass, Clock, MSBFIRST, [noparse][[/noparse]Measure\4]
status = 0 ' Clear previous status flags
DO ' Status flag checking loop
HIGH Enable ' Measurement status command
LOW Enable ' P4 controls HM55B's /Enable
SHIFTOUT Compass, Clock, MSBFIRST, [noparse][[/noparse]Report\4]
SHIFTIN Compass, Clock, MSBPOST, [noparse][[/noparse]Status\4]
LOOP UNTIL status = Ready ' Exit loop if status is ready
SHIFTIN Compass,Clock,MSBPOST,[noparse][[/noparse]x\11,y\11] ' Get x & y axis values
HIGH Enable ' Disable module
IF (y.BIT10 = 1) THEN y = y | NegMask ' Store 11-bits as signed word
IF (x.BIT10 = 1) THEN x = x | NegMask ' Repeat for other axis
Heading = x ATN -y ' Convert x and y to brads
Heading = Heading */ 360 ' Convert brads to degrees
RETURN
Then I take that value and subtract 90 (degrees) from it and tell the penguin to turn that way using something like:
IF Heading > (Heading -90 ) THEN TurnLeft
Obviously this wont work because when the program loops to read the compass to see if the penguin has turned 90 degrees the Heading variable gets updated and he turns in a circle.
I need to be able to somehow store the 90 degree direction in a different variable which doesn't get changed until the penguin has achieved it. (Which is what you suggest)
Could you give me a bit of direction (+/- 90 Degrees!) on how to store in in a variable that doesn't get updated each time?
numbers when needed. When flagging compass directions, to
improve performance, a range of values is suggested. If the
number bumps around, it may not see the +90 or -90 value.
So, an envelope around 5 degrees is workable. For experimenting
with this effect, try using the tuner on the Penguin Robot Radio.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
humanoido
*Stamp SEED Supercomputer *Basic Stamp Supercomputer *TriCore Stamp Supercomputer
*Minuscule Stamp Supercomputer *Three Dimensional Computer *Penguin with 12 Brains
*Penguin Tech *StampOne News! *Penguin Robot Society
*Handbook of BASIC Stamp Supercomputing
*Ultimate List Propeller Languages
*MC Prop Computer
for sections involving writes to the eeprom as examples. It's
not as challenging as you might think. The Penguin reset
button code, when converted to a virtual keyboard, makes
use of the eeprom, for one example. There's code to do this
in the master program for the Penguin Superhero too. The
SEED Stamp Supercomputer also uses a technique of storing
into eeprom memory, i.e. each life form will memorize its own
unique self determinations. The code understanding is
principally the same for a Penguin robot. You are welcome
to use any sections of this code for your project. The STAMP
book and software have excellent examples too.
humanoido