Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Communications — Parallax Forums

BS2 Communications

In your opinion, what is the best way to use BS2 unit #1 to send decimal data words (0-123) to a second BS2 unit #2?

Sincerely,
Discovery

Comments

  • How fast do you have to go?
    How far?
    How many pins can you spend?
  • The first BS2 reads temperature and computes the value for the pulse ON time ranging from 0 ms to 500 ms. Temperature is read once a minute. This value must be sent to a second BS2 about two inches away where the value is read every 500 ms. This forms a pulse-width modulated 120 vac drive to an AC fan motor. The update pulse ON time is read during the pulse OFF time. The 500 ms ON/OFF wave form is generated in a DO/LOOP in the second BS2.

    Discovery
  • How many pins can you spend?

  • 14

    Discovery
  • No actually 13 would be max.

    Discovery
  • If the range is 0-123, you can just use seven pins in parallel. BS-2 unit #1 puts the value on the bus whenever it changes and BS-2 unit #2 reads it whenever it likes. I might wanna read it twice to be sure it is valid in case BS-2 pins have different transition times, but then I'm pretty much a defensive driver.
  • Our two minds were on the same page. This is what I sketched out on paper:

    BS2 unit #1
    'I/O Descriptions
    P0 is a ReadDataReady signal Output
    P1 through P8 are binary outputs designated A1 through A8


    BS2 unit #2
    'I/O Descriptions
    P0 is ReadDataReady from unit #1
    P1 through P8 are the binary data from unit #1(A1 though A8)

    'Variables
    PulseOut VAR Word
    PulseWidth VAR Word
    Period VAR Word
    B VAR Word
    C VAR Word

    Main:
    B=%00000001
    Period = 500 'milliseconds

    DO
    HIGH PulseOut
    PAUSE PulseWidth
    LOW PulseOut
    PAUSE Period-PulseWidth
    IF ReadDataReady = 1 THEN
    PulseWidth = DEC (A1*B+A2*B<<1+A3*B<<2+A4*B<<3+A5*B<<4+A6*B<<5+A7*B<<6+A8*B<<7)
    ENDIF
    LOOP
    END

    Is this what you had in mind?

    Sincerely,

    Discovery
  • Um, I would right-align the data pattern: Use P7..P0 for the eight-bit data bus. Just seems cleaner and you can use INL or whatever the syntax is for that bunch of inputs (and outputs for that matter).

    And, if BS-2 unit 1 is always outputting valid data, you don't really need a ReadDataReady signal (but it couldn't hurt; you could make it inactive when changing values).

    and I have no idea what
    PulseWidth = DEC (A1*B+A2*B<<1+A3*B<<2+A4*B<<3+A5*B<<4+A6*B<<5+A7*B<<6+A8*B<<7)
    
    is doing, but, hey, if it gets the right answer...
  • That PulseWidth expression converts the bits from unit #1 into a binary word but the DEC formatter would not compile. I need to find a fast simple way to convert PulseWidth into decimal so the DO/LOOP will work.

    Discovery
  • Why do you need to convert to decimal? PAUSE expects a binary value.
  • Not on the programs that I write. PAUSE 100 will pause for 100 milliseconds decimal.

    Discovery
  • kwinnkwinn Posts: 8,697
    Using a 7/8 pin parallel connection for updating a one byte value twice per second seems like a bit of overkill. A shared ground and one pin would allow you to send 8 bits of data serially at about 15 times that rate using 300baud. Even Basic subroutines should be able to handle the 2 byte per second needed.
  • kwinn wrote: »
    Using a 7/8 pin parallel connection for updating a one byte value twice per second seems like a bit of overkill. A shared ground and one pin would allow you to send 8 bits of data serially at about 15 times that rate using 300baud. Even Basic subroutines should be able to handle the 2 byte per second needed.

    Not sure I buy that. Got the pins to spend, why not spend them? Guaranteed no synchronization problems.

    What's prob'ly overkill is using two BS-2s.
  • kwinn wrote: »
    Using a 7/8 pin parallel connection for updating a one byte value twice per second seems like a bit of overkill. A shared ground and one pin would allow you to send 8 bits of data serially at about 15 times that rate using 300baud. Even Basic subroutines should be able to handle the 2 byte per second needed.

    Not sure I buy that. Got the pins to spend, why not spend them? Guaranteed no synchronization problems.

    What's prob'ly overkill is using two BS-2s.

    no, not overkill, we have to support Parallax...

    Enjoy!

    Mike
  • I got it functioning. I use a single pass decimal to binary conversion technique that sets eight I/O pins in binary at the end of the pass. These eight I/O pins are read by the second BS2 and represent the width of the pulse from 0 milliseconds to 500 milliseconds. This provides for temperature measurement using a one-wire remote sensor with the BS2p and a control loop that adjusts the air flow using exhaust fans. The BS2p and BS2 team-up very nicely.

    Sincerely,

    Discovery
  • kwinnkwinn Posts: 8,697
    kwinn wrote: »
    Using a 7/8 pin parallel connection for updating a one byte value twice per second seems like a bit of overkill. A shared ground and one pin would allow you to send 8 bits of data serially at about 15 times that rate using 300baud. Even Basic subroutines should be able to handle the 2 byte per second needed.

    Not sure I buy that. Got the pins to spend, why not spend them? Guaranteed no synchronization problems.

    What's prob'ly overkill is using two BS-2s.

    Having the pins to spare and guaranteed sync are valid points, although that is not really much of an issue for serial either. I suppose it's just my urge to be as thrifty as possible with the hardware when software is an option.

    Must admit that I wondered why you used a second BS-2, but assumed it was either lack of speed or memory.
  • The reason for the second BS2 is to provide a very stable Pulse Width generation circuit. The motor control is formed using a DO/LOOP that forms a pulse that ranges from zero to 500 milliseconds. The second BS2 reads the binary number that represents the width of the pulse and repeatedly sends out the pulse every 500 milliseconds. If this circuit code was installed in the BS2p with all the other one-wire read, calculations, decimal to binary conversions, and necessary pauses...the Pulse Width would not be stable. As it is now functioning the fan motor can run as slowly as a few revolutions per minute up to full speed. 120 VAC is pulsed to the motor using an electronic switch. This produces very smooth rotary motion.

    Discovery

    PS If there is a simpler and better method for sending digital data, actually 9-bits, I would like to evaluate it before I commit this design to PCB manufacturing.

  • Well, the obvious answer is one word: FLiP

    That said, is the period BETWEEN pulses really critical or just the pulse width itself? That is, is there anything magic about the 500 millisec? If not, if you can stand a few millisec uncertainty between pulses, you could surely live with a single processor.

    If the period is critical, you could have an external 2 HZ pulse generator to control the pulse reputation rate (I HATE autocorrect so much).

    But you really ought to have a look at FLiP. It could solve your problem with 6 cogs and about 25 pins tied behind it's back.
  • Discovery,

    As tomcrawford mentioned, this would be a perfect case for using a Propeller.

    What is your fan controlling that you need such precise timing?
  • I use the Propeller on many other projects but on this project I have experience using the one-wire devices for reading temperature and other variables. I don't have experience with the Propeller reading and writing one-wire devices. So, the breadboard works perfectly and the art work will be submitted for commercial manufacturing.

    Sincerely,

    Discovery
Sign In or Register to comment.