Component: Formula AllCode (RB4420) (Robotics)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 1.3
Category Robotics


Formula AllCode component

A component to allow all the features of the Formula AllCode robot to be investigated. Fully simulated component which can interact with simulated objects on the panel as well as control the real hardware.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_FA_Source_P4.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_FA_Source_P4.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Line Following

Line following example using the Formula AllCode, works with objects on the simulation panel and on the real hardware.

FC6 Icon.png FA-Line

FALine.jpg


Simulation with the API component

An example showing how to use the API component to drive the robot in simulation.

FC6 Icon.png FA API Sim Demo


Macro reference

AudioAddToBuffer

Fc9-comp-macro.png AudioAddToBuffer
Writes a value to the 16-bit audio output buffer. 
Fc9-u16-icon.png - UINT Data
 
Fc9-void-icon.png - VOID Return


AudioQueueLength

Fc9-comp-macro.png AudioQueueLength
Retreives the current length of valid data within the audio queue 
Fc9-u16-icon.png - UINT Return


AudioReadFromBuffer

Fc9-comp-macro.png AudioReadFromBuffer
Allows the audio buffer to be used for other streaming data such as recording the mic.  
Fc9-u16-icon.png - UINT Return


AudioStreamControl

Fc9-comp-macro.png AudioStreamControl
Allows control of the audio output functionality via the onboard speaker. Data is loaded into the audio output buffer using the AddToBuffer function. 
Fc9-u8-icon.png - BYTE Mode
0=Off, 8=8-bit Mode, 16=16-bit Mode 
Fc9-u8-icon.png - BYTE SampleRate
Sets the sample rate 0=8KHz, 1=16KHz 
Fc9-void-icon.png - VOID Return


BluetoothCheckConnection

Fc9-comp-macro.png BluetoothCheckConnection
Checks the status of the Bluetooth connection. Returns 0 for not paired and 1 for paired. 
Fc9-u8-icon.png - BYTE Return


BluetoothQueueLength

Fc9-comp-macro.png BluetoothQueueLength
Reads the length of received Bluetooth data in bytes.  
Fc9-u16-icon.png - UINT Return


BluetoothReceive

Fc9-comp-macro.png BluetoothReceive
Attempt to read a byte from the Bluetooth receive queue. 
Fc9-u8-icon.png - BYTE Return


BluetoothTransmit

Fc9-comp-macro.png BluetoothTransmit
Sends a byte via the Bluetooth data connection. 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


BluetoothTransmitString

Fc9-comp-macro.png BluetoothTransmitString
Sends a string via the Bluetooth data connection. 
Fc9-string-icon.png - STRING Data
 
Fc9-void-icon.png - VOID Return


CheckIR

Fc9-comp-macro.png CheckIR
Checks to see if a IR sensor is within the master threshold distance. Returns 0 if the IR reading is below the threshold. Returns 1 if the IR reading is greater than or equal to the threshold. 
Fc9-u8-icon.png - BYTE Sensor
Range: 0 to 7 - 0=Left, 1=Front Left, 2=Front, 3=Front Right, 4=Right, 5=Rear Right, 6=Rear, 7=Rear Left 
Fc9-u8-icon.png - BYTE Return


CheckLine

Fc9-comp-macro.png CheckLine
Checks to see if a line sensor is within the master threshold distance. Returns 0 if the IR reading is below the threshold. Returns 1 if the IR reading is greater than or equal to the threshold. 
Fc9-u8-icon.png - BYTE Sensor
Range: 0 to 1 - 0=Left, 1=Right 
Fc9-u8-icon.png - BYTE Return


CheckUSB

Fc9-comp-macro.png CheckUSB
Checks to see if a USB cable is connected to the robot. Returns 0 for no connection and 1 for an active connection. 
Fc9-u8-icon.png - BYTE Return


EncoderReadCount

Fc9-comp-macro.png EncoderReadCount
Reads one of the motor encoder counters. Each encoder count is equal to 0.314159 mm.  
Fc9-u8-icon.png - BYTE Channel
0 = LeftCount, 1=RightCount 
Fc9-u16-icon.png - UINT Return


EncoderReset

Fc9-comp-macro.png EncoderReset
Resets the encoder counters to 0 
Fc9-void-icon.png - VOID Return


Forward

Fc9-comp-macro.png Forward
Drives both motors of the formula flowcode forwards with the power specified.  
Fc9-u8-icon.png - BYTE Power
Amount of power to use to drive motor. Range 0-100 
Fc9-void-icon.png - VOID Return


