JaycoRobotics
Where your best friend is a Robot
Title
Date
Author

Windows has several performance counters that help with getting values of what is happening on the computer. First we have to start out with adding the library that has the performance counters like below.

Below is code for getting a list of performance categories.

Once you have the list of categories you can get a list of all performance counters under that category.

The below code gets a list of all the performance counters in the category and the instance. You can use this to drill down to the exact performance counter that you want to have.

Finally after having done all the work above we have the ability to get a list of all performance counters on our system. The next thing we need to learn is how to get the value from the performance counter. Below is the code for this.

Categories
Title
Date
Author

When making a basestation program for your UAV it can be nice to add voice warnings. There can be used to let the user know when they have reached a waypoint, achieved an objective, and announce a warning or error. With windows programming it is easy to add this voice to the program.
To start you will need to add a reference to your the “System.Speech”. You can then add the using statement in your code like below.

After adding the reference you can use the code below to make the computer speak.

With this you should hear your computer speak. If you have problems there are a few other options that may need to be set before you system can speak.

Your speach program should now work to give your users verbal information.

Categories
Title
Date
Author

When using a robot with a Windows based operating system it is sometimes nice to get the load on the processor so you know how much more processing you can add.  If you have a multicore processor it is also nice to see each core individually.  If you have direct access to the computer you can just use the task manager to see this information but if you want to see it in your own program you will need to get the information programatically.

To get the performance of the processor it is best to use a performance counter.  The performance counters are under “System.Diagnostics”.

To get a string array of processors use the code below.

This will give you a list of all the cores plus one called _total.  The _total category is exactly what it sounds like.  It is a combination of all the cores.  The rest will be labeled as CPU0,CPU1, etc.

After you have the list of cores you can choose which one you want or get the total for all.  You will need this name in order to create a performance counter.  The next step is to choose what you want the performance counter to track.  In our case we want to use the “% Processor Time”.  To create the Performance Counter we use the code below. Then all we have to do is call the NextValue method to get the value we want.

If you would like to get a list of all the performance counters on the system you can use the code below. This is helpful if there are other metrics that you wish to track on the system.

Performance counters are very helpful in diagnosing a robotic system and for making sure your processor is getting used to its full potential.

Categories
Title
Date
Author

Sometimes when creating a program you will need to know something about the computer inside your program. One way of getting information about the computer is using Windows Management Information. It is relatively simple to get the information and use it to whatever purpose you have. Sometimes it is just fun to show the user the hardware that is on the system. All of the objects that we want to call are Win32 objects. By searching online you can find the names for all of them but I have provided a list at the bottom of this post for ease.
To get the information from the object we can use SQL query strings. Below is code for accessing all the properties within the object and adding to a list which can be viewed in a DataGridView or other control.

Once you have the list of properties for the object you can sort out the ones that you want to display to your user or even modify your SQL statement to quickly get the property you want to show your user.
This is a list of all Win32 classes that I know of. Depending on your system not all of these will return information since some systems to not support all objects.

Categories
Title
Date
Author

The C# langauge and the embedded processors that can harness the programs created by it are growing every year. This post will teach making a simple serial program. Sample Project Files

The first thing we need to do is create a serial port using the code below.

The code below shows how to fill combo boxes with the possible selections for each of the settings required to create a serial port.

To create the serial port we need to set several variables.

The next thing we need to do is set up an event handler so we can catch when new information is transmitted to us.

Since the event handler does not come back on the same thread as the UI we need to invoke and delegate the information to our UI thread for displaying.

To send data over the serial link all we need to do is call the WriteLine method. The serial port also allows for sending character or byte strings.

Putting the parts learned here together I created a simple serial communication program that sends text from one computer to another. This is a perfect start to developing communication between computers and components. With a few changes to the above code you can send data in byte streams specific to your needs or stay in Ascii characters and make your communication easy for humans to read and interpret. Have fun with your newly learned skills.

Categories
Title
Date
Author

The Simple HUD components for C# now includes a Graphic HUD which is similar to most aircraft glass cockpits.  Get the new version here

