Shop OBEX P1 Docs P2 Docs Learn Events
Prop to BS2 communication — Parallax Forums

Prop to BS2 communication

computer guycomputer guy Posts: 1,113
edited 2007-03-18 06:23 in Propeller 1
How would i send commands to a BS2 from the prop.

i.e. send "10" to the BS2 from the prop.
get the BS2 to receive "10" and do something.

BS2 -

If value = 10
do this
else if value = 11
do this
end if

prop -
send 10

do i need a resistor between the prop and bs2 or any other circuitry.

Thank you smile.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-18 02:48
    1) You do need a resistor between the Propeller I/O pin and a BS2 I/O pin. Read the "sticky thread" on HOW TO SAFELY INTERFACE A 5V SIGNAL TO THE PROPELLER for more information. A 1K to 4.7K should work.

    2) You could use all kinds of ways to get a value from one to the other. On the BS2, use SERIN. On the Propeller, use the FullDuplexSerial driver from the Propeller Tool's library. I recommend using 2400 Baud so the BS2 has a little time to interpret the data as it's received. On the Prop end, if you declare "FullDuplexSerial" as "ser", you'd use "ser.dec(10)" then "ser.tx(13)" to provide a return character. On the BS2, use "SERIN <pin>,<Baud>,[noparse][[/noparse]DEC v]" and you should see a value of 10 in the variable v. <pin> is the transmit pin (from the Stamp's perspective) and <Baud> is the appropriate Baud constant for 2400 Baud.

    Do look at the comments for FullDuplexSerial. It talks about the initialization routine call needed. Typically, it would be "ser.start(<recv pin>,<xmit pin>,%0000,2400)" where <recv pin> and <xmit pin> are for receiving and transmitting (from the Propeller's standpoint).

    Post Edited (Mike Green) : 3/18/2007 2:53:27 AM GMT
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 03:22
    So this circuit would be ok then.
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 03:36
    That is a very pricey 7 seg display.
    FAQ said...


    How much current can the I/O pins handle?
    On the BASIC Stamp I and BASIC Stamp II, each I/O pin is capable of sourcing 20 mA and sinking 25 mA. The
    total across all I/O pins should not exceed 40 mA source or 50 mA sink at any given time, however. One
    exception to this rule exists with the BS2-IC. If the BS2-IC is powered by an external 5-volt regulator capable of
    delivering at least 100 mA, the total across each group of 8 I/O pins (0 - 7 and 8 - 15) can reach 40 mA source or
    50 mA sink providing a total of 80 mA source or 100 mA sink overall. The BASIC Stamp IIsx’s I/O pins can
    source and sink 30 mA, and the total across all I/O pins should not exceed 150 mA.
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 03:49
    As i said in a previous post i need a double 7 segment display that is easy to use.
    I have a BS2 laying around that i was going to use for a robot, I am now using a prop though and have no use for the BS2.
    If you can come up with a cheaper way or controlling 2 7 segment displays, without making programming the prop hard (i know nothing about i2c or creating bits of information from a string or decimal).
    Your advise would be great.

    Thank you smile.gif
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-18 03:51
    computer guy,
    The Prop should be happy with the 1K series resistor you've shown. If you make a mistake with the Stamp's program and happen to make P0 a high (+5V) output while the Prop is trying to output a low (0V), the maximum current will be about 5ma ... no sweat for either chip. If P0 is a high output for the Stamp and an input for the Prop, the maximum current through the Prop's protective diode will be 5V-3.3V-0.7V=1V with 1K = 1ma, again no sweat.
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 03:55
    Have you considered the current sourcing limitations on the BS2 as quoted above? The BS2 has limits on how much per side it can source. You at least will need the external supply, even then you are pushing it if all LEDs can be on at a time. The other option is to run it dim.
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 03:59
    Displaying things seams to be hard.

    All i want to do is display numbers on a 2x 7 seg display without using 14 i/o pins on my prop.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-18 04:06
    You could use some I2C I/O expanders that you can attach to the same I/O pins as the boot EEPROM (if you've got a PropStick or Protoboard). The PCA9554 is a really easy to use 8-bit expander with a maximum sink current total of 100ma which will let you drive the LED segments at 14ma. There are existing I/O routines in the Propeller Object Exchange that could be used with a little work.

    The TPIC6595 is an 8-bit high power serial shift register that you could drive from the Prop with only 3 I/O pins and is cascadable. It works like a combination of a 74HC595 and a ULN2803, both well described in Parallax's documentation.

    Post Edited (Mike Green) : 3/18/2007 4:11:57 AM GMT
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 04:18
    PCF8574 said...

    ·Latched outputs with high current drive capability for
    directly driving LEDs

    I already gave him the Eagle library and schematics for this, not sure why the wild goose chase. It can't get simpler than the i2c. The PCF8574 or other option Mike mentioned will sink the LEDS no problem, you don't even need the ULN2803s, just two PCF8574's- 2 wires to the existing EEPROM SCL and SDA, I posted the code already, it is no brainer.
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 04:20
    I just didn't get the example code.

    How would you send i/o pins 1 and 6 high for example.

    Thank you smile.gif
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 04:24
    OBJ
      i2c   :   "minimali2cdriver"     ' THE OBJECT
    
    PUB  SetSomePins
        i2c.start(28)                                  'start the transaction
        i2c.write(28, %0100_000_0 + 0)    '   pin start(28), device type(0100), address(000), write mode(0)
        i2c.write(28, %00100001)              '   pins 1 and 6 high
        i2c.stop(28)
    
    



    This makes pins 1 and 6 high( assuming you are numbering the pins from least sig bit to high). To sink the LEDs in the real world case, you would want to do the opposite logic, LOW pin = LED ON, unless you are using a ULN28xx, in which case keep the logic normal, the HIGH output would TURN ON the transistor, causing the transistor to SINK the LED to GND.

    Post Edited (originator) : 3/18/2007 4:56:40 AM GMT
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 04:32
    Ok i get it now,

    thank you smile.gif
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 04:34
    Mike feels the same way about my slowness
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 05:13
    So this is what you mean.
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 05:33
    no, try this

    set the address according to the 3 address pins on the device, device type = %1011 + address = %001
    785 x 378 - 35K
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 05:34
    What and use 2 of them?
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 05:36
    Yes, just set one address to %001 and the next to %010

    You cannot get the PCF8475 in DIP, only SMT. The 8574 is available in DIP, unless you want another challenge to deal with in soldering SMT parts.
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 05:40
    I don't mind soldering SMT parts.
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 05:48
    Will this work? In your design the leds have their own anode and cathode. 7 seg displays have a shared anode or shared cathode.
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 05:51
    In that case, you can use 1 8575, the datasheet claims high current sinking for LEDs. Use the same circuit as what I just posted, refer back to the original post on this where I linked the code for the 8575, you need two data bytes ALWAYS following the Start byte. Set the pins for the address to maybe %001
    'The start byte contains:   device type  %0100  +   Address %001 + 0(0 =write mode)
    first byte       %1111_1111    'All LEDs off
    second byte   %1101_1110   'LED 1 and 6 on since the chip has provided a GND path to the LED via PIN
    stop          
    
    

    Post Edited (originator) : 3/18/2007 6:02:59 AM GMT
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 05:52
    Either do screen shots and convert to jpg, or reduce those bmps please

    Use common A segments to sink the catchode separely, your eagle library should have each ca and ck you can serach 7 segment and see all the listings partnumber + CA are what you want.

    Post Edited (originator) : 3/18/2007 6:02:07 AM GMT
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 05:57
    So this circuit with this code?

    With the 2x 7 seg display being Common Anode.

    Send output low to give led ground and turn led on.

    'The start byte contains:   device type  %0100  +   Address %001 + 0(0 =write mode)
    first byte       %1111_1111    'All LEDs off
    second byte   %1101_1110   'LED 1 and 6 on sicne the chip has provided a GND path to the LED
    stop
    
    

    Post Edited (computer guy) : 3/18/2007 6:09:41 AM GMT
    606 x 381 - 47K
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 06:12
    That code is just the idea, refer back to my original in your old post( I linked to it) for for the exact version, just edit the data bytes to reflect what you want to do.

    For example, you could set up a seprated methods or case statements for each letter. I don't know how simple or complex your needs are to judge what to do, here is a very simple idea
    OBJ
      i2c   :   "minimali2cdriver"     ' THE OBJECT
    
    
    
    PUB start
           repeat
              makeDecision
    
    
    PUB makeDecision
        If someCondition == true
            Diplay77
        If anotherCondition == true
            Display55
    
    PUB Display77
        i2c.start(28)                                  'start the transaction, below the address pins are shown as %001
        i2c.write(28, %0100_001_0 + 0)    '   pin start(28), device type(0100), address(000), write mode(0)
        i2c.write(28, %11111111)              ' <<figure out what makes 7's, then set these bytes
        i2c.write(28, %11111111)              '<< figure out what makes 7's, then set these bytes
        i2c.stop(28)
    
    
    PUB Display55
        i2c.start(28)                                  'start the transaction
        i2c.write(28, %0100_001_0 + 0)    '   pin start(28), device type(0100), address(000), write mode(0)
        i2c.write(28, %11111111)              '<< figure out what makes 5's, then set these bytes
        i2c.write(28, %11111111)              ' <<figure out what makes 5's, then set these bytes
        i2c.stop(28)
    
    




    I would study this datasheet, remember for future ref, this IC will not source anything unless you use pullups, but it will sink no problem.

    focus.ti.com/lit/ds/symlink/pcf8575.pdf
  • computer guycomputer guy Posts: 1,113
    edited 2007-03-18 06:17
    Thank you. I take it you have to send the state of the first 8 i/o pins and then the second set of i/o pins.

    Thank you smile.gif
  • T ChapT Chap Posts: 4,199
    edited 2007-03-18 06:23
    With this chip, you have to send two data bytes always, since it is a 16 bit i/o device. Never just one. Even if you only want to change one display, you still have to send the other display's data again, which means you have to keep track of what was sent prior, which is easy.


    An example:
    %11111111 'byte 1 = all off
    %10000000 'byte2 = "8"

    You could think of the segments as two separately controlled devices, so that if you know that byte 1 = %10000000 = 8 and byte 2 %11111111 = OFF, you could do a constant table

    CON

    DIS8 = %10000000
    OFF = %11111111

    And in your i2c.write, you now do

    i2c.start
    i2c.write(OFF)
    i2c.write(DIS8)
    i2c.stop

    or something like that

    Also note that you can do one start and any number of data bytes following the start, as long as the data bytes are in pairs, so you could even stream values to the LED segments very rapidly, just keep it always byte1 byte2 byte1 byte2, The stop is not required between the flow of data bytes, only when you are done with the device, you can stop.
    PUB updateSegments
      i2c.start
       repeat 
         i2c.write(byte1)
         i2c.write(byte2)
    
    



    Where byte1 and byte2 are varables being updated elsewhere. If the EEPROM or other I2C device on the same lines need to do something, you have to stop the loop.

    Post Edited (originator) : 3/18/2007 8:13:24 AM GMT
Sign In or Register to comment.