Announcement

Collapse
No announcement yet.

BASIC Stamp question

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • BASIC Stamp question

    Does anyone know if the stamp can interface with the computer while running, or only while being programmed?

    I know the Stamp 2p has 2 pins dedicated to serial I/O, but are those only used during programing or all the time? Basically, I want to be able to have control of my relays/sensors/components without having to wait for my PC to boot, so I'm using the stamp to control them. But once the PC boots, I want to be able to control the relays via windows, while still have the stamp's program running for automated functions (auto-headlights, auto-windows, etc.)

  • #2
    Yes.

    Yes, the BASIC stamp can be used to communicate with a COM port besides the download port. I have a setup pretty close to what you have planned, and it works well.

    You might want to check out BasicX -24 chips as well- they have 12 bit analog inputs as well.

    DRos.


    Originally posted by Banderon
    Does anyone know if the stamp can interface with the computer while running, or only while being programmed?

    I know the Stamp 2p has 2 pins dedicated to serial I/O, but are those only used during programing or all the time? Basically, I want to be able to have control of my relays/sensors/components without having to wait for my PC to boot, so I'm using the stamp to control them. But once the PC boots, I want to be able to control the relays via windows, while still have the stamp's program running for automated functions (auto-headlights, auto-windows, etc.)

    Comment


    • #3
      Ooohhhh... the BasicX24 seems to be better than the stamp in almost every way. Maybe I should just use this instead.


      edit: and this uses standard BASIC! no need to learn PBASIC! yay! And I mean, it's basicly the same as a stamp, so it should work with all of the stamp's pretty add-ons.

      Comment


      • #4
        I'll be the first to admit serial comms with the basic stamp are much, much easier though. The BX requires you to set up buffers and queues and is generally ackward in general compared to the stamp.

        Comment


        • #5
          Could the Basic stamp be programmed as a startup/shutdown controller? And be reliable?
          My board does not support the last power state function, so I have a very simple on/off relay system. However, it is possible to get the relay system out of sync, so that the computer boots when the key is turned off, and shuts down when the key is turned back on.
          I'm trying to design an on/off controller that would be much more reliable, and difficult to confuse.
          Any thoughts?
          PS, I don't know how to program in BASIC, but if I can also do a power windows setup too, then I'll learn.

          Thanks.

          Comment


          • #6
            Originally posted by Banderon
            Does anyone know if the stamp can interface with the computer while running, or only while being programmed?

            I know the Stamp 2p has 2 pins dedicated to serial I/O, but are those only used during programing or all the time? Basically, I want to be able to have control of my relays/sensors/components without having to wait for my PC to boot, so I'm using the stamp to control them. But once the PC boots, I want to be able to control the relays via windows, while still have the stamp's program running for automated functions (auto-headlights, auto-windows, etc.)
            Just out of curiosity, what exactly would you have the stamp do?
            I was trying to decide if it would be worth it for me to use computer/chip control of the car, but I couldn't find any great compelling reasons to do so. My alarm has enough outputs that I can use it to do what I need.

            I'd appreciate it if you would share some ideas and thoughts.

            BTW: There's also this.
            It looks like it could be pretty cool if you've got wireless internet in your car. Connect to its web server and start your car or unlock you doors or anything else you can think of, all from any internet-connected terminal, I guess even a cell phone.

            From their site:
            SitePlayer SP1 is the World's Smallest Ethernet Web Server at roughly one square inch. SitePlayer allows your application to be web enabled easily with just a serial port on your device. For less than the price of a keypad and graphics LCD, you can have a world wide user interface.


            Thanks,

            Kris
            How Much Horsepower Can I have And Still Go To Heaven?

            Comment


            • #7
              A stamp (regardless what kind... BASIC Stamp, BasicX, OOPic-C, Tiger, etc.) is just a powerful user-friendly microcontroller with a ton of I/Os, upgradable RAM/EEPROM... well, basically a mini-PC that is instantly on, and functions as well or as poorly as your programing and wiring skills. I have huge plans for my stamp.

              I realized a while ago that the only way I'll get things exactly how I want them to be, is to do things myself. As such, I'm going to create/buy/modify parts to make my own hardware solution, and write software for the PC/PDA to interact with it.


              My stamp (or additional EEPROM, if needed) will hold the code for the car's functions. The features I want (and will add if they aren't standard) include:

              - power locks (auto-locked when car is put in D)
              - auto-switch LCD's input to composite video (rear cam) when in R
              - auto-headlights (if it isn't standard)
              - humidity sensor to auto-turn on headlights/wipers for fog (with manual override)
              - auto-window up/down (on servos)
              - auto-sunroof
              - power seats/mirrors with user profiles (useful for passenger seat)
              - remote starter (only active if the car's in Park [if the car's a manual])
              - AM/FM radio on a PCB, controlled via PC (since there seems to be no AM radios for the PC, only FM)
              - radar detector concealed in-dash, connected to stamp to auto-switch LCD to GPS and disable non-cop-friendly PC functions if cop is near (with manual override for false alarms, of course)
              - servo to raise rear license plate @ EZ-Pass tolls (depending on how illegal I want to be... bridges and tunnels are like $6!! )
              - thermisters/servos to create regional climate zones with climate control
              - photoresistors connected to an inverter to auto-dim the LCD
              - sonar rangefinders with digital readouts for parking and "smart cruise control" (applies brake to keep from hitting car in ahead of you)
              - emergency lights and siren control
              - keypad on car door for keyless entry (if it isn't standard)
              - RFID tag on keychain, detector in steering column; tag needed to enable starter
              - mini wireless ethernet with booster antennae; I can control/monitor car functions via wireless-enabled PDA
              - all power functions for PC

              These are just the ones that come to mind immediatly. I've got a ton more.


              The way I see it, the microcontroller will be doing most of the work. Some of them come with multi-tasking, and I can always use more than 1 if needbe. Any function that I need that can't wait for the PC to boot up will be controlled via the stamp (lights, locks, EMT lights, etc.) with physical switches, and all PC control of the car will be through the stamp. The PC's job will be to give me a nice GUI to interact with via LCD touchscreen, a means of programming/updating the stamp, GPS, data transfer (memory readers/IR for cameras/phones), and storage/playback of media (mp3s, CDs, DVDs, etc.)

              I'll have a 802.11g adaptor in the PC, as well as one in my PDA. The power cables will be on channels, so I can remote-start the PC via the microcontroller's ethernet and choose to start only the motherboard, HD, and the USB HUB that has the 802.11g connected... to save power. Then I can stream mp3s/movies straight to my PDA while I'm sitting in class, or anywhere close enough for the booster antennae to still reach... and have the PC auto-shutdown if the battery voltage still drops too low. (And, I supposd I can have a capacitor bank connected solely to the starter in case the battery somehow DOES manage to drain too far.)

              Also, a side note. I don't know if it's legal or not... but I was thinking of putting a 8-10" LCD where the rear-view mirror is, with the camera input coming from a wideangle lens mounted near the rear window. That way, even if there's people in the back seat, I have a large unobstructed view of everything that's behind the car.


              Anyway... maybe that gave you some ideas. Let me know if it did.

              Comment


              • #8
                But anyway.. now I'm trying to decide on what the best stamp out there is. I plan on encoding all the programing into the stamp, and store variable data that I want saved into a tiny/cheap EEPROM chip which I can just replace if/when it breaks down.


                I'm currently considering the following four stamps:

                Stamp 2p - lots of documentation, little onboard EEPROM/RAM
                BasicX24 - less documentation, lots of onboard EEPROM/RAM
                OOPic-C - don't really know too much about it... it's OO
                Economy Tiger - amazing chip... but it's not too cheap and really ugly =\


                Any other good ones that I'm unaware of? What are other positives/negatives of each?

                Comment


                • #9
                  Originally posted by Banderon
                  But anyway.. now I'm trying to decide on what the best stamp out there is. I plan on encoding all the programing into the stamp, and store variable data that I want saved into a tiny/cheap EEPROM chip which I can just replace if/when it breaks down.


                  I'm currently considering the following four stamps:

                  Stamp 2p - lots of documentation, little onboard EEPROM/RAM
                  BasicX24 - less documentation, lots of onboard EEPROM/RAM
                  OOPic-C - don't really know too much about it... it's OO
                  Economy Tiger - amazing chip... but it's not too cheap and really ugly =\


                  Any other good ones that I'm unaware of? What are other positives/negatives of each?
                  You could also try picaxe (www.picaxe.com)
                  Never let the truth get in the way of a good story

                  Comment


                  • #10
                    Hmm.. that Picaxe doesn't look too good. Neither does the OOPic-C.. way too many connections on the chip itself. They should've just made it a 28 or 40-pin IC.


                    So it's down to BasicX24 and Basic Stamp 2p. I'm considering the Tiger... but it seems a bit overkill.

                    Comment


                    • #11
                      BasicX24!

                      I have not had any personal experience with it, but I've been wanting one to replace my Stamp 2!

                      It is much more powerful, but you're right they don't give you much write up. It takes practically the same programming as the Stamp.

                      And if you get something working, I would gladly take a look at your source code...
                      2000 Subaru OBS

                      Dell P3 @ 900 Mhz
                      7" Lilliput TS w/DigitalWW in-dash mount
                      80GB External HD

                      I am Zero Bitrate....

                      Comment


                      • #12
                        Originally posted by kiltjim
                        BasicX24!

                        I have not had any personal experience with it, but I've been wanting one to replace my Stamp 2!

                        It is much more powerful, but you're right they don't give you much write up. It takes practically the same programming as the Stamp.

                        And if you get something working, I would gladly take a look at your source code...
                        Yeah, I'm considering the BasicX24 as my primary choice right now. I found out the Stamp 2p doesn't let you store program code outside of the onboard EEPROM, and I don't know if that'll be enough space. And the BasicX24 is faster, too.

                        I'm still considering the Economy Tiger though.. http://www.wilke-technology.com

                        But it's a) ugly, b) not really a stamp, and c) very little documentation/user support


                        Edit: The BasicX24 actually has very good documentation and a Yahoo! Support Group. I liiike..

                        Comment


                        • #13
                          Hmm, Im wanting to get a programmable chip, going to research the X24, it sounds pretty good. Does any one have the Chip & programmer and have anything good / bad to say about it?
                          CarComputer Status: New Car & Broken (Motherboard Fried)
                          Owen JH | My Linux Blog | The Tech Fellows

                          Comment


                          • #14
                            Originally posted by owenjh
                            Hmm, Im wanting to get a programmable chip, going to research the X24, it sounds pretty good. Does any one have the Chip & programmer and have anything good / bad to say about it?
                            You can download the documentation and code editor off of www.basicx.com and go http://basicx.com/custapps/custapps.htm to see some of the uses this chip's been put to.

                            You program it in VB syntax, so that should simplify things for most people. No C/Assembler knowledge required.

                            Comment


                            • #15
                              Here's some old code I run on my BX24 Startup code. Im still working on it, so you'll obviously notice some discrepencies, and that fact that i am not a programmer!

                              '
                              ' BasicX-24 Chip
                              ' ________________
                              ' | |
                              ' COM1 TX | 1 24 | V+ Regulator in 5.5-15v
                              ' COM1 RX | 2 23 | GND
                              ' ATN | 3 22 | Reset (Active Low)
                              ' GND | 4 21 | V+ Regulator out 4.8 - 5.5v
                              ' - | 5 ADC 20 | - Ign
                              ' - | 6 ADC 19 | - SW1
                              ' - | 7 ADC 18 | - SW2
                              ' - | 8 ADC 17 | - NA
                              ' - | 9 ADC 16 | - Dimmer In
                              ' - | 10 ADC 15 | - LCD Brightness
                              ' - | 11 ADC 14 | - LCD SSR
                              ' - | 12 ADC 13 | - CPU SSR
                              ' |________________|
                              '
                              ' LIMITS
                              ' Output:
                              '
                              ' Input:
                              '
                              ' Total: < 70mA
                              '
                              Option Explicit


                              '--------------------------------------------------------
                              ' Pin definitions for the basicX chip
                              '--------------------------------------------------------
                              Public Const null_pin As Byte = 0 ' Null pin for serial exchange
                              Public Const cpu_power_switch_pin As Byte = 7 ' CPU Switch Pin (digital out - active low)
                              Public Const cpu_ssr_pin As Byte = 14 ' CPU SSR Pin (digital out)
                              Public Const lcd_ssr_pin As Byte = 13 ' Amplifier/LCD SSR Pin (digital out)
                              Public Const not_used As Byte = 17 ' Not used
                              Public Const dimmer_in_pin As Byte = 16 ' Dimmer in (analog in)
                              Public Const switch_input_2 As Byte = 19 ' Switch Input 2 (analog in)
                              Public Const switch_input_1 As Byte = 18 ' Switch Input 1 (analog in)
                              Public Const ignition_in_pin As Byte = 20 ' IgnitionIn (analong in)
                              Public Const red_led_pin As Byte = 25 ' red led
                              Public Const green_led_pin As Byte = 26 ' green led
                              Public Const temperature_in_pin As Byte = 27 ' Temperature in pin (analog in)

                              '--------------------------------------------------------
                              ' Some global variables
                              '--------------------------------------------------------
                              Public current_mode As Byte ' Mode that dash switch is in
                              'Public previous_mode As Byte ' mode 0 off, mode 1 on
                              Public switch_mode As Byte

                              Public debug_mode As Byte

                              Public switch_1_status As Integer
                              Public switch_2_status As Integer
                              Public ignition_status As Byte
                              Public ignition_value As Integer
                              Public computer_status As Integer
                              Public previous_state As Integer
                              Public temperature_value As Integer
                              Public dimmer_value As Integer


                              Public Const InputBufferSize As Integer = 17 ' 8-byte buffer.
                              Public Const OutputBufferSize As Integer = 20 ' 11-byte buffer.
                              Public InputBuffer(1 To InputBufferSize) As Byte
                              Public OutputBuffer(1 To OutputBufferSize) As Byte




                              Public error_flag As Byte
                              ' Error Code Explanation
                              ' 91 - Switch input error (unused mode- both input high)
                              ' 92
                              ' 93
                              ' 94
                              ' 95
                              ' 96
                              ' 97
                              ' 98
                              ' 99


                              '================================================= =====
                              ' MAIN
                              '================================================= =====

                              Public Sub Main()


                              ' USE DEBUG MODE FOR VERBOSE LOGS
                              debug_mode = 0 ' 0 = OFF, 1 = ON

                              ' Initialize serial ports and IO
                              Call initialize()

                              Do
                              'Call find_switch_mode()
                              'Call find_ignition_mode()
                              'Call set_power()
                              ''Call output_data()
                              'Call heartbeat()
                              'Call Delay(1.0)
                              'Call PutStr("SHUTDOWN")

                              Call Delay(10.0)
                              Call PutPin(6,1)
                              Call PutPin(5,0)

                              Call Delay(10.0)
                              Call PutPin(6,0)
                              Call PutPin(5,0)


                              Loop


                              End Sub









                              '================================================= =====
                              ' CUSTOM FUNCTIONS
                              '================================================= =====

                              Sub initialize()
                              ' Initial state of computer is off
                              computer_status = 0
                              ' CPU switch initially high (off)
                              Call PutPin(cpu_power_switch_pin,1)


                              Call OpenQueue(InputBuffer, InputBufferSize)
                              Call OpenQueue(OutputBuffer, OutputBufferSize)
                              Call OpenCom(1, 19200, InputBuffer, OutputBuffer)


                              previous_state = 0
                              End Sub
                              '------------------------------------------------------

                              Public Sub PutStr( _
                              ByVal Tx As String)

                              ' Outputs a String type to the serial port.

                              Dim Length As Integer, Ch As String * 1, bCh As Byte
                              Dim I As Integer

                              Length = Len(Tx)

                              For I = 1 To Length
                              Ch = Mid(Tx, I, 1)
                              bCh = Asc(Ch)
                              Call PutByte(bCh)
                              Next

                              End Sub
                              '-------------------------------------------------------------------------------

                              Public Sub PutByte( _
                              ByVal Value As Byte)

                              ' Sends one byte of binary data to the serial port. The byte is sent
                              ' directly without translating it to a string.

                              Call PutQueue(OutputBuffer, Value, 1)

                              End Sub

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

                              Sub find_switch_mode()

                              switch_1_status = GetADC(switch_input_1)
                              switch_2_status = GetADC(switch_input_2)

                              ' sw mode 1 2 function
                              '-------------------------------
                              ' 91 1 1 Error mode - switch malfunction
                              ' 2 0 1 On all the time
                              ' 1 1 0 Off all the time
                              ' 0 0 0 Auto mode

                              ' On all the time & Auto mode
                              If(switch_1_status < 100 ) Then
                              If(switch_2_status > 500) Then
                              switch_mode = 2
                              'Debug.Print " On all the time"
                              else
                              switch_mode = 0
                              'Debug.Print " Auto Mode"
                              End if

                              ' Off all the time
                              Else
                              If(switch_2_status < 100) Then
                              switch_mode = 1
                              'Debug.Print " Off all the time"
                              else
                              switch_mode = 5
                              error_flag = 1
                              End If
                              End If

                              If(debug_mode = 1) Then
                              debug.print "Sw1 status: " & Cstr(switch_1_status) &" Sw2 Status: " & CStr(switch_2_status) & " Mode: "& Cstr(switch_mode)
                              End if

                              End Sub

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

                              Sub find_temperature()
                              temperature_value = GetADC(temperature_in_pin)
                              ' Debug.Print CStr(temperature_value)
                              End Sub

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

                              Sub find_ignition_mode()
                              ignition_value = GetADC(ignition_in_pin)
                              If(ignition_value > 1000) Then
                              ignition_status = 1
                              Else
                              ignition_status = 0
                              End If

                              If(debug_mode = 1) Then
                              Debug.Print "Ignition Value: " & CStr(ignition_value)
                              End if
                              End Sub

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

                              Sub set_power()

                              ' sw mode 1 2 function
                              '-------------------------------
                              ' 91 1 1 Error mode - switch malfunction
                              ' 2 0 1 On all the time
                              ' 1 1 0 Off all the time
                              ' 0 0 0 Auto mode

                              ' Previous mode
                              '---------------
                              ' 0 - previously off
                              ' 1 - previously on


                              ' Auto Mode - SW mode 0
                              If(switch_mode = 0) Then
                              If(debug_mode = 1) Then
                              Debug.Print "IN Auto Mode"
                              End If

                              ' If car is on
                              If(ignition_status = 1) Then
                              If(previous_state=1) Then
                              ' Ignition On - Was on - leave on
                              If(debug_mode = 1) Then
                              Debug.Print "Is ON, Was ON ->Leave ON"
                              End if
                              Else
                              ' Ignition On - Was off - turn on
                              If(debug_mode = 1) Then
                              Debug.Print "Is ON, Was OFF -> Call Startup"
                              End if
                              Call startup()
                              End If
                              Else
                              If(previous_state=1) Then
                              ' Ignition Off - Was on - turn off
                              If(debug_mode = 1) Then
                              Debug.Print "Is OFF, Was ON -> Call Shutdown"
                              End If
                              Call shutdown()
                              Else
                              ' Ignition OFF - Was off - leave off
                              If(debug_mode = 1) Then
                              Debug.Print "Is OFF, was OFF -> Leave OFF"
                              End If
                              End If
                              End If


                              ' On all the time - SW mode 2
                              ElseIf(switch_mode = 2) Then
                              If(debug_mode = 1) Then
                              Debug.Print "IN Mode 2"
                              Debug.Print "On all the time"
                              'Debug.Print CStr(previous_state)
                              End If

                              If(previous_state=0) Then
                              Call startup()
                              ' Was off - turn on
                              Else
                              ' Was on - leave on
                              Call PutPin(lcd_ssr_pin,1)
                              End If


                              ' Off all the time - SW mode 1
                              Else

                              If(debug_mode = 1) Then
                              Debug.Print "IN Mode 1"
                              Debug.Print "Off all the time"
                              'Debug.Print CStr(previous_state)
                              End if

                              If(previous_state=1) Then
                              ' Was on - turn off
                              Call shutdown()
                              Else
                              ' Was off - leave off
                              End If
                              End If


                              End Sub

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

                              Sub heartbeat()
                              ' Just a little pulse to say it's alive
                              Call PutPin(green_led_pin,0)
                              Call Delay(1.0)
                              Call PutPin(green_led_pin,1)
                              Call Delay(1.0)
                              End Sub


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

                              Sub output_data()
                              ' Send helpful information to the computer

                              If(debug_mode = 1) Then
                              Debug.Print "MODE=" & CStr(switch_mode)
                              Debug.print "SW1=" & CStr(switch_1_status)
                              Debug.print "SW2=" & CStr(switch_2_status)
                              Debug.print "IGN=" & CStr(ignition_value)
                              'Debug.Print "shutdown"
                              End If
                              End Sub

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

                              Sub startup()
                              If(debug_mode = 1) Then
                              Debug.Print "Entering startup mode..."
                              End if
                              ' Power on Inverter and PS
                              Call PutPin(cpu_ssr_pin,1)
                              Call delay(1.0)

                              ' Toggle cpu switch pin low to start cpu
                              Call PutPin(cpu_power_switch_pin,0)
                              Call delay(1.0)
                              Call PutPin(cpu_power_switch_pin,1)

                              ' Wait for computer to start
                              Call Delay(5.0)

                              ' Turn on LCD/Audio Amplifier
                              Call PutPin(lcd_ssr_pin,1)

                              ' State is ON
                              previous_state = 1
                              If(debug_mode = 1) Then
                              Debug.Print "Finished startup mode..."
                              End If

                              End Sub

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

                              Sub shutdown()
                              If(debug_mode = 1) Then
                              Debug.Print "Entering shutdown mode..."
                              End If

                              ' Shutdown amplifier and LCD screen
                              'Call PutPin(lcd_ssr_pin,0)

                              ' Issue shutdown computer command via serial port
                              Call PutStr("SHUTDOWN")

                              ' PUTBYTE(<shutdown Byte>)
                              ' Wait for computer to shut down
                              Call Delay(30.0)

                              ' Toggle the cpu switch to turn off computer
                              Call PutPin(cpu_power_switch_pin,0)
                              Call delay(0.5)
                              Call PutPin(cpu_power_switch_pin,1)

                              ' Power off inverter and PS
                              Call PutPin(lcd_ssr_pin,0)
                              Call delay(1.0)
                              Call PutPin(cpu_ssr_pin,0)

                              ' State is OFF
                              previous_state = 0

                              End Sub

                              Comment

                              Working...
                              X