Shop OBEX P1 Docs P2 Docs Learn Events
SCi-BOX project — Parallax Forums

SCi-BOX project

JoNIKaHJoNIKaH Posts: 12
edited 2008-05-22 01:18 in BASIC Stamp
Hey guys,
I need some help with a SCi-BOX project. Basically for the last two days I have been trying to learn PBASIC and right now my I have a total mess.
I have SCi-BOX, two ZX-Switches, a thermistor and the LCD display.
What I want to do is something similar to air conditioning. I will later use a motor with a fan to rise the temperature or decrease it.
First of all I have no ideea how to use the LCD to output variables.
I have to declare a minim temperature (ex. 10 degrees Celsius) by pressing a switch that will modify the given (0 degrees celsius) default starting temperature on the LCD, by one degree, and then pressing the other switch (as an ENTER) so I can move to declaring the maximum temperature starting from the minim temperature value. (ex. 20 degrees celsius).
After this the thermistos should check the room temperature at any given interval and if the temperature is higher than the maximum temp declared by my , it should display COOLING on the LCD and start the fan. The same thing with HEATING, by rotating the motor in the oposite way.
I`m afraid that if I`ll compile another code and it gets out wrong my computer will explode. [noparse]:([/noparse]
So please if you have some hints, or anything that can help me I would apreciate it SO MUCH.
Thank you and have a good day! [noparse]:)[/noparse]

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-05-18 14:47
    Not a lot of information on just what you are using for hardware. Could you post links to the parts? I Googled the SCi-BOX but only got that it has a BS2sx module.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • P!-RoP!-Ro Posts: 1,189
    edited 2008-05-18 15:40
    Try using the download section. There are plenty of examples and info for programming. In the stamps in class section there is info on how to use the lcd. Be careful though, the info there is made for the BS2, so some things might change in the programming.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Pi Guy
  • JoNIKaHJoNIKaH Posts: 12
    edited 2008-05-18 15:44
    I am using this :

    Stepper motor driver
    SCi-BOX can drive uni-polar stepper motor 12V 500mA maximum 2 channels by using
    P14 and P15 of i-Stamp. The heart of this circuit is Stepper motor Co-processor. It receives
    serial data from P14 of i-Stamp. Thus, call this pin as SERIN. After that this processor will
    pprocess data and send signal to drive the stepper motor.
    During the STepper motor Co-processor working in process, it sends signal back to i-
    Stamp at P15 for informing in-process not cannot get any data from i-Stamp. Call this pin as
    BUSY.
    Baudrate of this interface is 9,600 bit per second. Data is 8 bits and none parity.
    Everytime i-Stamp send data to porcessor, it will send BUSY siganl in logic “0” back to i-
    Stamp. i-Stamp will polling until BUSY line set to high. It can send the new data following.


    Stepper motor basic
    Stepper motors differ from standard DC motors in that they do not spin freely when
    power is applied. For a stepper motor to rotate, the power source must be continuously
    pulsed in specific patterns. The step sequence (pattern) determines the direction of the
    stepper’s rotation. The time between sequence steps determines the rotational speed.
    Each step causes the stepper motor to rotate a fixed angular increment. The stepper
    motor supplied with SCi-BOX kit rotates 7.5 degrees per step. This means that one full
    rotation (360 degrees) of the stepper requires 48 steps.

    And the images attached.


    But I don`t know how to program it correctly. And the time .... way to less time on my hands [noparse]:([/noparse]
    1535 x 1643 - 406K
    1061 x 557 - 69K
    1033 x 673 - 103K
  • JoNIKaHJoNIKaH Posts: 12
    edited 2008-05-18 15:47
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-05-18 16:03
    Hi, your best approach would be to break the project down into smaller pieces. Use the documentation that comes with your display to learn how to send characters and strings to the LCD. Learn how to read temperature input from your sensors and display them on the debug screen in a meaningful way. The fan will need some kind of controller for forward and reverse, select a motor that suits your needs find a controller and learn what signals are required to turn it on and off and how to switch direction. A small menu might be needed for adjusting the temperature setpoints, try to program a menu that you can scroll through using button input to alter the setpoints.

    When you have each piece working put each in its own subroutine, that will give the program a modular look that is easier to modify or troubleshoot.

    It may sound daunting but the Parallax sight has many examples of everything I have mentioned, code and hardware etc.

    If you give each piece a shot and have difficulty post further questions here. Dealing with a small piece with a specific problem will be easier to answer and you will progress/learn much quicker. Start by using the PBasic IDE help files and learn how to create and use a subroutine.

    hope this helps

    Jeff T.
  • JoNIKaHJoNIKaH Posts: 12
    edited 2008-05-18 19:01
    Well, it seems I`m retarded cause I just cannot figure out this basic thing. I mean i read and read tutorials the whole day, but still can`t figure a lot of things out, and the main one would be understanding its way of thinking.
    I have no idea how to create a menu or anything like that.
    If there is anyone that knows some tutorials for DUMMIES please post some links here.
    Thank you.
  • JoNIKaHJoNIKaH Posts: 12
    edited 2008-05-18 19:23
    Is there anyone interested in tutoring me for a few minutes online ?
    About this : http://www.inexglobal.com/products.php?type=SCIENCE&cat=SCIENCE&model=SCIBOX
    uses BASIC Stamp2SX
    All I need is someone to explain how this whole thing works in declaring variables and stuff.

    My sensor reads a temperature and displays it on the LCD, but that`s just a 3 digit number . How do I find out what that number means and how can I convert it to Celsius ?
    Because I want to declare a variable (I think its a variable) like temperature. And I want it to show 0 and then to modify its value on the display by pressing a button. And after that I want the last value I set for the temperature to be stored when I press another number. So I can go to setting up the next temperature value.
    What does the LCD cursor have to do with this ?
    I mean, do I have to declare something fix like TEMPERATURE and then something I can modify like a number ?
    Or can I modify the whole line that is shown on the LCD ? Like MINIMUM TEMPERATURE = 0 degrees,MINIMUM TEMPERATURE = 1 degrees etc.

    Right now I am so lost ... [noparse]:([/noparse]
  • FranklinFranklin Posts: 4,747
    edited 2008-05-18 20:39
    Could you attach your code to your next post so we can see where you are?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • JoNIKaHJoNIKaH Posts: 12
    edited 2008-05-20 09:32
    Ok, so here it is , the code i`ve been working for 2 days. I got stuck at this piece cause it just doesn`t work and i tried to apply as much logic as I could but the problem is that it just doesn`t show me what I need!
    I have a 2x16 LCD display and I need to
    a)Define a minimum Temperature. Tmin
    b)Press another switch so I can jump to another Temperature. Tmax
    c)Define Tmax
    d) Display on the first row : Tmin = , and on the second row Tmax

    '{$STAMP BS2sx}
    '{$PBASIC 2.5}
    BAUD  CON  240
    CMD  CON  $FE
    SLCD PIN  7
    SWITCH1 PIN 0
    SWITCH2 PIN 1
    SD  PIN 13
    Tmin VAR Word
    Tmax VAR Word
    
    
    PAUSE  1000
    SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
    
       DEBUG "Tmin= ",DEC5 Tmin,HOME ' Show data read
    
      SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,2]    ' Cursor home
      Tmin=5
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C"]
    
    
      DO
     'Reglare Tmin'
     DO
        IF SWITCH1=1 THEN
       DO UNTIL SWITCH1=0
       LOOP
      ELSE
       DO UNTIL SWITCH1=1
       LOOP
      ENDIF
    
      IF SWITCH1=1 THEN
       DO UNTIL SWITCH1=1
       LOOP
      ELSE
       DO UNTIL SWITCH1=0
       LOOP
      ENDIF
    
       Tmin=Tmin+1
       SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C"]
       PAUSE 250
    
      IF (SWITCH2=1) THEN EXIT
        LOOP
    
        'Reglare Tmax'
        Tmax=Tmin
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C          ",CR,"Tmax = ",DEC2 Tmax, " gr.C"]
    
     DO
        IF SWITCH1=1 THEN
       DO UNTIL SWITCH1=0
       LOOP
      ELSE
       DO UNTIL SWITCH1=1
       LOOP
      ENDIF
    
      IF SWITCH1=1 THEN
       DO UNTIL SWITCH1=1
       LOOP
      ELSE
       DO UNTIL SWITCH1=0
       LOOP
      ENDIF
       Tmax=Tmax+1
       SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C          ",CR,"Tmax = ",DEC2 Tmax, " gr.C"]
       PAUSE 250
    
      IF (SWITCH2=1) THEN EXIT
        LOOP
        LOOP
    
    



    No. 2
    '{$STAMP BS2sx}
    '{$PBASIC 2.5}
    BAUD  CON  240
    CMD  CON  $FE
    SLCD PIN  7
    SWITCH1 PIN 0
    SWITCH2 PIN 1
    SWITCH3 PIN 2
    SD  PIN 13
    Tmin VAR Word
    Tmax VAR Word
    
    
    PAUSE  1000
    SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
    
       DEBUG "Tmin= ",DEC5 Tmin,HOME ' Show data read
    
      SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,2]    ' Cursor home
      Tmin=5
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C"]
    
     DO
    
     'Reglare Tmin'
     DO
        IF SWITCH1=1 THEN
             Tmin=Tmin+1
              PAUSE 250
              SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
              SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C"]
              PAUSE 250
        ENDIF
        IF (SWITCH3=1) THEN EXIT
     LOOP
        'Reglare Tmax'
    
               Tmax=Tmin
               SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmax = ",DEC2 Tmax, " gr.C"]
      DO
    
        IF SWITCH2=1 THEN
    
              Tmax=Tmax+1
              PAUSE 250
              SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
    
               SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmax = ",DEC2 Tmax, " gr.C"]
              PAUSE 250
       ENDIF
       IF (SWITCH3=1) THEN EXIT
      LOOP
    
      LOOP
    
    



    Please HELP ?!
  • JoNIKaHJoNIKaH Posts: 12
    edited 2008-05-21 12:46
    Well I`m back with the right code. I took it again this morning, did it all over again and managed to make it display what I need. Had to trick it in some parts but anyway, I get my result.
    But I have another problem. My temperature sensor reads something and when it displays it , I just see a 3 digit number like 250 or something that grows with the temperature or decreases. My problem is that I don`t know how can I convert that to Celsius without knowing what it means. I have no way right now of making sure that my sensor records 2 different and exact temperatures to make up a rule of transformation. So if there is anyone that can help me with this, please don`t be shy ... Lol. [noparse]:)[/noparse]
    Anyway here`s the right code :

    '{$STAMP BS2sx}
    '{$PBASIC 2.5}
    BAUD  CON  240
    CMD  CON  $FE
    SLCD PIN  7
    SWITCH1 PIN 0
    SWITCH2 PIN 1
    SWITCH3 PIN 2
    SD  PIN 13
    Tmin VAR Word
    Tmax VAR Word
    
    
    PAUSE  1000
    SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
    
    
      SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,2]    ' Cursor home
      Tmin=0
      Tmax=Tmin
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C          ","                Tmax = ",DEC2 Tmax, " gr.C"]
    
    
    
     'Reglare Tmin si Tmax'
     DO
        IF SWITCH1=1     THEN
        Tmin=Tmin+1
        Tmax=Tmin
        PAUSE 250
        SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
        SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,2]
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C          ","                Tmax = ",DEC2 Tmax, " gr.C"]
    
        ELSEIF SWITCH2=1 THEN
        Tmax=Tmax+1
    
        PAUSE 250
        SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,1]
        SEROUT SLCD,BAUD,[noparse][[/noparse]CMD,2]
      SEROUT SLCD,BAUD,[noparse][[/noparse]"Tmin = ",DEC2 Tmin," gr.C          ","                Tmax = ",DEC2 Tmax, " gr.C"]
        ENDIF
        IF (SWITCH3=1) THEN EXIT
      LOOP
    
    
    
    
  • FranklinFranklin Posts: 4,747
    edited 2008-05-22 01:18
    The temperature sensor is a variable resistor and is probably being read with an ADC circuit and converted to a number. You need to find out what the conversion factor is and what the number is for several key temperatures (like freezing and boiling) so you can then convert to Deg F. The data sheet or the documentation that came with the Scibox may give you that info.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.