Initialise

Fc9-comp-macro.png Initialise
Starts up the Formula Allcode PWM for motor control and performs the wait for button press if enabled. 
Fc9-void-icon.png - VOID Return


LCDBacklight

Fc9-comp-macro.png LCDBacklight
Controls the brighness of the LCD backlight 
Fc9-u8-icon.png - BYTE Brightness
Range: 0-100, 0=Off, 1=Min Brightness, 100=Max Brightness 
Fc9-void-icon.png - VOID Return


LCDClear

Fc9-comp-macro.png LCDClear
Clears the contents of the graphical LCD. 
Fc9-void-icon.png - VOID Return


LCDDrawLine

Fc9-comp-macro.png LCDDrawLine
Draws a line on the LCD. 
Fc9-u8-icon.png - BYTE X1
Range 0-127 
Fc9-u8-icon.png - BYTE Y1
Range 0-31 
Fc9-u8-icon.png - BYTE X2
Range 0-127 
Fc9-u8-icon.png - BYTE Y2
Range 0-31 
Fc9-void-icon.png - VOID Return


LCDDrawRectangle

Fc9-comp-macro.png LCDDrawRectangle
Draws a rectange on the LCD. 
Fc9-u8-icon.png - BYTE X1
Range 0-127 
Fc9-u8-icon.png - BYTE Y1
Range 0-31 
Fc9-u8-icon.png - BYTE X2
Range 0-127 
Fc9-u8-icon.png - BYTE Y2
Range 0-31 
Fc9-u8-icon.png - BYTE Transparent
Sets the transparency of the box, 0=Box contains background colour, 1=Box contains previous pixel data 
Fc9-u8-icon.png - BYTE Solid
Chooses to fill the box with colour, 0=Box contains transparency data, 1=Box contains foreground colour 
Fc9-void-icon.png - VOID Return


LCDPlotPixel

Fc9-comp-macro.png LCDPlotPixel
Allows a single pixel on the LCD to be set or cleared. 
Fc9-u8-icon.png - BYTE X
Sets the X coordinate - Range 0-127 
Fc9-u8-icon.png - BYTE Y
Sets the Y coordinate - Range 0-31 
Fc9-void-icon.png - VOID Return


LCDPrintNumber

Fc9-comp-macro.png LCDPrintNumber
Prints a numeric value to the graphical LCD. 
Fc9-u8-icon.png - BYTE X
The horizontal start pixel. Range 0-127 
Fc9-u8-icon.png - BYTE Y
Y coordinate to print the string. Range 0-31 
Fc9-s16-icon.png - INT Number
 
Fc9-u8-icon.png - BYTE Transparent
 
Fc9-void-icon.png - VOID Return


LCDPrintString

Fc9-comp-macro.png LCDPrintString
Prints a string to the graphical LCD. 
Fc9-u8-icon.png - BYTE X
The horizontal start pixel. Range 0-127 
Fc9-u8-icon.png - BYTE Y
Y coordinate to print the string. Range 0-31 
Fc9-string-icon.png - STRING Data
 
Fc9-u16-icon.png - UINT Transparent
 
Fc9-void-icon.png - VOID Return


LCDSetBackgroundColour

Fc9-comp-macro.png LCDSetBackgroundColour
Sets the pixel colour to drive the LCD. Default colour is 1 where a set pixel is black and the background is white. 
Fc9-u8-icon.png - BYTE Colour
Range 0-1 : 0=White, 1=Black 
Fc9-void-icon.png - VOID Return


LCDSetForegroundColour

Fc9-comp-macro.png LCDSetForegroundColour
Sets the pixel colour to drive the LCD. Default colour is 1 where a set pixel is black and the background is white. 
Fc9-u8-icon.png - BYTE Colour
Range 0-1 : 0=White, 1=Black 
Fc9-void-icon.png - VOID Return


LCDWriteByte

Fc9-comp-macro.png LCDWriteByte
 
Fc9-u8-icon.png - BYTE Data
 
Fc9-u8-icon.png - BYTE X
 
Fc9-u8-icon.png - BYTE Y
 
Fc9-void-icon.png - VOID Return


LEDOff

Fc9-comp-macro.png LEDOff
Switches off a single LED on the front of the Formula Allcode.  
Fc9-u8-icon.png - BYTE LED
Which LED to switch on, range 0-7 
Fc9-void-icon.png - VOID Return


