Shop OBEX P1 Docs P2 Docs Learn Events
Sx Proto Board Project ......Newbe — Parallax Forums

Sx Proto Board Project ......Newbe

Little_Part_ManLittle_Part_Man Posts: 8
edited 2007-09-15 21:40 in General Discussion
Hi, EveryOne

I am new to this Forum

I have Play with the Basic Stamp·for a few years·but not with SX Chip

I have look at the online stuff that you have for the SX

I bought a few of these
·http://www.parallax.com/detail.asp?product_id=45302

I have project that all i need to is.....>>>>>>

Look at an input if it = 1

Turn on output1 ON

Then have timer cout for a minute

Then turn output2 ON

When input = 0

Then ·have output2 Turn OFF


Then have timer count for a minute

Then turn output1 turn OFF

Then Repeat·

Now i read that this chip has timer on the chip

I would like to know how write this routine

Now i could use a Basic Stamp for this and know how to write this

I· thought that this was an easy route to learn how to use a SX
·
Please let me know in i am wrong in this idea
But i would like to learn something more about a different chip


Is there any one that can help with this Thanks ahead a time for your time

Stefan




▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Thanks For all and Help that You Can Give so that i can how to write SX code


······································· Stefan

Post Edited (Little_Part_Man) : 9/13/2007 5:35:44 PM GMT

