Shop OBEX P1 Docs P2 Docs Learn Events
Problem with src file? — Parallax Forums

Problem with src file?

Shawn LoweShawn Lowe Posts: 635
edited 2008-08-20 19:09 in General Discussion
Hello!

Well, Im still working on my kegerator code, and after compiling my code and finding several rookie mistakes, the program finally compiles. However,it brings up the src program (I am not sure why) and displays a "symbol <__else1> is not defined. I am uncertain as to why it is saying this, as I have my SX_Key set up to work in SXB.

Can anyone educate me? I would be thankful. ( I am using the BETA key, if that helps)

Thanks
' =========================================================================
'
'   File...... ADC0831_Working_File.SXB
'   Purpose... Tempurature controller for homebrew kegs
'   Author....  
'   E-mail....  
'   Started...
'   Updated...
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'
' Reads value from an ADC0831 
' Note that the SpeedMult feature is used with SHIFTIN to bump the clock
' speed up to ~332 kBits/sec (ADC0831 max is 400).

' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------

DEVICE   SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ   4_000_000
ID   "beercool"

' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------

Cpin   PIN  RA.2 OUTPUT  ' shift clock
Dpin   PIN  RA.1 INPUT  ' shift data
CS   PIN  RA.0 OUTPUT  ' chip select

TX  PIN RB.1 OUTPUT  ' transmit to PC / Stampplot
RC4   PIN  RB.0 OUTPUT  ' transmit to RC4

' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------

temperature VAR Byte   ' main variable
tmpB1   VAR  Byte    ' working variables
tmpB2           VAR     Byte
tmpW1  VAR Word

' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------

IsOn            CON     1
IsOff           CON     0
App_Mod_On CON %1000   ' not currently used
App_Mod_Off CON %0000
BaudMode        CON     "OT38400"

' =========================================================================
 PROGRAM Start
' =========================================================================

' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------

DELAY_MS        SUB     1, 2                    ' delay in milliseconds
TX_BYTE         SUB     1                       ' transmit a byte
TX_STR          SUB     2                       ' transmit a string
RESET_RC4       SUB     0                       ' reset the RC-4
SET_RC4         SUB     1                       ' set RC-4 relays
Get_ADC  SUB     0,1   ' get adc reading

' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------

Start:

  DELAY_MS 250                                  ' let RC-4 power up
  RESET_RC4

  HIGH CS      ' make CS output, no ADC
  LOW Cpin      ' make clock 0-1-0

Main:
  
  temperature = Get_ADC
    
  watch temperature

  If temperature >= 38 then
 SET_RC4  %1000
 
  If temperature <= 34 then
 SET_RC4  %0000

  DELAY_MS 250
  BREAK

GOTO Main





' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------

' Use: aVar = GET_ADC
' -- reads ADC0831 and places value into 'tmprtr'

FUNC Get_ADC
  CS = 0      ' activate ADC0831
  SHIFTIN Dpin, Cpin, MSBPOST, tmpB1\1, 4  ' start conversion
  SHIFTIN Dpin, Cpin, MSBPOST, tmpB1, 4  ' shift in the data
  CS = 1      ' deactivate ADC0831
  RETURN tmpB1
ENDFUNC

' -------------------------------------------------------------------------

' Use: DELAY_MS duration
' -- replaces PAUSE

SUB DELAY_MS
  IF __PARAMCNT = 1 THEN
    tmpW1 = __PARAM1
  ELSE
    tmpW1 = __WPARAM12
  ENDIF
  PAUSE tmpW1
  ENDSUB

' -------------------------------------------------------------------------

' Use: TX_BYTE byteVal
' -- transmit "byteVal" at "BaudMode" on pin "Sio"

SUB TX_BYTE
  SEROUT RC4, BaudMode, __PARAM1
  ENDSUB

' -------------------------------------------------------------------------

' Use: TX_STR [noparse][[/noparse]string | label]
' -- "string" is an embedded string constant
' -- "label" is DATA statement label for stored z-String

SUB TX_STR
  tmpW1 = __WPARAM12                            ' get address of string
  DO
    READINC tmpW1, tmpB1                        ' read a character
    IF tmpB1 = 0 THEN EXIT                      ' if 0, string complete
    TX_BYTE tmpB1                               ' send character
  LOOP
  ENDSUB

' -------------------------------------------------------------------------

' Use: RESET_RC4

