bluetooth eblock connection

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

stephenmccarthy
Flowcode V4 User
Posts: 36
Joined: Tue Mar 01, 2011 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: bluetooth eblock connection

Post by stephenmccarthy »

Hi,
David thanks for sorting out this thread for me,

Ben thanks for the reply,
I am just wondering that if for what i want to accomplish should I have to fiddle with the AT commands in the bluetooth macro as I am able to connect my code to hyperterm but hyperterm has never responded to commands, like AT returning OK?

Thanks
Stephen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bluetooth eblock connection

Post by Benj »

Hello,

I'm not sure if you can send AT commands via the wireless. Eg via hyperterminal. Have you tried connecting to the other COM port that is provided when installing the remote bluetooth device.

stephenmccarthy
Flowcode V4 User
Posts: 36
Joined: Tue Mar 01, 2011 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: bluetooth eblock connection

Post by stephenmccarthy »

Hi Ben,

Yes I tried the other COM port it connects, but i dont think to the bluetooth component as the LED on the component does not light.
The first thing i done to my code was include a bluetooth initilize command, followed by send script 1. It works it allowed a conection.
Funnnily enough i just threw in a creat command and a send command loaded both with the same value and compiled to the chip to see if hyperterminal would react. It did. With a smiley face.. So atleast I know its capable of getting some reaction to my code.
I am just wondering now for the send command should the bExpectEcho(BYTE) value be the same as the bExpectCR(BYTE) value?
I had a look at some example programs but thry mainly seem to be using strings.
Thanks
Stephen

stephenmccarthy
Flowcode V4 User
Posts: 36
Joined: Tue Mar 01, 2011 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: bluetooth eblock connection

Post by stephenmccarthy »

Hi Ben,

I have a set up the Bluetooth and i can now communicate with hyperterm i can send a message to hyper term saying ""YOUR_HEART_RATE=" followed by the BPM value, the problem is instead of printing a number it prints a symbol i.e instead of "YOUR_HEART_RATE=6" it prints "!", any idea on how i can fix this, i am sending the BPM value as a byte, but it is the same case when i send as an int?

Thanks
Stephen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bluetooth eblock connection

Post by Benj »

Hello Stephen,

Ok here you will need to convert your numeric byte into a string representing the number you wish to send.

On the PIC you can do this using the string manipulation icon and the ToString function. You would then simply send the string over the bluetooth rather then the byte variable.

stephenmccarthy
Flowcode V4 User
Posts: 36
Joined: Tue Mar 01, 2011 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: bluetooth eblock connection

Post by stephenmccarthy »

Hi Ben,

Thanks for the reply, I have converted my value to a string, however i cannot find parameter in the bluetooth macro that accepts strings? Am i missing something?
As far as I know string receive and string send is the correct way too send strings.

Thanks,
Stephen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bluetooth eblock connection

Post by Benj »

Hello,

Ah yes you are correct you can only send a byte at a time using the Bluetooth component.

In this cas eyou will have to convert the number to a string as detailed previously and then output the string to the Bluetooth a byte at a time.

To do this you simply create two byte variables, one to hold the length of the string and the other to hold the current position in the string.

To read the string length use the length function available from the string manipulation icon.

Once you have the string length initialise your position variable to 0 and then enter a loop while position < length.

Inside the loop to send a byte from the string you can use this syntax.

string[position]

then increment the position byte.

position = position + 1

stephenmccarthy
Flowcode V4 User
Posts: 36
Joined: Tue Mar 01, 2011 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: bluetooth eblock connection

Post by stephenmccarthy »

Hi Ben,

I just seen your reply, I actually tried somnething similar to what you outlined , last night, But I was not succesful. I even tried shouting at it...... this didnt work either :)
I noticed the bluetooth is very sensitive to the send command if i set it up in a way it dosent like it will refuse to connect to hyperterminal atall,

I just tried implementing your idea but I dont think I have it quiet right, could you please view the attached code and let me know what corrections I need to make?

Thanks
Stephen
Attachments
smc_FYP_18F488.fcf
(17 KiB) Downloaded 317 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bluetooth eblock connection

Post by Benj »

Hello Stephen,

I have made amendments to your file and it should work correctly now.
Attachments
smc_FYP_18F488.fcf
(17 KiB) Downloaded 321 times

stephenmccarthy
Flowcode V4 User
Posts: 36
Joined: Tue Mar 01, 2011 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: bluetooth eblock connection

Post by stephenmccarthy »

Hi Ben

Thanks yet again for another quick reply,
I just downloaded your updated code and cleaned up the send command and now it works.
Thanks very much for your time, there is no way I would have managed to get the bluetooth component working with your help,
I will keep this thread up to date on the progress of this project over the coming weeks,

Thanks again!!
Stephen

Post Reply