Page 1 of 1

FA Remote Control From E-blocks EB006 + EB024

Posted: Thu Apr 14, 2016 11:59 am
by Benj
Hello,

I have been asked to create an example of using E-blocks to control the Formula AllCode robot via it's Bluetooth API so I thought I would share it here just in case anyone else wants to do this.

To do this I used the following E-blocks setup.

EB006 (PIC Programmer) - 16F1937 chip
EB005 (LCD) - PortB
EB024 (Bluetooth) - PortC - Jumpers B & 1
EB014 (Keypad) - PortD

Firstly I added a few additional functions to our Bluetooth v2 component to simplify the process and resolve a bug we came across. To add this component to your v6 installation simply copy the file to your "Flowcode 6/components" directory.
Bluetooth2.fcpx
(13.72 KiB) Downloaded 681 times
The first example simply scans for Bluetooth devices and prints the Bluetooth Address and friendly name to a LCD E-block connected to PortB. Send this program to the EB006, switch on the Formula AllCode device you wish to control and write down the address. It should be a 12 digit hexadecimal string similar to 00BA55571F8A – The address of one of the FA units here.
EB024_Formula_AllCode_Scan.fcfx
(8.24 KiB) Downloaded 657 times
The second example shows you how to connect to a Formula AllCode robot and control it using the built in API. This example will need to be edited with the address found from the scanning program. In this program I use the keypad E-block connected to PortD to drive the Formula AllCode around. Holding 2 or 8 drives the robot backwards or forwards. Holding 4 or 6 turns the robot left or right. Releasing the keypad stops the robot.
EB024_Formula_AllCode_Control.fcfx
(11.04 KiB) Downloaded 675 times
Enjoy :D

Re: FA Remote Control From E-blocks EB006 + EB024

Posted: Tue May 02, 2017 10:07 pm
by joubertmorne
I have the exact same setup and managed to connect and control my FAC using your scripts. Now I am required to read a light value from the LDR on the FAC and set it as a variable. I send the script "Readlight" to the FAC but I can't seem to use the returned value as a variable. This has troubled me all day... Could you please help?

Re: FA Remote Control From E-blocks EB006 + EB024

Posted: Wed May 03, 2017 11:26 am
by joubertmorne
We have been tasked to control the Formula allcode (API mode) via a combination of the EB006 Programmer and a bluetooth card (EB024). When the LDR detects a laser ( Value of +/-3400 ), the buggy should be immobilised for a set time. To do this we need to return a value and attach it to a variable which then could be added to the logic in our program. We have tried various ways of getting this value back to the EB006 but had no luck. Could anyone assist us in this matter?

Re: FA Remote Control From E-blocks EB006 + EB024

Posted: Fri May 05, 2017 11:38 am
by Benj
The ReadString function will require you to use a string variable to store the incoming value from the AllCode robot.

The StringToInt$() command will allow you to convert the string variable to a numeric binary value.

The attached example program shows what I mean.

Also please note that the command to read the light sensor should be “ReadLight” and not “ReadLDR”.
FA_BT_Demo.fcfx
(8.81 KiB) Downloaded 378 times
The easiest way to fire the laser might be to use one of the LED outputs.

You can control the LED output state using the API commands.

You will need an NPN transistor to amplify the voltage from 3V3 to 5V but this will also provide you with more current to drive the laser. Don’t forget the NPN series base resistor, 1K should be fine.

Hope this helps.