BS2 Communications
Discovery
Posts: 606
in BASIC Stamp
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
Sincerely,
Discovery
Comments
How far?
How many pins can you spend?
Discovery
Discovery
Discovery
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
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 is doing, but, hey, if it gets the right answer...
Discovery
Discovery
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
Sincerely,
Discovery
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.
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.
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.
As tomcrawford mentioned, this would be a perfect case for using a Propeller.
What is your fan controlling that you need such precise timing?
Sincerely,
Discovery