Comments

  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-09-13 17:33
    If you can do this on the BASIC Stamp then it is easy to port to SX/B. There is no timer in the SX28 -- you have to do it with delays (very easy).
  • Little_Part_ManLittle_Part_Man Posts: 8
    edited 2007-09-15 01:18
    ·JonnyMac

    Thanks for your reply·I am· sorrry·I did reply sooner

    I made a mistake when i bought these SX28 instead SX48 that ok i will find a use for them

    But i would like to learn how to write this Assemble
    Code

    ·http://www.parallax.com/detail.asp?product_id=45300

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·Thanks For all and Help that You Can Give so that i can how to write SX code


    ······································· Stefan

    Post Edited (Little_Part_Man) : 9/15/2007 4:05:17 AM GMT
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-09-15 02:07
    Why don't you just post your PBASIC code -- any one of us can show you how to translate it to SX/B.
  • Little_Part_ManLittle_Part_Man Posts: 8
    edited 2007-09-15 03:59
    JonnyMac

    Thank You for your reply

    Here is the Basic Stamp Code that i will use·this is·only·part of what i have now

    But i would like to learn how to write this Assemble Code

    I will be buying the SX48 Proto boards
    Now i know that·this chip has a timer and i would like to learn how to use this as well

    Thanks for your help ahead of time··· lol.gif



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·Thanks For all and Help that You Can Give so that i can how to write SX code


    ······································· Stefan

    Post Edited (Little_Part_Man) : 9/15/2007 4:25:22 AM GMT
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-09-15 13:22
    That program is easy to translate to SX/B (which is compiled to assembly) -- see attached. Note that I think you have logic errors: you turn on the power relay LED but never turn it off; you turn off the con relay LED but it was never turned on (these are easy to fix).

    I've written several articles for Nuts & Volts on SX/B; you might want to go back and read them, as well as the help file that is included. One way to learn assembly is to write a program in SX/B and then look at the compiled output; I've learned a lot this way and when I need assembly in a program I usually start with SX/B, compile it, then take the assembly output and hand-optimize it to suit my needs.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-09-15 14:38
    '
    '   File...... Test Code
    '   Purpose... Change to SX Code
    '   Author.... Stefan
    '   E-mail....  N/A
    '   Started... 9-14-2007
    '   Updated...
    '
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    ' -----[noparse][[/noparse] Program Description ]---------------------------------------------
    '
    ' To set up the demo,
    ' connect a 10k resistor from +5V to P7 on the BASIC Stamp. The resistor
    ' to +5V puts a high (1) on the pin when it's an input and low (0)
    '
    '
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    '
    Power_relay            PIN         15
    Power_relay_led        PIN         14
    Con_relay              PIN         13
    Con_relay_led          PIN         12
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    Timer                  CON          60000
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
    setup: INPUT 1
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
    Main:
     IF IN=0 THEN
      GOTO MAIN
     ELSE
     IF IN1 = 1
      HIGH Power_relay
      HIGH Power_relay_led
      PAUSE Timer
      HIGH Con_relay
      HIGH Con_relay_led
     ENDIF
    BUTTON_OFF:
     IF IN=1 THEN GOTO BUTTON_OFF
      LOW Con_relay
      LOW Con_relay_led
      PAUSE Timer
      LOW Power_relay
      LOW Power_relay_led
      
      ENDIF
    
     
    

    I think this is what your trying to do. when you get a trigger you turn on your power relay and its led, wait 60 secs, then turn on your con relay. After the trigger is released you turn off your con relay and its led, wait 60 secs, then turn off your power relay.

    Hope I helped, I'm just trying to get better at programming myself

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


    Maybe I should have waited to do that......
  • Little_Part_ManLittle_Part_Man Posts: 8
    edited 2007-09-15 16:40
    Shawn

    BUTTON_OFF:
    ·IF IN=1 THEN GOTO BUTTON_OFF
    · LOW Con_relay
    · LOW Con_relay_led
    · PAUSE Timer
    · LOW Power_relay
    · LOW Power_relay_led


    Thank You for your reply

    What i want to do is have the INPUT control the two relays by input status only

    That is when·INPUT has power then Start Power ON routine then when power is OFF on the INPUT then Start The OFF Routine

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·Thanks For all and Help that You Can Give so that i can how to write SX code


    ······································· Stefan
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-09-15 17:31
    As far as I can see, if you add an goto main line at the end of the program I posted, it should do exactly what you want.

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


    Maybe I should have waited to do that......
  • Little_Part_ManLittle_Part_Man Posts: 8
    edited 2007-09-15 19:22
    Shawn

    Thank You for your reply and help

    I do not think that you understand what i am trying to do here

    When the INPUT see 5 Volts then want to have this routine run

    ··IF IN1 = 1
    · HIGH Power_relay
    · HIGH Power_relay_led
    · PAUSE Timer
    · HIGH Con_relay
    · HIGH Con_relay_led

    When the INPUT see·0 Volts then want to have this routine run

    IF IN = 0 · LOW Con_relay
    · LOW Con_relay_led
    · PAUSE Timer
    · LOW Power_relay
    · LOW Power_relay_led


    ·I hope that now you can understand what i want to here with these routines

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·Thanks For all and Help that You Can Give so that i can how to write SX code


    ······································· Stefan

    Post Edited (Little_Part_Man) : 9/15/2007 9:39:02 PM GMT
  • Little_Part_ManLittle_Part_Man Posts: 8
    edited 2007-09-15 21:40
    JonnyMac


    Thank You· for your reply

    I have some studying to do and a lot to read and understand and it will take some time for all this sense's
    to me· and for me to understand all of it

    Can you help me understand some thing here that are in blue


    DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX, BOR42 How do you know·where and when to use this
    FREQ··········· 4_000_000
    ID············· "Stefan"

    DELAY_MS·SUB·1, 2···' delay in milliseconds· What is this do, Is this for sub routine

    Start:
    · PLP_C = %11110000····' pull-ups on unused pins Do you need to tie all unused pins to vdd
    · PLP_B = %00000001
    · PLP_A = %0000·········· What is this setting

    '
    ' Subroutine / Function Code
    '

    tmpB1··VAR·Byte··· Am i right that this var for the sub routines
    tmpB2··VAR·Byte
    tmpW1··VAR·Word

    ' Use: DELAY_MS ms
    ' -- delays program in milliseconds
    SUB DELAY_MS
    · IF __PARAMCNT = 1 THEN······ What dose do and what is it for
    ··· tmpW1 = __PARAM1··························· ' save byte value What saved byte value
    · ELSE
    ··· tmpW1 = __WPARAM12························· ' save word value· What saved·word value

    · ENDIF
    · PAUSE tmpW1
    · ENDSUB

    Thank You for all of your help and time in helping learn the SX Code

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·Thanks For all and Help that You Can Give so that i can how to write SX code


    ······································· Stefan

    Post Edited (Little_Part_Man) : 9/15/2007 10:19:38 PM GMT
Sign In or Register to comment.