ask for a help to read the clapper syntax
thetarbre
Posts: 3
Hello. I just started learning basicStamps a month ago and this clap detection is my first project at architectural school where there are no electrical
engineering students around me. We start using sensors and microcontrollers to come up with kinetic architecture that responds to different input. My professor suggested using a Basic Stamp2. I need some help with programming for this clapper since i am running out of sources and time...Any help would be greatly appreciated.... thank you very much.
For a learning purpose, the circuit and code I am now working on are basically borrowed from http://www.stampsinclass.com/dl/docs/article/UCalgaryStampInvestigationk-12.pdf.
The code had errors in couple places with my BasicStamp2.5 chip since it seems it is written in PBasic 1. So my next step is to convert this to Pcasic2.
I tried reading a "BS syntax manual" to start converting it_as I shown at the declaration of variables with ''_ but I found no way to figure some parts out...
especially I really couldn't understand what "pot" means in the line of "pot pcellpin,scale,B2".
If anyone could help me in reading this code, I would really appreciate it. Thank you, again.
[noparse][[/noparse]code]
'This program will monitor the sound falling on a microphone,
'toggling a number of lights whenever a very loud sound is heard.
symbol pcell = pin0 '#DEFINE pcell = pin0 //I hope those are the right conversion
symbol pcellpin = 0 '#DEFINE pcellpin =0
symbol light1 = pin1 '#DEFINE light1 = pin1
symbol light2 = pin2 '#DEFINE light2 = pin2
symbol light3 = pin3 '#DEFINE light3 = pin3
symbol scale = 200 '#DEFINE scale = 200
OUTPUT 1
OUTPUT 2
OUTPUT 3
read_pcell:
pot pcellpin,scale,B2 'What "pot" means? or what can be an alternative idea to here?
DEBUG B2
GOTO read_pcell
is_light1_on:
IF B2>200 THEN light1_on
light1_off:
light1=0
GOTO is_light2_on
light1_on:
light1=1
is_light2_on:
IF B2>100 THEN light2_on
light2_off:
light2=0
GOTO is_light3_on
light2_on:
light2=1
is_light3_on:
IF B2>40 THEN light3_on
light3_off:
light3=0
GOTO is_light4_on
light3_on:
light3=1
is_light4_on:
GOTO read_pcell
Post Edited (thetarbre) : 10/22/2007 6:16:39 AM GMT
engineering students around me. We start using sensors and microcontrollers to come up with kinetic architecture that responds to different input. My professor suggested using a Basic Stamp2. I need some help with programming for this clapper since i am running out of sources and time...Any help would be greatly appreciated.... thank you very much.
For a learning purpose, the circuit and code I am now working on are basically borrowed from http://www.stampsinclass.com/dl/docs/article/UCalgaryStampInvestigationk-12.pdf.
The code had errors in couple places with my BasicStamp2.5 chip since it seems it is written in PBasic 1. So my next step is to convert this to Pcasic2.
I tried reading a "BS syntax manual" to start converting it_as I shown at the declaration of variables with ''_ but I found no way to figure some parts out...
especially I really couldn't understand what "pot" means in the line of "pot pcellpin,scale,B2".
If anyone could help me in reading this code, I would really appreciate it. Thank you, again.
[noparse][[/noparse]code]
'This program will monitor the sound falling on a microphone,
'toggling a number of lights whenever a very loud sound is heard.
symbol pcell = pin0 '#DEFINE pcell = pin0 //I hope those are the right conversion
symbol pcellpin = 0 '#DEFINE pcellpin =0
symbol light1 = pin1 '#DEFINE light1 = pin1
symbol light2 = pin2 '#DEFINE light2 = pin2
symbol light3 = pin3 '#DEFINE light3 = pin3
symbol scale = 200 '#DEFINE scale = 200
OUTPUT 1
OUTPUT 2
OUTPUT 3
read_pcell:
pot pcellpin,scale,B2 'What "pot" means? or what can be an alternative idea to here?
DEBUG B2
GOTO read_pcell
is_light1_on:
IF B2>200 THEN light1_on
light1_off:
light1=0
GOTO is_light2_on
light1_on:
light1=1
is_light2_on:
IF B2>100 THEN light2_on
light2_off:
light2=0
GOTO is_light3_on
light2_on:
light2=1
is_light3_on:
IF B2>40 THEN light3_on
light3_off:
light3=0
GOTO is_light4_on
light3_on:
light3=1
is_light4_on:
GOTO read_pcell
Post Edited (thetarbre) : 10/22/2007 6:16:39 AM GMT
Comments
The following should get you started:
[noparse][[/noparse]code]
'Add appropriate PBASIC compiler directives below here:
'This program will monitor the sound falling on a microphone,
'toggling a number of lights whenever a very loud sound is heard.
pcell = pin0·'#DEFINE pcell = pin0··//I hope those are the right conversion
pcellpin = 0········ '#DEFINE pcellpin =0
light1 = pin1······· '#DEFINE light1 = pin1
light2 = pin2······· '#DEFINE light2 = pin2
light3 = pin3······· '#DEFINE light3 = pin3
scale = 200········ '#DEFINE scale = 200
OUTPUT 1
OUTPUT 2
OUTPUT 3
read_pcell:
'pot pcellpin,scale,B2··········· 'What "pot" means? or what can be an alternative idea to here?
'Replace POT with RCTIME. The external circuitry may need to change as well.
DEBUG B2 '<== Replace B2 with output variable name·from RCTIME instruction
GOTO read_pcell
is_light1_on:
IF B2>200 THEN light1_on·· '<== See above regarding B2
light1_off:
light1=0
GOTO is_light2_on
light1_on:
light1=1
is_light2_on:
IF B2>100 THEN light2_on·· '<== See above regarding B2
light2_off:
light2=0
GOTO is_light3_on
light2_on:
light2=1
is_light3_on:
IF B2>40 THEN light3_on··· '<== See above regarding B2
light3_off:
light3=0
GOTO is_light4_on
light3_on:
light3=1
is_light4_on:
GOTO read_pcell
Regards,
Bruce Bates
This code finally has no compile errors but the circuit is not yet responding yet. I mean sounds haven't activated the LEDs yet.
Is it still possible for me to ask you what makes this unsuccessful?
I attached the jpeg of my circuit for this, too.
It seems the circuit is right but I feel like I don't really understand the setting of RCTime as the source of On-off.
I hope what I write makes sense to you and wish you would help me out of this.
Again, thank you very much.
thetarbre
Post Edited (thetarbre) : 10/23/2007 7:54:52 AM GMT
I didn't view the original program to try to determine what it did, nor even if it would work. My only thrust was to help you convert a BS-1 Stamp program to BS-2 format.
However, the following (extracted form the present progam) will never execute anything other than the instructions contained therein:
read_pcell:
RCTIME 0,1, time
DEBUG DEC time, CR
GOTO read_pcell
Thus, you will never get to any other part of this program. I suspect some decision (i.e. IF statement) must be made as to when an exit should be made, and if one should NOT be made, ONLY THEN would one want to return to "read_pcell".
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 10/23/2007 4:47:22 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
We will try this again soon.
thetarbre