Component: Formula AllCode API (AllCode)
Author | Matrix Ltd |
Version | 1.2 |
Category | AllCode |
Contents
- 1 Formula AllCode API component
- 2 Component Source Code
- 3 Detailed description
- 4 Examples
- 5 Macro reference
- 5.1 PlayNote
- 5.2 LEDOn
- 5.3 LCDPrintString
- 5.4 ReadLight
- 5.5 Right
- 5.6 SetLogoSpeed
- 5.7 ReadAllSensors
- 5.8 SampleMag
- 5.9 CardCreate
- 5.10 LCDPrintNumber
- 5.11 LEDOff
- 5.12 LEDWrite
- 5.13 ReadAxis
- 5.14 ServoSetAutoMoveSpeed
- 5.15 CardPlayback
- 5.16 ReadMic
- 5.17 ReadSwitch
- 5.18 SampleAccel
- 5.19 Left
- 5.20 ReadIR
- 5.21 LCDDrawPixel
- 5.22 ServoSetPosition
- 5.23 CardBitmap
- 5.24 CardRecordMic
- 5.25 CardOpen
- 5.26 Forwards
- 5.27 ReadBearing
- 5.28 GetConsoleHandle
- 5.29 LCDDrawLine
- 5.30 ServoAutoMoveToPosition
- 5.31 ReadAllValue
- 5.32 LCDBacklight
- 5.33 LCDDrawRect
- 5.34 ReadLine
- 5.35 ServoDisable
- 5.36 ServoEnable
- 5.37 CardReadByte
- 5.38 CardErase
- 5.39 CardWriteByte
- 5.40 EncoderRead
- 5.41 SetMotors
- 5.42 Backwards
- 5.43 EncoderReset
- 5.44 LCDVerbose
- 5.45 SetProp
- 5.46 CardInit
- 5.47 GetProp
- 5.48 LCDClear
- 6 Property reference
Formula AllCode API component
A simulation only component to allow the Formula AllCode robot to be controlled via it's API interface and Bluetooth data connection without having to compile or re-program the robot.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_FormulaAllCode_API.fcsx
Please click here to view the component source code (Beta): FC_Comp_Source_FormulaAllCode_API.fcsx
Detailed description
No detailed description exists yet for this component
Examples
The COM port for the Formula AllCode can be set via the panel properties which can be exposed to the SCADA runtime user.
LED Control
Controls the LEDs on the Formula AllCode by collecting the analogue value of a potentiometer on the simulation panel and sending the value to the robot.
Motor Control Using Keypad
Uses the keypad on the simulation panel to control the speed and direction of the motors. Key 2 drives the robot forwards, 8 drives backwards, 4 and 6 turn the robot on the spot.
Motor Control Using Joystick
A simple example showing how to drive the Formula AllCode robot around in API mode using a panel based joystick control.
Proximity Alarm
Reads the front IR sensor on the Formula AllCode from the Flowcode simulation. If a near object is sensed then the Flowcode simulation will speak the word "Hello" using the Speech component.
Driving Simulation using the API component
An example showing how to use the API component to drive the Formula AllCode robot component on the simulation panel.
JCB Bot Blog
Blog with example code showing how to drive the Formula AllCode robot using Key Mappings and how to add extra features such as a 3D printed cover and servo motors to operate a digger arm and bucket.
Macro reference
PlayNote
![]() |
PlayNote |
Plays a note using the speaker on the FA | |
![]() |
Note |
Range 1 to 65535 in Hz | |
![]() |
Delay |
Number of milliseconds to play the note for | |
![]() |
Return |
LEDOn
![]() |
LEDOn |
Sets a single LED 0-7 | |
![]() |
index |
Range: 0-7 | |
![]() |
Return |
LCDPrintString
![]() |
LCDPrintString |
Prints a string to the LCD | |
![]() |
X |
X Pixel 0-127 | |
![]() |
Y |
LCD Y Coordinate 0-31 | |
![]() |
Data |
![]() |
Return |
ReadLight
![]() |
ReadLight |
Reads the light sensor 0-4095 - 4095 = Max Brightness | |
![]() |
Return |
Right
![]() |
Right |
Rotates the robot right - waits for the angle to be traversed before returning | |
![]() |
Angle |
Angle to turn in degrees | |
![]() |
Return |
SetLogoSpeed
![]() |
SetLogoSpeed |
Sets the speed of logo movements | |
![]() |
Speed |
Logo Speed 1-100 - Default 40 | |
![]() |
Return |
ReadAllSensors
![]() |
ReadAllSensors |
Samples all of the robot's sensors at once, storing the values locally | |
![]() |
Return |
SampleMag
![]() |
SampleMag |
Samples the magnetometer 0 = no new data, 1 = new data available | |
![]() |
Return |
CardCreate
![]() |
CardCreate |
Attempts to create a file on the SD card 255=Error, 1=File Already Exists, 0=Create OK | |
![]() |
Filename |
![]() |
Return |
LCDPrintNumber
![]() |
LCDPrintNumber |
Prints a 16-bit signed number to the LCD | |
![]() |
X |
X Pixel 0-127 | |
![]() |
Y |
LCD Y coordinate 0-31 | |
![]() |
Number |
Range -32768 to 32767 | |
![]() |
Return |
LEDOff
![]() |
LEDOff |
Clears a single LED 0-7 | |
![]() |
index |
Range: 0-7 | |
![]() |
Return |
LEDWrite
![]() |
LEDWrite |
Sets the value of the LEDs as an 8-bit output | |
![]() |
Value |
LED value 0=All Off, 255 = All On | |
![]() |
Return |
ReadAxis
![]() |
ReadAxis |
Reads a single X/Y/Z axis from the accelerometer sensor. | |
![]() |
index |
0=X, 1=Y, 2=Z | |
![]() |
Return |
ServoSetAutoMoveSpeed
![]() |
ServoSetAutoMoveSpeed |
Changes the speed of the auto movements Default - 1 | |
![]() |
Speed |
Range 1-50 | |
![]() |
Return |
CardPlayback
![]() |
CardPlayback |
Plays back a .Wav file audio stream from the card | |
![]() |
Filename |
![]() |
Return |
ReadMic
![]() |
ReadMic |
Reads the microphone sensor 0 - 4095 | |
![]() |
Return |
ReadSwitch
![]() |
ReadSwitch |
Read the switch value | |
![]() |
index |
0 (left) or 1 (right) | |
![]() |
Return |
SampleAccel
![]() |
SampleAccel |
Samples the accelerometer 0 = no new data, 1 = new data available | |
![]() |
Return |
Left
![]() |
Left |
Rotates the robot left - waits for the angle to be traversed before returning | |
![]() |
Angle |
Angle to turn in degrees | |
![]() |
Return |
ReadIR
LCDDrawPixel
![]() |
LCDDrawPixel |
Allows a single pixel on the LCD to be set or cleared | |
![]() |
X |
X Pixel 0-127 | |
![]() |
Y |
Y Pixel 0-31 | |
![]() |
State |
0=White (Off), 1=Black (On) | |
![]() |
Return |
ServoSetPosition
![]() |
ServoSetPosition |
Allows one of the servo positions to be assigned | |
![]() |
Channel |
Range 0-3 | |
![]() |
Position |
Range 0-255 | |
![]() |
Return |
CardBitmap
![]() |
CardBitmap |
Displays a monochrome bitmap read from the card on the LCD | |
![]() |
X |
Range 0-127 | |
![]() |
Y |
Range 0-31 | |
![]() |
Filename |
![]() |
Return |
CardRecordMic
CardOpen
![]() |
CardOpen |
Attempts to open an existing file on the SD card 255=Error, 1=File not found, 0=Open OK | |
![]() |
Filename |
![]() |
Return |
Forwards
![]() |
Forwards |
Drives the robot forwards - waits for the distance to be traversed before returning | |
![]() |
Distance |
Distance in mm | |
![]() |
Return |
ReadBearing
![]() |
ReadBearing |
Reads the compass bearing based on the degrees clockwise from magnetic north. | |
![]() |
Return |
GetConsoleHandle
![]() |
GetConsoleHandle |
Gets the handle to the console allowing data displaying on the panel etc. | |
![]() |
Return |
LCDDrawLine
![]() |
LCDDrawLine |
Allows a single pixel width line to be drawn on the LCD | |
![]() |
X1 |
X Pixel 0-127 | |
![]() |
Y1 |
Y Pixel 0-31 | |
![]() |
X2 |
X Pixel 0-127 | |
![]() |
Y2 |
Y Pixel 0-31 | |
![]() |
Return |
ServoAutoMoveToPosition
![]() |
ServoAutoMoveToPosition |
Allows one of the servo positions to move gradually to a new position | |
![]() |
Channel |
Range 0-3 | |
![]() |
Position |
Range 0-255 | |
![]() |
Return |
ReadAllValue
![]() |
ReadAllValue |
Reads a single value stored from the read all command Index dictates which sensor value to read | |
![]() |
Index |
0=SW, 1-8=IR, 9-10=Line, 11=Light, 12=Mic, 13-15=Accel | |
![]() |
Return |
LCDBacklight
![]() |
LCDBacklight |
Allows the LCD backlight brighntess to be adjusted | |
![]() |
Intensity |
Range 0-100, 0=Off, 1=Min Brightness, 100=Max Brightness | |
![]() |
Return |
LCDDrawRect
![]() |
LCDDrawRect |
Allows a rectangle to be drawn on the LCD | |
![]() |
X1 |
X Pixel 0-127 | |
![]() |
Y1 |
Y Pixel 0-31 | |
![]() |
X2 |
X Pixel 0-127 | |
![]() |
Y2 |
Y Pixel 0-31 | |
![]() |
Return |
ReadLine
![]() |
ReadLine |
Reads one of the IR line sensors 0-1 0=Left, 1=Right | |
![]() |
index |
0=Left, 1=Right | |
![]() |
Return |
ServoDisable
![]() |
ServoDisable |
Allows one of the servo outputs 0-3 to be disabled | |
![]() |
Channel |
Range 0-3 | |
![]() |
Return |
ServoEnable
![]() |
ServoEnable |
Allows one of the servo outputs 0-3 to be enabled | |
![]() |
Channel |
Range 0-3 | |
![]() |
Return |
CardReadByte
![]() |
CardReadByte |
Reads a byte from the currently open file. Starts at the beginning of the file and auto increments to the end | |
![]() |
Return |
CardErase
![]() |
CardErase |
Attempts to delete an existing file on the SD card 255=Error, 1=File not found, 0=Delete OK | |
![]() |
Filename |
![]() |
Return |
CardWriteByte
![]() |
CardWriteByte |
Appends a byte to the end of the currently open file | |
![]() |
Data |
![]() |
Return |
EncoderRead
![]() |
EncoderRead |
Reads one of the motor encoder counters. Approx 0.328296mm of travel per encoder unit. | |
![]() |
index |
0=Left, 1=Right | |
![]() |
Return |
SetMotors
![]() |
SetMotors |
Sets the motor speeds without feedback Range -100 to 100 | |
![]() |
Left |
Range -100 to 100 | |
![]() |
Right |
Range -100 to 100 | |
![]() |
Return |
Backwards
![]() |
Backwards |
Drives the robot backwards - waits for the distance to be traversed before returning | |
![]() |
Distance |
Distance in mm | |
![]() |
Return |
EncoderReset
![]() |
EncoderReset |
Resets the motor encoder counters | |
![]() |
Return |
LCDVerbose
![]() |
LCDVerbose |
Allows the LCD to automatically report the API commands as they get processed. Default - verbose on | |
![]() |
State |
0=Off 1=On | |
![]() |
Return |
SetProp
![]() |
SetProp |
Allows the COM port property to be set from a parent component. | |
![]() |
PropName |
![]() |
PropVal |
![]() |
Return |
CardInit
![]() |
CardInit |
Attempts to startup the SD card 255=No Card, 254=Init Fail, 0=Init OK | |
![]() |
Return |
GetProp
![]() |
GetProp |
Allows the property filter for the COM port list to be copied to a parent component. | |
![]() |
PropName |
![]() |
Return |
LCDClear
![]() |
LCDClear |
Clears the LCD | |
![]() |
Return |