BS1 version of Do...Loop...?
ppillard
Posts: 22
Hello All! I'm a relative noob, here, so please load up on your patience before you proceed.
So I built a simple remote start relay system for my old truck. I developed it on my trusty BS2 Homework Board, using a Parallax key fob remote. Once I had the code working with some simple LED's to indicate the vehicle was trying to start and I could lock/unlock the doors, I settled in and ordered my relays and such. To minimize power requirements, I opted for a BS1 module. This is the first time I have played with a BS1 at all.
Imagine my disappointment when the BS1 module and development board arrived and I tried to upload my code to it, only to find that the BS1 doesn't support a Do...Loop?!
Surely the BS1 has a version of Do...Loop?
So I built a simple remote start relay system for my old truck. I developed it on my trusty BS2 Homework Board, using a Parallax key fob remote. Once I had the code working with some simple LED's to indicate the vehicle was trying to start and I could lock/unlock the doors, I settled in and ordered my relays and such. To minimize power requirements, I opted for a BS1 module. This is the first time I have played with a BS1 at all.
Imagine my disappointment when the BS1 module and development board arrived and I tried to upload my code to it, only to find that the BS1 doesn't support a Do...Loop?!
Surely the BS1 has a version of Do...Loop?
Comments
"a pseudo LOOP"?.
You could branch to a subroutine based on the status of a flag.
How are you using the DO..LOOP? If it's for nothing more than to create a continuously executing section of code, why not use a GOTO..LABEL?
People frown using the GOTO statement in general, but sometimes "ya gotta do what ya gotta do".
GOTOs are "frowned upon" because it's much easier to write sloppy and hard to understand code using GOTOs than DO / LOOP and other "structured control statements". Pretty much any introductory programming textbook will discuss this.
a:if PIN0=0 then a ' wait until pin 0 goes high
which loops eternally until Pin 0 goes high. A chicken in every pot, a workaround for every situation. The BS-1 is twenty years old, after all, but still plenty useful for many apps.
GOTO is totally BASIC. C64 BASIC had it - and GOSUB.
In C it's seen as an embarrassment, a vestigial carry-over, but it's still available.
You'll have to haunt some C sites.
Proper object-oriented programming should do without. If you can't manage, someone will show you how (if you ask the right way.)
GOTO is indispensable to the BS1 (BASIC) paradigm.
Picaxe. Busted!
Older texts such as Industrial Control had code in this form as well as older versions of other Stamps-in-class texts. Too bad these aren't on the Parallax website anymore because they are great for reference.
On another note, Assembly Language makes extensive use of the Jump instruction which is similar to GOTO in BASIC. BASIC uses what is called Direct addressing where the program jumps directly to the new location. Assembly also has indexed and indirect addressing and some chips even have an Index register that used for accessing memory.
Look at Propeller Assembly code and you will JMP (Jump) used quite frequently.
OUCH! Please let us not disparage old.
My goose gun is older than I am but it still puts what I aim at on the table. My Pfluger reel is just as old and it still puts snapper and grouper on the table.
The reason I am using BS2s is that I needed more I/O pins and faster speed for my current project.
As for humans... getting old ain't for sissies.
Tim
(As old as my hair and slightly older than my teeth.)
Thanks for the good data, guys! She's up and running.
BTW, the BS1 is still perfect for many projects. Just enough power & pins, and well-documented simplicity. That BS1-IC is tiny and tucks in anywhere. I wish I would have stockpiled (OK, hoarded) more BS1 project boards back when they were $14.99. Twice that now!
http://www.parallax.com/product/27112