Shop OBEX P1 Docs P2 Docs Learn Events
Getting started — Parallax Forums

Getting started

BjBj Posts: 22
edited 2008-09-17 08:09 in BASIC Stamp
Hi

I have now downloaded the editor.
I want my BS1 to connect and disconnect 2 cables

And I'm a beginner, and want to get started. [noparse]:)[/noparse]

I guess the code starts like this

' {$STAMP BS1}
' {$PBASIC 1.0}
and then a command to activate p0?
How to deactivate p0?
When p0 is activated, then cable 1 and 2 connect. Do I need a relay to do this? I guess so yeah.gif
How fast are a relay? Can it connect/disconnect a cable 10-15 times in a secound?
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-28 19:48
    Most reed relays are fast. They were originally developed for use in telephone exchanges. You will need to look at the datasheet for the specific reed relay you want to use to find the on and off switching times. You probably want a 5V coil with a coil current of 20mA or less. That would involve a coil resistance of 250 Ohms or more. These are readily available. You will also need a diode like a 1N4001 or 1N4148. You would connect one end of the relay coil to a Stamp I/O pin and the other end to ground (Vss). You connect the cathode (white or black banded) end of the diode to the Stamp I/O pin and the other (anode) end of the diode to ground (Vss). A HIGH statement will turn the relay on and a LOW statement will turn it off. At the beginning of your program, put a LOW statement to make sure the relay is off.

    RadioShack has a nice reed relay that will work: www.radioshack.com/product/index.jsp?productId=2062478&cp=2032058.2032230.2032277&accessories=accessories&custRatings=custRatings&support=support&currentTab=features&parentPage=family&features=features&summary=summary&techSpecs=techSpecs&tab=summary
  • BjBj Posts: 22
    edited 2008-08-28 20:25
    Thanks. The coil is inside the relay, so I don't have to worry about buying coils?

    There is 8 pairs of cables to connect and disconnect. Do I need 8 relays?

    I aslo have a switch that connects 2 cables. Is it possible to use that switch to trigger the program?
  • BjBj Posts: 22
    edited 2008-08-28 20:33
    Hi

    I looked at this link now, and it looks like the relay have 5 pins. What does the 5.th pin? The 4 others is for ground, p0, cable1 and cable2. When there is voltage on p0, the relay will connect cable 1 and 2.
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-28 20:39
    The coil is part of the relay. Do a web search for "wiki relay".

    The BS1 only has 8 I/O pins, so it can directly control only 8 devices. There are also overall current limits that prevent you
    from activating more than two relays at a time. You may need to use some kind of switching transistor to handle the current.
    Look at the Nuts and Volts Column #6 for a discussion on controlling higher amounts of current and there are several columns
    on using external devices to expand the number of effective I/O pins.
    You probably will need to use something like a BS2 which has 16 I/O pins and quite a bit more program storage than the BS1.
    You can use a switch (or several of them) to control the program. Each switch will usually require an I/O pin.
    The "What's a Microcontroller?" tutorial downloadable from Parallax shows how to do this and provides coding examples.

    Nuts & Volts: www.parallax.com/Resources/NutsVoltsColumns/tabid/272/Default.aspx
    Tutorials: www.parallax.com/tabid/535/Default.aspx
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-28 20:40
    There is no 5th pin. You're seeing a reflection on the tabletop.
  • BjBj Posts: 22
    edited 2008-08-28 21:25
    Hi, If I understand what I have read, the BS1 cannot activate more than 2 relays because of overheating or fall in voltage? I need up to 4 relays activation at the same time.
    The program I want to create will contain about 10 000 commands like HIGH, LOW and PAUSE. It will take about 5 minuttes to run. Does BS1 have good enought storage for that?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-28 21:39
    No

    The BS1 is not adequate for your task. I suggest you use a BS2p or BS2pe which has much more memory.
    The BS2p does not have quite enough memory for 10,000 commands, but would be able to hold your sequencing
    information if it's encoded in table form. You may be able to represent one HIGH / LOW / PAUSE sequence in a single byte
    depending on the details. You will need to activate the relays using switching transistors or a transistor array like the
    ULN2803 described in the Nuts and Volts Column I mentioned.

    I strongly suggest you download the tutorial I mentioned and have a look through it. There are other useful tutorials on those
    pages. "Basic Analog and Digital" comes to mind. You will need to learn about the Stamps and how to use them effectively.
    There's plenty of documentation and sample programs, but you should work through the examples.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-28 22:11
    If you read his description, the BS1 is only managing the touch sensors and the relays.
    It's not storing any of the command pattern information. That's all on the PC or Mac.
    You're welcome to get whatever information you can about his system and try to duplicate
    it. That's not what you originally asked.
  • BjBj Posts: 22
    edited 2008-08-28 23:03
    Okay. So it is possible to run the program from a pc? What program is best to use? Pascal, Visual Basic, C?
    What kind of relays do you think he use? For me it looks like a double relay.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-28 23:51
    The program would not be run from a PC. There's one program on the Stamp and another on the PC and they communicate via a serial link.
    The BS1 has the ability to transmit to the PC over the same serial link used for programming. There's a Nuts and Volts Column on that subject.
    The data has a particular format used by the DEBUG statement. This serial link does not have the ability to transmit data back to the BS1 from
    the PC. It's possible to use a separate USB to serial or RS232 to serial logic level converter for such a link. It would require some of the I/O pins
    of the BS1 though. Any PC programming language that you're familiar with and supports a serial link (serial port) should be fine.

    I don't really see relays in the pictures. Perhaps he's using some kind of solid-state relay, but I can't read the part numbers in the photos.
  • BjBj Posts: 22
    edited 2008-08-29 07:27
    Hi, Do you know the Colum # for the serial-link communication between PC and BS?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-29 14:41
    Nuts and Volts Column #131

    This deals with interpreting the DEBUG information sent to the PC over the programming serial link.
    There's no article on other BS1 to PC links. Look at the Stamp Basic Manual in the chapters on the
    SERIN / SEROUT statements for information on connecting I/O pins to an RS232 serial port.

    Post Edited (Mike Green) : 8/29/2008 2:46:28 PM GMT
  • BjBj Posts: 22
    edited 2008-08-30 15:16
    Thank. If I understand you correct. I cannot use more than 2 relays, but I can solve this If I use a transistor, and then the relay?

    What is "IC"?

    I have also just read that there is possible to controll atleast 8 relays with with a paralell cable (LPT-port). I think that will maybe be a better solution for my project.
    Do you know how many volt and how many mA a paralellport kable can handle?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-30 15:25
    The problem with the relays is that they typically draw about 20mA. If two are on, that's 40mA.
    The Stamp can't handle more than 50mA total current for the I/O pins. By using a switching
    transistor, the Stamp only has to provide enough current to control the transistor. A few mA
    is enough for that.

    "IC" is an abbreviation for Integrated Circuit

    A parallel port interface usually works with 5V logic levels. You will need to get the specifications
    for any parallel port interface you are considering to see what the current rating would be. Keep
    in mind that there's a separate rating for each individual output and for all the outputs together
    just like the Stamp ratings. If your printer port is a standard IEEE1284 port, it can supply 14mA
    minimum on each output bit. This may or may not be enough for your relay. You could use a
    switching transistor for each relay to handle the current just like on the Stamp.

    Post Edited (Mike Green) : 8/30/2008 3:34:25 PM GMT
  • BjBj Posts: 22
    edited 2008-08-30 16:19
    Could this transistor be nice to buy?
    http://www.radioshack.com/product/index.jsp?productId=2062585

    EDIT:
    And how to connect a relay or transistor with a wire? Soldering or is there a more easy solution?

    Post Edited (Bj
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-30 17:15
    You can use those transistors, but they must be connected differently from the examples shown in the Parallax documentation
    because those are PNP transistors and the ones normally used for this sort of use are NPN transistors (of opposite polarity).

    These are essentially the same as shown in the Parallax examples: www.radioshack.com/product/index.jsp?productId=2062586&cp=2032058.2032230.2032279&parentPage=family

    Do you know how to solder? If not, search the internet for tutorials on soldering and practice on some scrap wire.
    It takes some practice and care to solder properly. I usually use a piece of perforated printed circuit board with
    plated and tinned through holes (the holes are coated with copper, then solder or tin). I position the parts so that
    I can use the leads to make the connections or I use a separate piece of wire. RadioShack and others sell boards
    like this with some printed circuit traces between some of the holes so you can use those for interconnections
    instead of wire. They even have one that duplicates the interconnections in a standard breadboard that they sell.
  • BjBj Posts: 22
    edited 2008-08-31 11:01
    Hi, Radioshark will not ship to Norway (where I live). Do you know about any other webshops (with the same products) who ship international?
  • FranklinFranklin Posts: 4,747
    edited 2008-08-31 14:34
    I would think that Mouser, DigiKey or Jameco would ship international. There must be local dealers for these things in Norway somewhere.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-31 14:41
    Companies like Jameco, Mouser, and DigiKey have webstores and on-line catalogs, accept small orders, and ship internationally.
    Shipping costs and international handling fees are often prohibitive for small orders though. You should be able to find dealers
    in most large cities who carry the basics.
  • BjBj Posts: 22
    edited 2008-09-01 19:51
    Hi, I got another Idea. Is it possible to connect I/O pins direct to the gamecontrollers wires, so I don't need to use relays and transistors. The gamecontroller operates with 1,61v maybe less or more cause of batterycondition. I guess I need to convert 5v to 1,61v, and I will maybe need to connect basic stamps ground to gamecontrollers ground.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-01 20:05
    That depends on the game controller's circuitry. There will need to be some kind of common ground or you'll need to use relays or optoisolators.
  • BjBj Posts: 22
    edited 2008-09-01 20:21
    How can I figure out the circuitry?
    And I have just painted a nice picture. This is a one button guitarcontroller (just to make it easy).
    solution_example.jpg

    Here is a picture of the guitarcontrollers circuitry?
    exilim_august2008016.jpg
  • BjBj Posts: 22
    edited 2008-09-01 21:33
    This is the strumbars backside.
    EOS_elektro_august2008007.jpg
    When I use my multimeter and put the red cable (connected to V/ohm/mA) to the UP or DN (Down) and the black cable (Connected to COM) to the 2pointed Noname field it shows 1,61v. If i put the red and black oposite, I gor -1,61v. I guess thats means that the 2pointed noname field is ground, so I'm afraid that I can just forget my last idea.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-01 21:55
    Really, unless you know the circuitry you're connecting to, the best technique is to use the
    reed relays or sometimes an optocoupler like the 4N26 (www.fairchildsemi.com/ds/4N/4N26-M.pdf)
    Since an optocoupler requires only about 10mA, you could run 4 or 5 of them at the same time from a series of I/O
    ports. You might be able to run them at a lower current, depending on what has to be controlled.

    Given that you don't know what you're connecting with, the reed relays would be the safest solution.
    This one from Jameco (www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&productId=1860088)
    would work. It has a 5V coil, built in diode for reverse voltage suppression and costs $1 US. Other distributors would carry the
    identical relay.

    Here's a link to the manufacturer's Norwegian Sales Representative and Distributor: www.hamlin.com/contact-detail.cfm?regionid=12&Territory=Norway. Give them a call. Sometimes they'll send a few free samples to a hobbyist.

    You'll still need some cheap NPN switching transistors like the 2N2222 and a 1K resistor for each (to go in series in the base lead).
    There are several examples of the proper wiring. Nuts and Volts Column #6 is the best. Go to Parallax's main website, choose
    the Resources tab, then choose Nuts and Volts Columns. Find #6 and download it.

    Post Edited (Mike Green) : 9/1/2008 10:07:12 PM GMT
  • BjBj Posts: 22
    edited 2008-09-02 11:06
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-02 14:55
    This transistor would be cheaper because it comes in a plastic package rather than the metal package of the one you showed. Electrically, it's the same. www.Jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&pa=787552&productId=787552&keyCode=PDF

    The resistor is exactly what I was intending.

    The relay is rated for switching up to 200VDC at currents up to 500mA. The datasheet doesn't say anything about lifetime, but reed relays in general are designed for high speed switching, over 1KHz, and would last years at that rate as long as the current and voltage aren't exceeded.
  • BjBj Posts: 22
    edited 2008-09-02 16:12
    I have now ordered reedrelays, transistors and resistors, but it will take about a week before a recive it. I will draw how to wire everything together while I sait for the shippingprogress. I think I will go for the parallel-solution, and not use the basic stamp, because of smal storage space.

    I have bought a experimentalboard, parallel-cablel, and soldering equipment and I have now soldered everything to the experimentlboard. This is a newbie solderwork, but I think it is good enought and it will do the job.

    I did a mistake with pin 17 and 18, because I soldering it together, but I don't need pin17, so I have just cut the wire. My other mistake where that I forget to take my wirestripper off the cable before I started to soldering.
    You can see it at the pictures. pin1 to the right and 25 to the left. pin2 and 10 was soldered from the underside.
    exilim_august2008024.jpg

    This picture shows my mistake with the wirestripper.
    exilim_august2008026.jpg


    Thanks for your help and good answeres so far.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-02 16:28
    You need more practice with the soldering. It looks like you used a bit too much solder and not quite enough heat. The solder should melt and flow rather than bunch up. This happens because the printed circuit board copper traces are hot enough to keep the solder melted for a fraction of a second so the solder "wets" the copper. It's hard to explain, but easy to demonstrate. Try to find someone who's experienced in soldering to show you. There are probably free videos on the internet that demonstrate this. Do some searches perhaps starting with the Wikipedia.
  • BjBj Posts: 22
    edited 2008-09-02 17:06
    I tought it would be nice to buy a 15W solderstick for solder small things like electronics. How big solderstick should I use?
    I misunderstood how a transistor works, but I think I now understand it.

    I have drawn a exaple, and also have some questions.

    "Relayground" is this the ground at the relay?

    RB means resistor, and I will need to put my 1k resistor here?

    Does the ground for the transistor have to be common for the stamp pin and the supply?

    Will my example connect wire 1 and wire2?

    And I guess this will work the same way if I connect a LPT-pin instead of stamp pin?

    Post Edited (Bj
Sign In or Register to comment.