LEDOn

Fc9-comp-macro.png LEDOn
Switches on a single LED on the front of the Formula Allcode.  
Fc9-u8-icon.png - BYTE LED
Which LED to switch on, range 0-7 
Fc9-void-icon.png - VOID Return


LEDWrite

Fc9-comp-macro.png LEDWrite
Allows control of all 8-LEDs on the front of the Formula Allcode.  
Fc9-u8-icon.png - BYTE LED_Byte
8-bit binary value to write to the 8 LEDs 
Fc9-void-icon.png - VOID Return


LogoBackwards

Fc9-comp-macro.png LogoBackwards
Drives the robot backward using the encoders as feedback to ensure the robot drives straight. Automatically stops at the specified distance. 
Fc9-u16-icon.png - UINT Distance
Distance you want to robot to drive in mm. Range 1-65535 
Fc9-void-icon.png - VOID Return


LogoConfigure

Fc9-comp-macro.png LogoConfigure
The Logo movement may sometimes be slightly off in terms of distance or angle. Before tweaking the factory values check that the wheels are pushed well onto their shafts but not tight against the FA body. Also check the tyre is on the wheel correctly.  
Fc9-f32-icon.png - FLOAT Distance
mm per encoder step. default = 0.32 
Fc9-f32-icon.png - FLOAT Angle
mm of travel per degree. default = 0.7295 
Fc9-void-icon.png - VOID Return


LogoForwards

Fc9-comp-macro.png LogoForwards
Drives the robot forward using the encoders as feedback to ensure the robot drives straight. Automatically stops at the specified distance. 
Fc9-u16-icon.png - UINT Distance
Distance you want to robot to drive in mm. Range 1-65535 
Fc9-void-icon.png - VOID Return


LogoSetSpeed

Fc9-comp-macro.png LogoSetSpeed
Sets the cruise speed for LOGO type macros. Default speed 20%. 
Fc9-u8-icon.png - BYTE Speed
Range 1-100, Default 60 
Fc9-void-icon.png - VOID Return


LogoTurnLeft

Fc9-comp-macro.png LogoTurnLeft
Rotates the robot left by a specific angle using the encoders as feedback to ensure the robot turns evenly. Automatically stops at the specified turn angle. 
Fc9-u16-icon.png - UINT Angle
Angle in degrees you wish to rotate. Range 1-65536 
Fc9-void-icon.png - VOID Return


LogoTurnRight

Fc9-comp-macro.png LogoTurnRight
Rotates the robot right by a specific angle using the encoders as feedback to ensure the robot turns evenly. Automatically stops at the specified turn angle. 
Fc9-u16-icon.png - UINT Angle
Angle in degrees you wish to rotate. Range 1-65536 
Fc9-void-icon.png - VOID Return


PlayNote

Fc9-comp-macro.png PlayNote
Outputs a single tone from the onboard speaker for the period specified. 
Fc9-u16-icon.png - UINT Note
Sets the pitch of the note in Hz. Range: 1 - 10000 
Fc9-u16-icon.png - UINT Time
Time period to play the note for in milliseconds. Range: 0 - 65535 ms 
Fc9-void-icon.png - VOID Return


ReadBattery

Fc9-comp-macro.png ReadBattery
Reads the current voltage level from the LiPo battery. Return value is the battery voltage in Volts. Take care not to run the battery too low. Voltages lower than 3.4V may damage the battery. 
Fc9-f32-icon.png - FLOAT Return


ReadIRSensor

Fc9-comp-macro.png ReadIRSensor
Reads the analogue value from the specified IR distance sensor. Return value range: 0 to 4095 4095 represents the object is very close. 
Fc9-u8-icon.png - BYTE Channel
Range: 0 to 7 - 0=Left, 1=Front Left, 2=Front, 3=Front Right, 4=Right, 5=Rear Right, 6=Rear, 7=Rear Left 
Fc9-u16-icon.png - UINT Return


ReadLDR

Fc9-comp-macro.png ReadLDR
Reads the current light level from the on board light sensor. Return value range: 0 to 4095 4095 represents the maximum level of light and 0 represents the minimal level of light. 
Fc9-u16-icon.png - UINT Return


ReadLineSensor

Fc9-comp-macro.png ReadLineSensor
Reads the analogue value from the specified IR line sensor. Return value range: 0 to 4095 4095 represents the object is reflecting the most light. 
Fc9-u8-icon.png - BYTE Channel
Range: 0 to 1 - 0=Left, 1=Right 
Fc9-u16-icon.png - UINT Return


