'------------------------------------------------------------------ 'co_talk.bas 5/18/00 Arrick Robotics www.robotics.com ' 'This program illistrates how to talk to the coprocessor using 'a bx-24 as the master processor. The bx-24 com protocal is a 'little more tricky. This program will tell the coprocessor to 'turn on the drive motor. It will then wait for the Ack signal from 'the coprocessor. When it receives this signal the green led on the 'bx-24 will come on. ' '------------------------------------------------------------------ '------------------------------------------------------------------------------- public char as byte public test as string '------------------------------------------------------------------------------- sub main() dim outbuffer(1 To 40) as byte 'define buffers. dim inbuffer(1 To 40) as byte call openqueue(outbuffer, 40) 'open buffers. call openqueue(inbuffer, 40) call definecom3(13,13,bx0000_1000) 'define com port. call opencom(3, 2400, inbuffer, outbuffer) 'open com port. call freqout(14,1500,1500,200) 'signify reset. call freqout(14,1500,1500,200) call putpin(26,1) 'turn on red led, turn off green led. call putpin(25,0) test="!1M11700E7" 'string to turn motor. call putqueuestr(outbuffer, test) 'output string to coprocessor. 'now we must read the input buffer for the Ack signal from the coprocessor. 'we must first flush the buffer before we get the Ack signal. 'this is because the buffer contains the command tht was sent out. call getqueue(inbuffer,char,1) 'get char from buffer "!". call getqueue(inbuffer,char,1) 'get char from buffer "1". call getqueue(inbuffer,char,1) 'get char from buffer "M". call getqueue(inbuffer,char,1) 'get char from buffer "1". call getqueue(inbuffer,char,1) 'get char from buffer "1". call getqueue(inbuffer,char,1) 'get char from buffer "7". call getqueue(inbuffer,char,1) 'get char from buffer "0". call getqueue(inbuffer,char,1) 'get char from buffer "0". call getqueue(inbuffer,char,1) 'get char from buffer "E". call getqueue(inbuffer,char,1) 'get char from buffer "7". call getqueue(inbuffer,char,1) 'get char from buffer "A". if char = asc("A") then 'compare char if its "A". call putpin(26,0) 'turn on green led and off red led. call putpin(25,1) 'this signifies that we got the Ack signal. end if end sub