Shop OBEX P1 Docs P2 Docs Learn Events
PC Status Indicator Using Basic Stamp BS2 — Parallax Forums

PC Status Indicator Using Basic Stamp BS2

Peter SavoryPeter Savory Posts: 5
edited 2012-10-31 11:23 in BASIC Stamp
I am new to the Basic Stamp, I am trying to use the Basic Stamp to operate out puts to control lights which will show the status of the PC that the Stamp is connected to.

1 - Output when the PC is in stand by mode and ready to receive data.
2 - Output when the PC is traferring data or recieving data.
3 - Output if there was an error transferring data or if there is a problem with the PC.

Can any one help, I have not got a clue.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-10-30 06:35
    Start by describing what you mean by the terms you used ("standby mode", "ready to receive data", "transferring data", "receiving data", "error transferring data", "problem with the PC") in terms of signals from/to the PC. If you're referring to a PC serial port, some of these terms may refer to standard signals like Data Terminal Ready (DTR) or Clear To Send (CTS). "Problem with the PC" is very vague. What sort of problem? Are you talking about a timeout of some kind? If so, you have to specify what it is. This vagueness is why you feel you "have not got a clue".
  • Peter SavoryPeter Savory Posts: 5
    edited 2012-10-30 06:57
    Mike Green wrote: »
    Start by describing what you mean by the terms you used ("standby mode", "ready to receive data", "transferring data", "receiving data", "error transferring data", "problem with the PC") in terms of signals from/to the PC. If you're referring to a PC serial port, some of these terms may refer to standard signals like Data Terminal Ready (DTR) or Clear To Send (CTS). "Problem with the PC" is very vague. What sort of problem? Are you talking about a timeout of some kind? If so, you have to specify what it is. This vagueness is why you feel you "have not got a clue".

    Hi Mike, the scenario is, a Truck with a lot of data on board checking all operations of the truck, when the truck parks in its parking bay it will transfere data either wirelessly or via a plug in cable to a PC, the PC will have software that will recive all data from the truck to preform diognostics to make sure all parts on the truck is operating correctly.
    The truck driver needs to see some illumination of lights to indicate that the PC is ready to recieve the data, that the data has transmitted from the truck to the PC ok or if there was a fault with the transmission from the truck to the PC.
    Using Basic Stamp I need to create an interface between the PC and the illumination of lights, the lights will be switch via relays but I need to get the signals from the PC to operate the relays note sure of correct terminology but switching the lights to different colours to illustrate the status of the PC is the final outcome.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-10-30 07:16
    Again, more information is needed. For example, what do you mean by "wireless"? There could be any of a host of technologies used there. "Plug in cable" ... again, this could be a standard RS232 serial port or it could be a USB "virtual serial port" or possibly other schemes. How you'd do what you want depends on the details of this information. Do you have any control over the software talking to the truck's systems? Do you have any details of the format of the data going back and forth? All of this is important.

    For example, assuming this is a standard RS232 serial port, you could build a simple interface to receive and transmit data signals that indicates whether data is being transferred. A 22K resistor between a Stamp I/O pin and the signal may be enough as shown in the Stamp Manual chapter on the SERIN statement. An RS232 line typically idles at a negative voltage (-3V to -15V) to indicate a one bit and changes to positive to indicate a zero bit (+3V to +15V). The Stamp could monitor the data line for a short period of time looking for pulses. If there are any, there's data going back and forth.

    On the other hand, for a Stamp to determine that there are errors, it has to look at the data itself and know what should be there or the PC has to tell it that an error occurred. That may be too complex and require too much speed from the Stamp ... depending on the details not yet described.

    If the PC uses a standard serial port and uses the DTR / DSR and RTS / CTS control lines, the Stamp can monitor them to find out if the PC is indicating that it's ready to receive data. That's a function of the way the PC program uses the serial port.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-10-30 07:28
    If you have complete control of the PC program and can modify it, then the PC program can do all the decision making and you can just use the Stamp to control the indicator lights based on information from the PC. The simplest thing would be to use a separate serial port. Any Stamp board with a USB interface would do. The PC would send characters out to the Stamp like "A" to turn on one LED and "B" to turn off the LED. "C" would turn on a 2nd LED and "D" would turn it off and so on. You'd have a simple program on the Stamp that would use the DEBUGIN statement to receive these characters and turn on or off the corresponding LED.

    For reliability, the PC would probably send each character twice with a 20ms pause between characters.
  • Peter SavoryPeter Savory Posts: 5
    edited 2012-10-30 07:58
    Hi Mike, this sounds ok, but where do I start, I have very little experience with programming but need to get this sorted, can you help???
  • Mike GreenMike Green Posts: 23,101
    edited 2012-10-30 09:02
    1) What / Which sounds ok? Are you referring to post #5? First thing with programming is you need to remember to be specific. Details are important.

    2) The starting point for Stamp programming is "What's a Microcontroller?" (here) and "Basic Stamp Syntax and Reference Manual" (here). Both (like most of Parallax's documentation) are downloadable for free and available in book form. If you need to drive a relay or an incandescent bulb from a Stamp I/O pin, look at Nuts and Volts Column #6 (under Volume #1 here).

    3) If you want more detailed help, you'll need to supply more information. Do you have a Stamp already? If so, what board are you using? How many indicator lights do you need? What kind are they (LED or incandescent)? What voltage and current do they require?
  • Peter SavoryPeter Savory Posts: 5
    edited 2012-10-31 07:42
    I have a Basic Stamp 2 as recommended by the previous unit that has been installed.
    The operation is not to operate the lights but to give output voltage when the condition are met, I will interface relays to control the lights, voltage is not an issue.

    LED's can be connected to the bread board to demonstrate that the unit is operating when the PC changes status.
    I have never delt with this type circuits so not sure where to start.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-10-31 09:34
    You start by defining exactly what the Stamp is to do under what circumstances. I've discussed some possible scenarios. Which sounds like your situation? Are we talking about post #5? If so, what board are you using? The term "BS2" usually refers to the 24-pin module although it can also refer to boards with a BS2 permanently mounted on the board (like the Homework Board).
  • Peter SavoryPeter Savory Posts: 5
    edited 2012-10-31 09:45
    Mike Green wrote: »
    You start by defining exactly what the Stamp is to do under what circumstances. I've discussed some possible scenarios. Which sounds like your situation? Are we talking about post #5? If so, what board are you using? The term "BS2" usually refers to the 24-pin module although it can also refer to boards with a BS2 permanently mounted on the board (like the Homework Board).

    We have the Basic Stamp 2 module microcontroller & the Board of Education USB development board.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-10-31 11:23
    OK. That's a little bit of information. That means that you can attach the Stamp to your PC via a USB cable and the Stamp can communicate with a program on the PC using the DEBUG and DEBUGIN statements as well as using SEROUT and SERIN with a "fake" I/O pin number of 16 specified as described in the Stamp Reference Manual under those statements. The Stamp can set I/O pins high (+5V) and low (0V) using the HIGH and LOW statements. All of these (and things like IF and GOTO) are covered in "What's a Microcontroller?" and the Reference Manual. If you like what I described in post #5 (you didn't say), your program would consist mostly of a DEBUGIN statement that would wait for a character from the PC, then a series of IF statements that compare that character to a constant and make an I/O pin high or low like:

    IF theChar = "A" THEN HIGH 5

    The last statement would be a GOTO to start it all over again.

    Go through "What's a Microcontroller?" and the Reference Manual to see what else you need in the way of declarations, compiler directives, labels, etc. It's all there and you need to learn it. There are plenty of simple examples of what you need.
Sign In or Register to comment.