Unable to get Bluetooth to work correctly

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
L_B_312
Posts: 1
Joined: Sat Jun 05, 2021 12:10 am
Has thanked: 1 time

Unable to get Bluetooth to work correctly

Post by L_B_312 »

Hello,

Okay I am a extremely new user to flowcode, and I am working on a project with flowcode v6. The project is a remote location temperature monitor, where in one remote location it records the temperature, and other things, then over bluetooth it feeds some of it's information back to a location to monitor it from also. The problem I'm having is getting the bluetooth to be received on the monitoring end, and displayed however if I try it with the way I'm trying it completely breaks the rest of the code I have done. I am no expert on this as you would see within the coding of all I have done. But if i can get any help on getting the bluetooth to work with the current system I have going it would be massively appreciated.

I tested the bluetooth sending from the remote location, which it seems to be sending completely fine as I ran that along side a clean end which only receives bytes without having any other code inside of it but that. If i try the sticking it into my code it just fails to work at all, and messes with other things, which I have zero clue on what the conflict is.

Anyway if anyone is willing to help I've attached the two sets of code for each PIC and if it helps. The board I'm using is a PIC16F1937 for both boards.
Attachments
Monitor location Non working bluetooth receiving.fcfx
(30.23 KiB) Downloaded 237 times
Remote location sending bluetooth.fcfx
(58.04 KiB) Downloaded 237 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 784
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 186 times
Been thanked: 205 times

Re: Unable to get Bluetooth to work correctly

Post by chipfryer27 »

Hi

Sorry to be brief as I'm traveling.

I see in your Monitor Location's Main Loop you are calling many Macro's, which take time to process, including a Bluetooth Rx Byte. What happens if you receive a byte when your loop is busy elsewhere?

Assuming I've setup whatever comms device I'm using correctly, I usually use an "Interrupt on Rx" (UART RXINT0) when using the UART which I'll call before entering my Main Loop.

If I then receive anything on my comms device, an interrupt is generated and my program immediately jumps to a handling routine. In that routine I'll "Receive Byte" or whatever for further processing in my Main Loop.

Perhaps give that a try?

Regards

chipfryer27
Valued Contributor
Valued Contributor
Posts: 784
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 186 times
Been thanked: 205 times

Re: Unable to get Bluetooth to work correctly

Post by chipfryer27 »

Hi

Another airport another bit of time to kill.

Again sorry to be brief due to travel. Further to previous are you familiar with the Circular Buffer component? If not then you should look it up in the Help / Wiki / Forum pages.

As mentioned earlier, I use an interrupt to detect when I receive, then jump to a handling routine. It is good practice to keep all interrupt routines as short as possible. In the Rx interrupt routine you could for example Rx-byte then immediately store it in the Circular Buffer before exiting the routine.

In the Main loop you can poll the buffer for received bytes and act accordingly. Plenty of examples in the Wiki / Help / Forum pages.

Hope this is of help.

Regards

Post Reply