Shop OBEX P1 Docs P2 Docs Learn Events
Send data from bs2 to bs2 — Parallax Forums

Send data from bs2 to bs2

jbalatjbalat Posts: 96
edited 2009-10-01 03:47 in BASIC Stamp
I want one bs2 to do a pulsin and then send this data to a bs2p with a pwmpal so it can generate a frequency..
How easy is this.
Note PWMPal uses P0 to connect with bs2p.

Comments

  • dev/nulldev/null Posts: 381
    edited 2009-09-27 09:20
    This is VERY easy using two wire serial communication. You use two wires, one for data and the other for flow control.
    The SEROUT and SERIN commands have built-in support for flow control.

    Here is the connection diagram.
    attachment.php?attachmentid=64032

    And here is a link to a N&V column no. 4: www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol3/col/nv81.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy

    Post Edited (dev/null) : 9/27/2009 9:26:26 AM GMT
    693 x 465 - 25K
  • jbalatjbalat Posts: 96
    edited 2009-09-28 23:45
    Thanks for the link it was good reading.. I am a little bit scared that because of no buffering I am not going to get what I want.

    --> Q) Is it possible to write the value of 'X' to a shared memory register so the 2 stamps do not need to synchronise with each other.. Keeping in mind that SPEED is my primary concern ???

    All I want is to pulsout the input with a fixed offset.. I cant afford to do a serin unless it is quick enough so that it wont affect the continuous pulse from Stamp2.


    STAMP1:
    ======

    main:
    PULSIN 9, X
    (WRITE X TO REGISTER)
    goto main


    STAMP2: (up to 350 Hz)
    =====

    main:
    (READ X FROM REGISTER)
    PULSOUT 12, X + OFFSET
    goto main


    P.S. Cant use PWMPal since it keeps re-triggering
  • jbalatjbalat Posts: 96
    edited 2009-09-30 11:31
    I assume from the overwhelming response that there is no other way to share data between the 2 stamps ?
  • stamptrolstamptrol Posts: 1,731
    edited 2009-09-30 13:08
    I think the fact that we seem to be talking pulsin, pulsout and serial somewhat interchangeably (which they're not), you might not have gotten across exactly what your concerns are.

    My understanding is that Stamp 1 will receive a pulse. Then, it will transmit a serial command to a BS2p which will then issue a command to the the PWMPAL.

    Can you show us a sketch of the whole setup? How about the code you've written so far?

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • jbalatjbalat Posts: 96
    edited 2009-09-30 13:56
    Stamptrol.. I am still on the same mission trying to modify my maf signal in the car...

    STAMP1(BS2) READ MAF PULSE
    > STORE TIME 'X'
    > LOOP

    STAMP2(BS2P) READ TIME 'X'
    > GENERATE PULSE OUT ('X'+OFFSET) ----> LOOP

    METHOD: Stamp 1 will receive the pulse. I then want to make this value available (asynchronously) to the bs2p which will create a slightly different pulse with pulsout command in a continuous loop.

    AIM: I am just trying to figure out the FASTEST way for the BS2p to get the value from Stamp1 so that you dont see any glitches in the pulse coming out of the BS2p. It does not matter whether Stamp1 has updated the value on every loop for the bs2p.

    NOTES: 1) I dont want to use the PWMPal because it doesnt work properly. Supposedly Pulsout will continue from where it left off but the pwmpal just stops and restarts when it sees a new command.. Anyone want to buy it ?

    2) SERIN/SEROUT seem to be slow because of the lack of buffering ? I just read in another post that writing the data to an external eeprom is very slow...

    QUESTION: Can I write to the BS2p eeprom from Stamp1 ?

    Post Edited (jbalat) : 9/30/2009 2:15:38 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-30 14:07
    What is the range of values you want to send from Stamp 1 to Stamp 2? How many I/O pins are available for this?

    If the values will fit in a byte and you have a block of 8 I/O pins available (pins 0-7 or pins 8-15), you could simply set either OUTH or OUTL to the 8 bit value and read INH or INL on the 2nd Stamp like:

    DIRL = $FF
    main:
    PULSIN 9,OUTL
    GOTO main

    and

    main:
    PULSOUT 12,INL + offset
    GOTO main

    Pins 0-7 of one Stamp would be connected through 8 - 220 Ohm resistors to pins 0-7 of the other Stamp.

    You can't access the EEPROM of one Stamp from another. Theoretically you could, but it's not practical.
  • jbalatjbalat Posts: 96
    edited 2009-09-30 14:16
    Mike,

    I like your thinking.. Dont know if I could convert these values to fall within 1 byte.
    Minimum freq is about 25 Hz - Max is 350Hz

    For 25Hz at 0.8us units for the BS2p, I think the time value may be around 50,000

    I am only using 1 pin on stamp1 - pulsin

    and 2 pins on the stamp2 - rctime for the offset, and pulsout

    Post Edited (jbalat) : 9/30/2009 2:33:52 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-30 14:34
    You really need some kind of buffer between the two Stamps. Unfortunately Stamps are single threaded and can only do one thing at a time. When they're looking for data (like in a SERIN), they can't do anything else. A cheap solution would be to use two 74HC595 shift registers on Stamp 1 to hold a 16 bit number and two 74HC165 shift registers on Stamp 2 to read the 16 bit value from the first set of shift registers. You'd need 3 I/O pins on each Stamp and the transfer would take about 1ms on each Stamp. There are plenty of examples of connections and coding in both the StampWorks manual and in one of the Nuts and Volts columns. You'd use a SHIFTOUT statement to transfer a word to the 74HC595, then a PULSOUT statement to load the output register of the 74HC595. On the receiving end, you'd use a PULSOUT to load the input register of the 74HC165, then a SHIFTIN to transfer a word from the 74HC165.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-30 14:36
    Another option would be to use a BS2p40 for both Stamps. That way you'd have an extra 16 bits of I/O on each Stamp that you could use for Stamp to Stamp transfers of a 16 bit value the same way I described for 8 bits. You'd just need to switch I/O banks using MAINIO and AUXIO and use OUTS and INS for the 16 bits of data.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-30 14:41
    You may run into problems with overflow. Remember that the maximum value on the Stamps for anything is 65535.

    You would really do so much better with a Propeller. It uses 32 bits for its arithmetic and can do at least 8 things simultaneously like reading input pulse widths and producing output pulses.
  • jbalatjbalat Posts: 96
    edited 2009-09-30 14:41
    Thanks Mike, 1 ms should not be an issue between looping pulsout statements I hope..

    I have no idea what a 74HC595 register is but I will have a look for some examples and see if it makes sense

    Propellor also makes more sense than buying another bs2p..or infact 2 bs2p40's. Not quite sure what bits I need for a budget setup ?

    As for overflow, it just occured to me that the pulsin/pulsout only sees/generates half of the pulse so I think the max value would be 25,000

    Post Edited (jbalat) : 9/30/2009 2:48:38 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-30 14:57
    A good cheap starting point would be a USB Propeller Protoboard for $40. If you have a spare VGA display and PS/2 keyboard, get the Accessory Kit. You could use the keyboard and display for adjusting and displaying test parameters. If you have a spare mini-TV, you could wire up a video output with a phono jack and a couple of resistors. You could use the Protoboard's prototype area for whatever interface electronics you need. Put the result into a box and you're done.
  • MoskogMoskog Posts: 554
    edited 2009-09-30 15:56
    Mike Green said...
    ......a Propeller. It uses 32 bits for its arithmetic and can do at least 8 things simultaneously.......
    So, a Propeller is a SHE. They say females can do several things simultaneously.

    And the single threaded Basic Stamp is a male, like myself, I can only do one thing at a time.

    That's what SHE tells me, sometimes, and she is probably right.·
  • jbalatjbalat Posts: 96
    edited 2009-09-30 23:49
    Cool.. So I need a woman to carry out this impossible task of processing high frequency signals in realtime !!! I will stop there before I get into trouble [noparse];)[/noparse]

    Mike is that all I need... the "USB Propeller Protoboard for $40" So I assume I plug in a standard printer USB cable, download the software and start programming ?

    So why did I spend a fortune on the STAMP stuff !! BUGGER #$%

    When I'm finished I will need to boost the output pulse to around 0-4.8v.. since I remember you said it would only output up to 3.5v
    I will worry about this later if my ECU cant see the 3.5v signal
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-01 00:36
    All you need is the Protoboard, a USB cable with a mini-USB plug, and a wall-wart or battery pack that can supply 6-9V. You can probably run the Protoboard directly off a filtered vehicle supply (14V) using a noise filter choke and filter capacitor (a couple of hundred uF at 20V) as long as you don't use more than a couple of hundred mA. The issue is that the regulators only have the PCB for a heatsink so they can't dissipate much power (14V - 5V = 9V x 100mA = 0.9W!) For what you're doing, the current drain should be pretty low.

    There's a long "sticky" thread on interfacing 5V logic to a Propeller. See under "Technical Considerations" here: http://forums.parallax.com/showthread.php?p=791527.

    The new StingRay robot uses a nice 3.3V to 5V bidirectional level translator from TI (the TXB0108). This comes in a 4 bit version as well (TXB0104) and there are similar 2 bit (sn74lvc2t45) and single bit level translators (sn74lvc1t45). For just an output pulse, you could use any switching transistor with a pullup resistor (and a current limiting resistor for the base). You could also use any MOSFET with a gate-source voltage well below 3.3V (and a pullup).

    Remember that the Stamps are very easy to use, have a tremendous amount of educational material developed for them mostly available for free, and do very well for single tasks.

    Post Edited (Mike Green) : 10/1/2009 12:41:42 AM GMT
  • jbalatjbalat Posts: 96
    edited 2009-10-01 03:47
    So the propellor doesnt have commands like pulsin and pulsout ?

    Is it any faster than the bs2p ?

    Post Edited (jbalat) : 10/1/2009 6:52:43 AM GMT
Sign In or Register to comment.