Sample code for the component

Categories
Title
Date
Author

A communication protocol is an agreement between two devices about how they should transfer data to each other.  In this entry we will talk about serial communication protocols.  Serial communication is a single channel that transmits data in a series of bits.  A series of bits in the protocol make up a data packet.  The communication protocol has to address the following issues:

  • What is the order of the bits?
  • How does the receiver know when to start looking for information?
  • How does the receiver know when the data packet starts?
  • How does the receiver know when the data packet has ended?
  • What does the data inside the packet mean?

The issue of when to look for data must be decided before creating the protocol.  The start of a transmission can take several forms.  Depending on the devices several methods can be used.  A few of them are listed below:

  • Set a separate channel from a low bit to a high bit to indicate that the receiver should start listening for the data packet.
  • Set the transmission channel from a low bit to a high bit for a specific period of time then follow with data.
  • Have the receiver continually looking for data then use an agreed upon start bit to indicate the start of the transmission with an end bit to indicate the end of the transmission.  This method usually gets placed into a circular buffer where the data packets can be

For this example, we will have our receiver continuously looking for data.  The data we are going to receive has a set amount of bits that it will send and does not have a need to be variable.  We will design our data packet so that it has a start and end byte.  The table below shows what our data packet will look like.  This data is coming from an AHRS on a helicopter.  It gives us all the data we need to understand the orientation and position of the helicopter within our reference frames.  By using a 16 bit integer we are able to use 65,535 values for our data.  The higher number of bits we use the more resolution our data has.  As our data packet grows so does the time to send it through our communications link which leaves the user deciding what is more important speed or resolution.

Description Type
Start Byte Ascii Charater “A” – 8 bit
Roll Angle 16 bit integer
Pitch Angle 16 bit integer
Yaw Angle 16 bit integer
Acceleration X 16 bit integer
Acceleration Y 16 bit integer
Acceleration Z 16 bit integer
Roll rate 16 bit integer
Pitch Rate 16 bit integer
Yaw Rate 16 bit integer
Latitude 16 bit integer
Longitude 16 bit integer
Altitude 16 bit integer
End Byte Ascii Character “B” – 8 bit

If you data is going to be variable in length then at the start of your packet you should have information about the size of the data that is coming so you can collect the full packet before you start processing assuming you need to wait for the entire packet to arrive.  An example of this would be a photograph.  Depending on if you are using compression the image size can vary slightly with each image sent.  To handle this you would encode in the start of the packet a place that shows the size and possible the number of bits that make up the whole packet.

This is the short version of creating a communication protocol.  I will add to it as time goes on.

Terms used in serial communications

  • Asynchronous – transmission does not occur at the same time or have the same period or phase.  Timing signals are derived from special characters in the data stream.
  • Synchronous – transmission that requires a common clock signal between communicating devices to coordinate their transmissions.
  • Bit – a single data point having either 0 or 1 state.
  • Byte – sequence of 8 bits which represents one character of alphanumeric data.
  • Start-bit – The first bit of data used to show the start of the transmission.
  • Stop-Bit – The last bit of data used to show the end of the transmission.
  • Baud – A data transmission rate for modems.  Example 9600 baud = 9600 bits/second = 1200 bytes/second
  • Parity bit – a bit that is used in error detection in which a 0 or 1 is added to each group of bits so that it will have either an odd number of 1’s or an even number of 1’s.  If the parity is odd then any group with even bits contains an error.
  • Read Timeout – the longest amount of time the connection will wait to read data.
Categories
Title
Date
Author

Welcome to JaycoRobotics, a blog about various robotic projects, robots in industry, and tools to help with robotic projects.

The mission of JaycoRobotics is to provide its readers with knowledge and tools to create robots for their personal lives as well as work lives. There is no reason a robot can’t be helpful to humans or do most of the work around the house. Plus it is just plain fun to work with and on robots.

Because we will be having code on the website. I will test the google code viewer to make sure it works well.

Categories