ReadMic

Fc9-comp-macro.png ReadMic
Reads the current audio signal level from the on-board microphone. Return value range: 0 to 4095 
Fc9-u16-icon.png - UINT Return


ReadSwitch

Fc9-comp-macro.png ReadSwitch
Reads the value of one of the switches from the front of the Formula Allcode. 
Fc9-u8-icon.png - BYTE Switch
Which switch do we want to read 0=Left, 1=Right 
Fc9-u8-icon.png - BYTE Return


Reverse

Fc9-comp-macro.png Reverse
Drives both motors of the formula flowcode backwards with the power specified.  
Fc9-u8-icon.png - BYTE Power
Amount of power to use to drive motor. Range 0-100 
Fc9-void-icon.png - VOID Return


SetMotors

Fc9-comp-macro.png SetMotors
Sets the speed and direction of the Formula Allcode motors.  
Fc9-s16-icon.png - INT Left
Valid Range = -100 to 100 
Fc9-s16-icon.png - INT Right
Valid Range = -100 to 100 
Fc9-void-icon.png - VOID Return


SpinLeft

Fc9-comp-macro.png SpinLeft
Spins the formula flowcode on the spot in an anticlockwise direction as seen from above.  
Fc9-u8-icon.png - BYTE Power
Amount of power to use to drive motor. Range 0-100 
Fc9-void-icon.png - VOID Return


SpinRight

Fc9-comp-macro.png SpinRight
Spins the formula flowcode on the spot in a clockwise direction as seen from above.  
Fc9-u8-icon.png - BYTE Power
Amount of power to use to drive motor. Range 0-100 
Fc9-void-icon.png - VOID Return


Stop

Fc9-comp-macro.png Stop
Stops both motors. 
Fc9-void-icon.png - VOID Return


WaitForSwitch

Fc9-comp-macro.png WaitForSwitch
Waits for the specified switch to be pressed. 
Fc9-u8-icon.png - BYTE Switch
Which switch do we want to wait for 0=Left, 1=Right, 2=Either, 3=Both 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-7-icon.png Wait For Button
Determines if the program will automatically wait for one of the front switches to be pressed before executing the program. Ran as part of the initialise function after the various components have been initialised. 
Fc9-type-16-icon.png Show Creation Info
Specifies what information is shown to the user on calling the initialise function. The time and date shown are the compilation time and date to help pinpoint the firmware version. 
Fc9-type-7-icon.png Bluetooth Reset
Decides if the Bluetooth data connection can reset the Formula AllCode. Used by mLoader when programming via Bluetooth to allow reprogramming without having to physically touch the robot. To ensure programming security set this option to No. 
Fc9-type-7-icon.png Use Motor Feedback
Controls when the motor feedback is used. No - Speed control feedback is not used for SetMotors commands. Yes - Speed control feedback is used for the SetMotors commands. SetMotors commands include Forward, Backward, SpinLeft, SpinRight as well as SetMotors itself. Logo functions always use feedback. 
Fc9-conn-icon.png IR Simulation
Fc9-type-16-icon.png IR Simulation Mode
Controls how the IR sensors are modelled in simulation. Linear is the legacy mode and works as it has always done. Exponential attempts to provide a more accurate reading which is closed to response of the real world hardware, 
Fc9-conn-icon.png IR Thresholds (CheckIR macro)
Fc9-type-21-icon.png IR Distance
IR Threshold used with the CheckIR macro 
Fc9-type-21-icon.png Line Sensitivity
 
Fc9-conn-icon.png Simulation Properties
Fc9-type-21-icon.png Sim Speed (1 - 100)
Sets the simulated amount of movement relative to the speed of the Formula Allcode. 
Fc9-type-21-icon.png Timer Interval (ms)
Interval in milliseconds between each simulated movement of the Formula Allcode robot. 
Fc9-type-16-icon.png Collision Method
Select which objects the robot sensors will interact with. 
Fc9-type-17-icon.png Light Source
Panel object specified as the simulation light source. Used when simulating "find the light" type tasks. 
Fc9-type-17-icon.png Addon Mechanics
Useful if you are creating add-ons to the robot which you want to be able to simulate. Point the property at the group containing the Formula Allcode and the additional mechanics. Otherwise leave blank to maintain the normal simulation functionality.