Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp Program Help — Parallax Forums

Basic Stamp Program Help

ArchiverArchiver Posts: 46,084
edited 2003-12-02 22:26 in General Discussion
Sorry about that, and I apologise for not posting the message, I
really thought I did. I guess, I may have pushed the wrong botton.
Anyway, thinks for the help. THe part that is not working correctly
for me yet is this. I am not getting the binary equivalent of the
two decimal digits that are randomly selected at the output. for
instance, if 2 (010) and 3 (011) are selected, I want pins 2, 4,and 5
to be on while pins 1,3,and 6 are off. this is the part that is not
working correctly for me yet. So I am not sure if I am setting my
outputs correctly, or if my variable definitions are correct. Thanks
again.

jacclem@h...

*********** God Loves You, John 3:16 ***********

Jean C.






>From: "Jon Williams" >

To: >Subject:

RE: Basic Stamp Program Help!

>Date: Tue, 2 Dec 2003 11:33:36 -0800 >

>What's not working? The only thing that I can see wrong (after a
very >quick look) is that his line: > > OutL = %01111111 ' P0 - P6
are outputs > >Should be... > > DIRL = %01111111 ' P0 - P6 are
outputs > >The DIRS register is what controls the pin's IO
configuration (0 = >input, 1 = output). > >Please understand that my
schedule doesn't really permit personal >consulting like this, and by
only sending you the answer, only you >benefit. In future, please
post these questions to the BASIC Stamp >group list so that you can
get help if I'm not available and everyone >can learn. > >-- Jon
Williams >-- Parallax > > > > >

Original Message
>From: konpen [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7kiFdD3EVB1faVPnNJp6efO6F-u37dclUzoPxYzs78uHJsNJvRHWntr1OFAz5-51ShSFEajtNrBs]jacclem@h...[/url
>Sent: Tuesday, December 02, 2003 1:16 PM
>To: Jon Williams
>Subject: Basic Stamp Program Help! > >
>Hello Jon, I wrote you a couple of weeks ago about a program that I
>am working on, and you reply with some very helpful suggestions. I
>really appreciate that. However I am still having some issues with
>the program. Bellow is a copy of my program as well as the original
>e-mail with the reply below it. I went to Basic stamp manual, but I
>have not been able to resolve the original problem. SO I wanted to
>send you a copy of the program, for review. I would really
>appreciate it if you would take a look at it and let me know what
>correction you think I should implement please. bellow is a copy of
>the program. you may e-mail me at jacclem@h... please. >
>Thank you very much for your help with this. >
>*************************************** > >'
[noparse][[/noparse] I/O Definitions
>']
>
>Electrode1 con 0 ' Make I/O pin 0 an output. >Electrode2 con 1 '
Make I/O pin 1 an output. >Electrode3 con 2 ' Make I/O pin 2 an
output. >Electrode4 con 3 ' Make I/O pin 3 an output. >Electrode5 con
4 ' Make I/O pin 4 an output. >Electrode6 con 5 ' Make I/O pin 5 an
output. >Electrode7 con 6 ' Make I/O pin 6 an output. > >'
[noparse][[/noparse]
Constants >']
--- > >MaxPin CON 6 ' random output = 1 TO MaxPin >OnTime CON 3000
>OffTime CON 1000 >Online CON 2800 >Offline CON 1000 > >'
[noparse][[/noparse]
Variables >']
--- > >rndVal1 VAR Word >rndVal2 VAR Word >target1 VAR Nib >last1 VAR
Nib >last2 VAR Nib > >target2 VAR Nib >target3 VAR Nib > >'
[noparse][[/noparse]
Initialization >']
--- > >Init: > OutL = %01111111 ' P0 - P6 are outputs > >'
[noparse][[/noparse]
Program Code >']
--- > >Main: > RANDOM rndVal1 ' spin random generator > target1 =
rndVal1 // MaxPin + 1 ' create pin value > RANDOM rndVal2 ' spin
random generator > target2 = rndVal2/11555 MIN 1 ' create pin value >
target3 = 7 ' Activate pin 7 to be used as reset > >'****** >
Select_Mpx: > OUT1 = rndVal1.Bit0 'Output bit 0 of rndVal1 to pin 1 >
OUT2 = rndVal1.Bit1 > OUT3 = rndVal1.Bit2 > OUT1 = rndVal2.Bit0 >
OUT2 = rndVal2.Bit1 > OUT3 = rndVal2.Bit3 >'****** > debug? rndval1 >
debug? rndval2 > debug? target1 > debug? target2 > PAUSE 400 > > IF
(target1 = last1) THEN Main ' do again if same as last > last1 =
target1 > > IF (target2 = last2) THEN Main ' do again if same as last
> last2 = target2 > > IF (target1 = target2) THEN Main ' do again if
same as last > > HIGH TARGET3 ' outputs on to ouput + 5v > PAUSE
Online > > HIGH TARGET2 ' outputs on to ouput + 5v > LOW target1 '
outputs off used as ground > PAUSE OnTime 'Keep then on for the
duration of OnTime > > LOW TARGET2 ' outputs off > LOW target1 >
PAUSE OffTime 'Keep then off for the duration of OnTime > LOW TARGET3
> PAUSE Offline > > GOTO Main >
>******************************************** > >Luckily, the Stamp
is very flexible with IO mapping and access. >Here'sa quick, kind
of "brute force" approach to your problem. Not >knowingthe rest of
your program, any more elegant solution I might >suggestcould
interfere with the rest of your project. > > Select_Mpx: > OUT1 =
randVal1.Bit0 >OUT2 = randVal1.Bit1 >OUT3 = randVal1.Bit2 >OUT4 =
randVal2.Bit0 >OUT5 = randVal2.Bit1 >OUT6 = randVal2.Bit2 >RETURN > >-
- Jon Williams >-- Applications Engineer, Parallax-- Dallas Office >
>
Original Message
>From: konpen [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=d0N-MoBN533nU5mdBhFCm0pg99TJvu0SZ4mAGNZv77QXQMXH5LMaApWR4L_0O1D9jn-Fy2dh2A]konpen@y...[/url
Sent: Thursday, November 20, >2003 10:27 AMTo: Jon Williams >Subject:
Basic Stamp programing >Hi, I am writting a program for a Basic stamp
2. I have the program >generating 2 random numbers which I use with a
circuit to select 2 >lines from seven lines and make them high. I am
using a couple of >multiplexers to select the 2 lines from seven
lines. I need the >Basic Stamp to output the two randomly generated
numbers in binary >using pin 1 through pin 6. Meaning if 2 and 3
where selected, I >would want the stamp to output 0 to pin 1 and 3
and 1 to pin 2 (010), >0 to pin 4 and 1 to pin 5 and 6 (011). Can you
help me achive this >please. Thanks. you can email the answer at
jacclem@h... >please. > > > > > >This message has been scanned
by WebShield. Please report SPAM to >abuse@p.... >
Sign In or Register to comment.