TABLE OF CONTENTS Executive Summary ... 3 M3 ... 3 Properties ... 3 Events... 4 Functions... 4 void Open() ... 4 void Connect() ... 4 void Stop() ... 4
void ResetAxis(int axis)... 4
int Close()... 4
void SendMessage( string Msg,PCBOTEventArgs.messageType type)... 4
public bool Calibrate() ... 5
public void M3GetStatus()... 5
public void Drive(long Distance, int LeftVel, int RightVel, int Power)... 5
public void Rotate(long Degrees, int Vel, int Power, rotate Dir ) ... 5
Sensor locations ... 5 Sensor Types... 6 Sensor Data ... 6 Drive Control ... 7 Properties ... 7 Sensor Control ... 8 Properties ... 8 Message Control ... 8 Properties ... 8 Toolbar Control... 9 Properties ... 9 Version checking ... 9
Installing the components into Visual Studio 2005 ... 10
How to use the PC-BOT components in a Visual Studio project ... 10
Distributing Applications... 10
Sample Programs ... 11
Executive Summary
This document outlines the functionality of, and how to use, the PC-BOT .NET controls for Visual Studio 2005. The components
There are five PC-BOT components for Visual Studio 2005. Drive, Messages, Sensors, M3, and ToolBar.
This is how the components appear in Visual Studio 2005. A Visual Studio Developer can drag and drop these components in to any Windows forms project. The developer may write their code in any of the .NET supported languages (Visual Basic, C#, J#, C++)
M3
The M3 control is a non-UI control. It gives the programmer full control of the PC-BOT’s M3 module.
Properties
[-] CalibrationFloorCenter The floor setting for sensor 6 - read only FloorLeft The floor setting for sensor 7 - read only FloorRight The floor setting for sensor 5 - read only [-] Drive
DropOffValue Percentage drop allowed Power 0 to 100
Safety On/Off StopOnSafety True/False
VelocityLeft -100 to 100 (mm/s velocity of the left motor)
VelocityRight -100 to 100 (mm/s velocity of the right motor)
[-] Digital IO
[+] DigitalOut On/Off [-] Misc
AverageCPU Average CPU usage in the last 60 seconds – read only [-] Sensors
[+] SensorData int32[] Array (0 to 100 – see section on Sensor Data) - read only [+] SensorTypes sensorType[]Array (see section on Sensor Types)
PC-BOT .NET Controls for Visual Studio 2005
4 [-] Version
Version Version number – read only
Events
MessageEvent -This event is fired when a message is available SensorEvent -This event is fired when there is new sensor data
SafetyEvent -This event is fired when the Safety has issued an emergency stop. PositionEvent -This event is fired when the requested position is reached.
DropOffEvent -This event is fired when a drop off is detected.
Functions
void Open()
This function will open the PC-BOT’s M3 module. This must be done before anything else.
void Connect()
This function will connect to the PC-BOT’s M3 module. Connect should be called after opening.
void Stop()
This function will stop the PC-BOT motors. It will do this by setting VelosityLeft, VelocityRight, and Power to 0.
void ResetAxis(int axis)
This function will reset an axis on the PC-BOT’s M3 module.
int Close()
This function will close the PC-BOT’s M3 module. After the M3 is closed, you must call Open() if you wish to resume sending commands to it.
void SendMessage( string Msg,PCBOTEventArgs.messageType type)
This function is used to send a message out using the MessageEvent. Msg = The message string.
public bool Calibrate()
This function will obtain new floor settings from the beak sensors. These settings will be used along with DropOffValue to determine if there is a drop off in the path of the PC-BOT.
public void M3GetStatus()
This function will cause the M3 component to send out a series of status messages.
public void Drive(long Distance, int LeftVel, int RightVel, int Power)
This function will drive a given distance. Distance = The distance to move in mm. LeftVel = Left wheel velocity (0-100 mm/s) RightVel = Right wheel velocity (0-100 mm/s) Power = Power (0-100)
public void Rotate(long Degrees, int Vel, int Power, rotate Dir )
This function will rotate a given number of degrees. Degrees = The number of degrees to rotate.
Vel = The velocity of the rotation (0-100 mm/s) Power = Power (0-100)
Dir = The direction of the rotation. ( rotate.clockwise or rotate.anticlockwise)
PC-BOT .NET Controls for Visual Studio 2005
6 There are 8 sensors connected to the M3 module of the PC-BOT. Numbers 0 to 4 are
located on the base and 5 to 7 are on the beak.
Sensor Types
There are two sensor types supported. The Sharp 80cm IR and the Sharp 150cm IR. Using the SensorTypes property you can select the sensors used on your PC-BOT.
Note that these are the standard settings for the currently shipping version of the PC-BOT 914.
Sensor Data
Reading any of the 8 sensors on the PC-BOT will return a value from 0 to 100%. This number represents the output of the A/D (analog to digital) converters. If an object is out of range of the sensor, then the value returned will be 0. As an object moves closer to the sensor the output increases until it reaches 100%. For the 80cm IR sensor 100% is reached at about 10cm, and for the 150cm IR at about 20cm.
Drive Control
The drive control is a UI component that allows you to drive the motors of the PC-BOT. Holding down the left mouse button on the control will move the PC-BOT in that direction. The red line shows the direction and how much power is being applied. The longer the line is the higher the power level. Releasing the left mouse button stops the PC-BOT.
Properties
[-] DrivePower The power to apply to the M3 (0-100) [-] PC-BOT
PCBOTm3 M3 object [-] Version
PC-BOT .NET Controls for Visual Studio 2005
8
Sensor Control
The sensor control is a UI component that receives the SensorEvent from the M3 component and displays the data graphically. It lets you see what the PC-BOT’s sensors are seeing.
Properties
[-] PC-BOT PCBOTm3 M3 object SensorColour Colour SensorLineColour Colour [-] VersionVersion Version number - read only
Message Control
The message control displays all messages sent via the M3 control’s MessageEvent.
Properties
[-] PC-BOT
PCBOTm3 M3 object
[-] Version
Toolbar Control
This Toolbar control is used to call functions in the M3 component. Before you start driving your PC-BOT you must first click the Open button. After Open, click the
Connect button. You are now ready to start driving the PC-BOT via the Drive control or your own code.
The Reset button will reset axis 1 and 2 of the M3.
The Close button will close the M3. To start up the M3 again you must click the Open button.
Properties
[-] PC-BOTPCBOTm3 M3 object
[-] Version
Version Version number - read only
If you do not wish to use the Toolbar control, here is the list of the M3 functions called by the buttons on the control.
Open m3.Open(); Connect m3.Connect(); m3.VelocityLeft = 0; m3.VelocityRight = 0; m3.Power = 0; Calibrate m3.Calibrate(); Reset m3.Connect(); m3.VelocityLeft = 0; m3.VelocityRight = 0; m3.Power = 0; m3.ResetAxis(1); m3.ResetAxis(2); Close m3.Connect(); m3.VelocityLeft = 0; m3.VelocityRight = 0; m3.Power = 0; m3.Close();
Version checking
Each component has a version property. To check that your components are all at the correct version you should look at this property.
PC-BOT .NET Controls for Visual Studio 2005
10
Installing the components into Visual Studio 2005
After running the setup program:
1) From the Visual Studio 2005 Toolbox, right click and select “Choose Items…” 2) From the “.NET Framework Components” tab click the “Browse…” button. 3) From the VisualStudio2005 directory of this install select PC-BOT.dll
Example:
C:\Program Files\WhiteBox Robotics\PC-BOT .NET Components for VS2005 (beta 2)\VisualStudio2005 4) Then select OK.
5) This should add all the PC-BOT beta components to the Visual Studio Tool Box.
How to use the PC-BOT components in a Visual Studio
project
Fast start (no code approach)
1. Start a new Visual Studio 2005 project. 2. Drop on the M3 component
3. Drop on the Sensors component and set the PCBOTm3 property to the M3 component you just added.
4. Drop on the Drive component and set the PCBOTm3 property to the M3 component you just added.
5. Drop on the Toolbar component and set the PCBOTm3 property to the M3 component you just added.
6. Build your project
7. Start driving your PC-BOT around the room. Or,
1) Start a new Visual Studio 2005 project 2) Drop on the M3 component
3) Use the M3 properties and events and write your own code to control the PC-BOT.
Distributing Applications
To distribute applications that you make with the PC-BOT .NET Controls for Visual Studio 2005 you will need the following files:
• PC-BOT.dll - Found in the Deploy directory • Wbrm3.dll - Found in the Deploy directory • Your program files
It is recommended that you copy these files to a directory on you PC-BOT. You can then run your application from this directory.
Sample Programs
Sample programs for this release can be found in the Samples directory.
C# Sample Code
The code samples for this release can be found in the SampleCode directory.