SUB RESET_RC4
  TX_STR  "!!!!!!RC4"                           ' header (ensure sync)
  TX_BYTE %00                                   ' address
  TX_BYTE "X"                                   ' reset command
  ENDSUB

' -------------------------------------------------------------------------

' Use: SET_RC4 relayBits

SUB SET_RC4
  tmpB2 = __PARAM1                              ' get relay bits
  TX_STR  "!RC4"                                ' header
  TX_BYTE %00                                   ' address
  TX_BYTE "S"                                   ' set command
  TX_BYTE tmpB2                                 ' relay bits
  ENDSUB



P.s. I could not locate my file to upload. I can only find it using the SX_key. I think I saw this problem on another post? Any clues?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe


When all else fails.....procrastinate!

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-19 05:24
    Shawn,

    You need to add ENDIFs after the SET_RC4 commands -- like this:

    IF temperature >= 38 THEN
      SET_RC4  %1000
    [color=#990000]ENDIF[/color]
     
    IF temperature <= 34 THEN
     SET_RC4  %0000
    [color=#990000]ENDIF[/color]
    
  • PJMontyPJMonty Posts: 983
    edited 2008-08-19 06:38
    Shawn,

    I'm not sure what you mean when you say you couldn't locate the file to upload and could only find it with the SX-Key. What file? The src file?

    Thanks,
    PeterM
  • Shawn LoweShawn Lowe Posts: 635
    edited 2008-08-19 12:43
    JonnyMac-
    DOH! Thank you. I will try that.

    PJMonty-
    I saved my file in the Beta key, then tried to upload the file using parallax's upload file button. The file did not show up when I went to the correct file location. So I exited out of the SX-Key, and tried to find the file using the upload button again. I could not find it. So I restarted the SX-Key, went to the projects-->sxb folder and there was the file. It opened just fine. The file is a SXB file. It is like the only program that can see the file is the sx-key. Hope that clarifies.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!

    Post Edited (Shawn Lowe) : 8/19/2008 9:02:29 PM GMT
  • Shawn LoweShawn Lowe Posts: 635
    edited 2008-08-19 21:06
    Jon-
    When I got home I put in the Endif's. It compiled right away! Thanks for answering what must have seemed like an obvious programming error! Everyone new should hopefully learn from this post.

    Bean-
    Can something be added to the help file of sxb 2.0 about endif with if...then's? Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-19 21:16
    That's in the Help file now. The only time you can leave out the ENDIF is when you're using a Label to jump to and the label at the end of the IF..THEN construct.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2008-08-20 10:44
    Jon/Bean-


    IF Condition [noparse][b]GOTO[/b [noparse][b]EXIT[/b

    Function
    Evaluate Condition and, if it is true, jump to the point in the program designated by Label.
    • Condition· is a simple statement, such as "x = 7" that can be evaluated as True or False.
    • Label· specifies where to go in the event that Condition statement evaluates as True.

    Explanation
    IF...THEN is decision maker that affects program flow. It tests a Condition statement and, if that statement is True, goes to a point in the program specified by Label. The available comparison operators are:

    attachment.php?attachmentid=73942

    Comparisons are always written in the form: Variable Op Value.
    • Variable· is a bit, byte or word variable.
    • Op· is the comparison operator.
    • Value· is a variable or constant for comparison.


    Main:··IF StartBtn = 1 THEN Main ' wait for input to go lowCheck_Mode:··IF ModePin = 0 GOTO Show_AMPM ' use HH:MM xM format if mode = 0

    Some programmers may prefer a more verbose style; the following syntax is also supported:

    Check_Mode:··IF ModePin = 0 THEN GOTO Show_AMPM ' use HH:MM xM format if mode = 0·This is what is in my online help file. Perhaps I have an outdated copy?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
    328 x 230 - 5K
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-20 15:00
    You absolutely do -- there's a second section having to do with IF-THEN-ELSE-ENDIF syntax. You can get the latest help file from the stick post at the top of the forum.

    http://forums.parallax.com/showthread.php?p=597707
  • Shawn LoweShawn Lowe Posts: 635
    edited 2008-08-20 15:50
    OOOhhhh! Okay, I see now! I had read the section on If/then/else I thought the endif ONLY had to do with the else function. So, yah, it makes sense now! Thanks Jon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-20 19:09
    Yep, if you look closely at the syntax diagram ELSE is optional ( indicated by { } ) -- ENDIF is not. Parallax has asked me to redo the help file (I'll get started shortly) so I'll add a few more examples to make sure that the options are abundantly clear.
Sign In or Register to comment.