PDA

View Full Version : Syntax error - Label is missing ':' ???



alisha
12-01-2009, 10:54 AM
I'm trying to use a BS1 with a DS1302 time keeping chip & crystal. I'm using the demo code from parallax & I've changed the Compiler directives to the BS1 (since it was written for a BS2), but when I try to run it, it gives a Syntax error 174 - Label is missing ':".

Any suggestions? Is this error because the code was written for a BS2?

Mike Green
12-01-2009, 11:05 AM
Yes, the syntax for BS1 programs is a little different from the syntax for BS2 programs. Without your source code, it's hard to tell what your specific problem is. It may be an IF/THEN statement where the syntax is "IF <expression> THEN <label>" rather than "IF <expression> THEN <statement>" used with the BS2.

alisha
12-01-2009, 11:43 AM
Thank you for the help Mike. Here is the top portion of the code I am using. When I get the error message, it highlights the first "PIN" as if it needs a colon after it? I've been trying to find information about this in the Basic Stamp Syntax and Reference manual that came with the BS1, but am unable to find any information about syntax errors and what they may mean.

' ================================================== =======================
'
' File...... DS1302_Demo.bs2
' Purpose... Demonstrate The DS1302 Clock & RAM Functions
' Author.... Chris Savage -- Parallax, Inc.
' E-mail.... csavage@parallax.com
' Started...
' Updated... 10-09-2005
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' ================================================== =======================


' -----[ Program Description ]---------------------------------------------

' This code demonstrates the use of the DS1302 RTC/RAM Chip with the BASIC
' Stamp 2 Microcontroller, making easy use of the 12 Hour & 24 Hour time
' modes, as well as accessing the RAM. The sample code will use the DEBUG
' window for input and output for simplicity. You can change the output
' to the device of your choice. For example, using a Parallax Serial LCD
' requires very few changes to the code to use it for output.
' A modified version of this code was adapted to display the date and time
' on a Parallax Serial LCD Display (#27976), also with backlight (#27977)
' and on Parallax Professional Development Board (#28138, coming soon!)
' using a MAX7219 8-Digit Display Driver.
' This code will work on all BS2 Stamp Modules. You may need to change
' the Baud constant if you're not using a BS2, BS2e or BS2pe.
'
' The Parallax 2 X 16 Serial LCD Displays are availble at the following
' links:
' http://www.parallax.com/detail.asp?product_id=27976
' http://www.parallax.com/detail.asp?product_id=27977
'
' Pin Assignments
' 0 DS1302 DataIO
' 1 DS1302 Clock
' 2 DS1302 Chip Select
' 3 Parallax Serial LCD RX Line


' -----[ Revision History ]------------------------------------------------



' -----[ I/O Definitions ]-------------------------------------------------

DataIO PIN 0 ' DS1302.6
Clock PIN 1 ' DS1302.7
CS1302 PIN 2 ' DS1302.5
LCD PIN 3 ' Parallax Serial LCD Display

Here's the address to the forum where Chris from parallax gave the demo code: http://forums.parallax.com/forums/default.aspx?f=21&m=68522

Mike Green
12-01-2009, 11:58 AM
The PIN statement is one of the incompatibilities between the BS2 and the BS1 syntax. You really need to consult the BASIC Stamp Syntax and Reference Manual for the differences. There's not a summary, but each section of the Manual has an indicator that shows which Stamp models implement which features.

For the BS1, you'd use the SYMBOL declaration. It's not identical to the PIN declaration. It's more like the CON declaration for constants. You can read the description of each declaration in the Manual to sort out the differences.

alisha
12-01-2009, 06:31 PM
Thank you!

JD
12-01-2009, 11:22 PM
Alisha,

There is also a document that might help do with the conversion from BS2 to BS1, here is a link for your convenience.

BS1/BS2 Conversion Document:
http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/BS1nBS2ConvTips.pdf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)

jorge_saldana
10-31-2011, 11:10 AM
Hi there,

I have the same situation, got a basic stamp 1(with the module). The application im truing to program is a gas sensor. Tried to modify the sample made for a bs2 by modifing headings and pin assigments , and got the same error. Let me know if u where able to solve urs.

Thanks,
Jorge

Franklin
10-31-2011, 03:58 PM
Jorge, have you read the links and documents listed above? Post your code if that is what you want help with.

jorge_saldana
10-31-2011, 11:37 PM
[QUOTE}

Jorge, have you read the links and documents listed above? Post your code if that is what you want help with.


[/QUOTE]

Hi , here is the code:

' ================================================== =======================
'
' File...... CO Gas Sensor.bs2
' Purpose... Runs the CO Gas Sensor Module Heater
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Started... 02-09-2009
' Updated...
'
'{$STAMP BS1}
'{$PBASIC 1.0}
'
' ================================================== =======================
' -----[ Program Description ]---------------------------------------------
' This program runs the Gas Sensor Heater through two phases (voltages) as
' recommended by the manufacturer datasheet. The sensor should run for at
' least 10 minutes in clean air before any calibration is done.
' The first phase is the PURGE phase where the heater element is turned on
' at a full 5V. This clears the sensor and no checking for an alarm
' condition is done here. The DEBUG screen will count down the 60 seconds
' of this phase.
' The second phase is the SENSE phase where the heater element is run at
' ~1.4V for 90 seconds. It is during this phase that the sensor can be
' calibrated or that the sensor is checked for alarm conditions.

' -----[ I/O Definitions ]-------------------------------------------------
SET IOS:
hsw VAR BIT ' Heater Switch Control
alr VAR BIT ' Alarm Input Sense

hsw=OUT0
alr=IN1

' -----[ Variables ]-------------------------------------------------------
index VAR Word ' Counter Variable

' -----[ Program Code ]----------------------------------------------------
Main:
DO
LOW hsw ' Turn Heater ON
FOR index = 59 TO 0 ' Count Down 60 Seconds
DEBUG HOME, "PURGE MODE...", DEC2 index, " "
PAUSE 1000 ' 1 Second Pause
NEXT
index = 1710 ' Approximately 90 Seconds
DO ' Of Iterations On BS2
DEBUG HOME, "SENSE MODE...", DEC2 index / 19
LOW hsw ' Turn Heater ON
PAUSE 15 ' For 15 mS
INPUT hsw ' Turn Heater OFF
PAUSE 3 ' For 3 mS
index = index - 1 ' Decrement Counter
IF alr = 1 THEN ' Check For Alarm Condition
DEBUG " ***ALARM***" ' Display Alarm Condition
ELSE
DEBUG " " ' Clear Alarm Condition
ENDIF
LOOP UNTIL index = 0 ' End Of Sense Mode Loop
LOOP

Mike Green
11-01-2011, 01:07 AM
Read the Basic Stamp Syntax and Reference Manual. There is no DO / LOOP statement in PBasic 1.0 nor is there an IF / THEN / ELSEIF / ENDIF. You have to do IF <expression> THEN <label>. Look in the Manual for examples. You can also look in the Basic Stamp Editor's help files. Statements are clearly marked as BS1-only or BS2-only or, in some cases, BS2p-only.

jorge_saldana
11-02-2011, 12:31 AM
Roger,

I'll take a look on that and rewrite it.


Thanks,
Jorge

Tracy Allen
02-20-2012, 06:36 PM
Jorge,
I see you had been trying to start a new thread about powering your CO sensor in the Sensors forum, but it did not stick because it was a copy of what you had posted off topic here. I moved your question and my response to a new thread (http://forums.parallax.com/showthread.php?138087-power-issue.-BS2-to-27931-CO-gas-sensor) there in Sensors.