Shop OBEX P1 Docs P2 Docs Learn Events
How would you send a text file to a BS2 — Parallax Forums

How would you send a text file to a BS2

JimDandyJimDandy Posts: 4
edited 2005-11-02 20:52 in BASIC Stamp
Hi all, first time poster here. I didnt find a topic that hit on what I am curious about. If you guys/gals could help me out with a problem I would be greatful.
I am trying to control a matrix of lights 6x6 for a total of 36 lights.
These lights will be controlled by relays which will be controled by the BS2 (control voltage for the relay).

I do not know where to begin? I have a text file that contains the matrix (binary 1/0) for the on/off for each light. this will be generated by another program.

I know that a program can be written to the stamps that converts a string of binary to the stamps and tells them which i/o pin should be high or low.
In other words, after I download the program to the BS2, how do send them a string of code to tell them which pins to turn on and off.

I mean how do I connect the BS2 to the text file that will be changing without haveing to plug the stamp in> program > then unplug and place back into the circuit.

I hope this isnt too scatterbrained for the point to get across.
thanks for any reply's,
Lane

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-10-28 20:48
    Well, your question is a little confusing.

    On the one hand, it sounds like you want to have your PC connected to the BS2, send it data, have the BS2 read the data, and then turn on LEDs in a particular pattern.

    On the other hand, it sounds like you have a text file of the patterns you want the lights to take. You then want to program the BS2 so it will cycle through the patterns without the PC connected.

    To do the second approach, you need to turn your light patterns into DATA statements. Then cut and paste those DATA statements into the BS2 IDE. Then write some simple code for the BS2 to cycle through those DATA statements, and send the results out to the lights.

    I don't know how complicated your patterns are, either. The BS2 has 2,000 bytes of EEPROM space. If the program takes 100 bytes, you have 1900 bytes of DATA space left. If, for each pattern, you did 5 bytes (40 bits) then you could fit 380 patterns in your EEPROM.

    That's how I'd go about it, anyway.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2005-10-28 21:02
    JD (a.k.a. Lane),

    Thinking that you might figure to send the data ("string of binary") to the STAMP as serial data. So, research "SERIN". Then you can 'interpret' that with the STAMP and place that data on OUTPUT pins in parallel fashion.
    So, say a row in your 6x6 is ** on-off-on-off-on-off **, I would send that as an 8-bit word -- 00101010 ($2A). Likewise, if another row was ** on,on,on,off,off,on **, I would send 00111001 ($39)
    I've fashioned the 6 pixels into an 8-bit word using 0's (as place-keeping) for the more significant bits.
    When you receive that data with the STAMP, store it in a variable, and then "dump" it in parallel.

    That much should give you a head start.
  • JimDandyJimDandy Posts: 4
    edited 2005-10-30 16:13
    Very helpful guys thank you, that should lead me in the right direction and I am sure I will have more questions later. Thanks again Ill keep you posted on progress.
    Lane
  • JimDandyJimDandy Posts: 4
    edited 2005-11-02 19:18
    allanlane5 said...
    Well, your question is a little confusing.

    On the one hand, it sounds like you want to have your PC connected to the BS2, send it data, have the BS2 read the data, and then turn on LEDs in a particular pattern.

    ay.
    this is exactly what I am looking for, you elaborated on the second notion, could elaborate on this one.
    I am looking into the SERIN command, but am also looking for other possibilities.
    I have at my disposal:
    1. homework board that I can connect to a cpu at all time( I was thinking that this would be the BS2 that I would download the data to, then have it send out the on/off data to the other slave BS2's)
    2. BOE board
    3. 3 BS2 modules
    4. my matrix consists of 36 120v realys with a control voltage of 4-32v connected to 36 120v halogen lights
    Thanks for any reply,
    Lane
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-11-02 19:56
    Hmm. Halogen lights, hmm?

    I believe this is doable. You'll probably need the Darlington Array IC's, to provide enough current to drive the relays. And you could use fewer BS2's if you used 74HCT595 serial to parallel converters to provide the 'on-off' bits for the darlingtons. I'm not sure how fast you can turn on and off a halogen light, though, I thought they needed some 'heat-up' time.

    The code is fairly simple. You'll still need the DATA statements in your VB program (or whatever you run on your PC). The BS2 code then just recieves the bytes, and sends them out the I/O pins.

    Attached is a simple example of how to use VB to interface with the BS2 -- including a simple BS2 program to interface to VB.
  • JimDandyJimDandy Posts: 4
    edited 2005-11-02 20:52
    I did get darlignton arrays, and the halogen bulbs are mini's but you are correct when you say that they may take a little warm up time. I am going to use it to melt a polymer so it will take some time studies for the correct time that each bulb is to be on.
    I will take a look at what you sent me thatnk you so much for the quick response AllanLane5
    Lane
Sign In or Register to comment.