Let's Make Robots!

bluetooth com and processing language rig

These are the source files related to the setup I mentioned in CTC's post about wireless serial com.

 

Reposting info on the setup just for ref.

Alrighty, ctc, got the rig working. The setup is the following:

<ir beacon> transmitting byte sequence from 1-9

<relay station> picaxe 8m with ir receiver showing correct data in the debug window.

Transmitting the byte sequence received from ir beacon via bt to my desktop running the processing code.

I'll post  source code  for all three components(irb, picaxe relay station, processing code) in a bit.

Just a note, the shot below was active and transmitting the number sequence(from the beacon) out through the bt(note green connect led on the bt device)  :D

 

 pa8M_bluetooth.jpg

 

The code is pretty simple and contains some not so cleaned up stuff...I tried to keep notes in the code for easy understanding of what I did. If you have any questions please feel free to ask. Updates to the code are welcomed as well.  :D

 I mentioned this a while back but didn't think too much about it for the community, but what do people think about setting up a global file repo that everyone can access, download and update. Just a thought.

AttachmentSize
sketch_picaxe_bluetoothtest.pde1.17 KB
bt_test.bas1.11 KB
38KHZ_CODE2.BAS3.01 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
I can't really understand the pulsout you are sending before doing the SEROUT. What do you mean by cooldown period?
The receiver is triggered(via interrupt) by the pulsout and starts it's read sequence from this point. To make sure that the receiver is set and ready to read in data , I give it a short cooldown period before the datasend.
Ah ok! I am using the same setup on my project, just didn't get what the cooldown time was for. Thanks!

This is the updated block that replaces getirin2

getirin3:
    {
    'do serin after int subprocedure redirect..
    serin 2, t1200_8, b0
    'SEROUT TX,T4800_8,(b0)
    if b0 is "S" then{
        do  
            if b0 is "S" then{
            SEROUT TX,T4800_8,(b0)
            'SEROUT TX,T4800_8,(10)
            else
            SEROUT TX,T4800_8,(b0)
            endif
        serin 2, t1200_8, b0
   'debug
    loop until b0 is "E"
    SEROUT TX,T4800_8,(b0)'this should send the E
    SEROUT TX,T4800_8,(10)
    }endif
   
    'debug
    'gosub transmit_bt
    'debug
    'b2 = b2 + 1
    'pause 30
    return
    }
 

this is a test function that replaces the com_2_pwmc function from the 38khz file

com_2_pwmd:'this sub is a mod of pwmb that loops through a count.
    {
      'send the first pulse out to get the attention of the reciever.s
     'high collector ' set the transistors collector high.
      pwmout collector,F,FP       
        {high Tbase
        pause 10
        low Tbase
        pause 200 'give a cool down period for the ir rec.
        }
        'set 1
        SEROUT Tbase,n1200_4,("S")'uses active low sig
        pause delay
        SEROUT Tbase,n1200_4,(34)
        pause delay_b
        SEROUT Tbase,n1200_4,(44)
        pause delay_b
        SEROUT Tbase,n1200_4,(66)
        pause delay_b
        SEROUT Tbase,n1200_4,(55)
        pause delay_b       
        SEROUT Tbase,n1200_4,("E")
        pause 1255

        {high Tbase
        pause 10
        low Tbase
        pause 200 'give a cool down period for the ir rec.
        }
       
        'set 2
        SEROUT Tbase,n1200_4,("S")'uses active low sig
        pause delay
        SEROUT Tbase,n1200_4,(15)
        pause delay_b
        SEROUT Tbase,n1200_4,(16)
        pause delay_b
        SEROUT Tbase,n1200_4,(23)
        pause delay_b
        SEROUT Tbase,n1200_4,(42)
        pause delay_b
        SEROUT Tbase,n1200_4,("E")
        pause 1000       
       
        'SEROUT Tbase,n1200_4,(b2)
        pwmout collector,0,1
        pause 55

i can have a look if you want.
I posted the updated code/function on ctc's post, but I'll post the updated basic here.

I am playing with the same sample code for my little tests.

Question: (With the same sample code) I am trying to switch from sending the incoming data out as text but instead using 4 bytes to then draw a line. As of now, I am trying to get the "instring" into an array so I can then use the 4 seperate bytes in to draw the line. --Any thoughts? Is this the way to go? 

One thing that I was thinking of doing was making a radar sweep anim, so the way I was going to do it was use a char var say x then send the value, then y and send the value

in basic something like

symbol startbyte = s

symbol endbyte = e

serout startbyte

serout "x",b0

serout "y",b1

serout "u" , b2

serout"v" , b3

In processing you'd want to do the following

look for the startbyte and discard everything else until you get it

match() the first char, and put the value in an array for each coord

use the values in the array to draw the line.