Duki 552 Nearly a Posting Virtuoso

Hey guys,

I need to know about Lithium-Ion batteries and where I can buy them. I'm not really talking about laptop batteries. I need something that can power a desktop for well over an hour (more like half a day). Does anyone know where I can get information on this?

Thanks

Duki 552 Nearly a Posting Virtuoso

Diet Coke... yet again.

Just had a nice juicy orange cranberry muffin with my coffee.

Duki's signature:
Let's include VB in that too.

Agreed.

Duki 552 Nearly a Posting Virtuoso

I can't get it to work that way. Here's the code I tried:

byte[] outBufferAngle = BitConverter.GetBytes(A);
            byte[] outBufferVelocity = BitConverter.GetBytes(V);

            comBobbySue.Write(outBufferAngle, 0, outBufferAngle.Length);
            comBobbySue.Write(outBufferVelocity, 0, outBufferVelocity.Length);

V and A are both doubles that have been calculated earlier. When I send the buffer out of the COM port, I don't get the correct output.

For example if I send

A = 90
V = 25

V is output as Hex 00 rather than Hex 19.

If I try to send

A = 160
V = 45

V is output as Hex 47 rather than Hex 2D.

The output is random for every time it's sent. Could this have anything to do with the unpredictability of the value after the decimal point? At any given point, A or V could have the value of x.329847 or some other non-integer number.

Duki 552 Nearly a Posting Virtuoso

Hello Duki, glad to see you are still around! Enjoy your Diet Coke!

I had an Einstein Wildberry Blender, yum!

Glad to be back. School always seems to draw me to DaniWeb again.

<puke>Just gargled some salt water (wisdom teeth were removed on Friday).</puke>
Getting ready to drink another Diet Coke.

Duki 552 Nearly a Posting Virtuoso

Ok, that answers my question. I'll try it when I start working on the program again.

We already have D computed from a previous section of code. I just wanted to know if there was a way to use D directly, without using the textbox.

Duki 552 Nearly a Posting Virtuoso

Ok I'm a little confused.
Say I want to send the double A out the COM port. what would be the easiest way?

I've got it working to where it will parse the text box, but there's got to be a way to just convert the double itself.

Thanks for the help

Duki 552 Nearly a Posting Virtuoso

Hm, how can I see what it was? Sorry if that's a dumb question

Duki 552 Nearly a Posting Virtuoso

I think there's some confusion between "Multi-threading" and "Multi-Tasking" here...

Duki 552 Nearly a Posting Virtuoso

oh cool. So I can specify how many bits to take in?

Duki 552 Nearly a Posting Virtuoso

Ok I've got a lot working!!

Here's the code:

private void btnX_Click(object sender, EventArgs e)
        {
            if (remote == false)
            {
                remote = true;
                Cursor.Position = pctRemote.PointToScreen(gridCenter);  //centers the cursor on the grid
                Cursor.Clip = pctRemote.RectangleToScreen(pctRemote.ClientRectangle); //confines mouse to grid perimater
            }
            else
            {
                remote = false;
                Cursor = Cursors.Default;
                /*  NEED HELP HERE   */
            }
            
        }

Now I need help switching the Cursor.Clip off. How can I do that?

Thanks!

Duki 552 Nearly a Posting Virtuoso

awesome, it's working great. Here's the only problem I've run into.

I'm sending angles to the controller. So when I get to angle 256, it errors out because of the maximum size of the Byte.parse

Can I use something larger than this? I just need something that will accept 360ish

Duki 552 Nearly a Posting Virtuoso

awesome, thanks. I'll test that out tonight.

Duki 552 Nearly a Posting Virtuoso

Diet Coke.

Duki 552 Nearly a Posting Virtuoso

ha. Ok :(

Ideally we would like to compile and run the code on a Linux box, but since we're going to be doing multithreading, I think we may just stick with XP or the like.

Am I right in thinking that we would get a greater performance boost by utilizing multithreading on windows rather than single threading on a *nix box?

Duki 552 Nearly a Posting Virtuoso

yeah maybe. Is there any way to send an Int or Double to the COM port?

Duki 552 Nearly a Posting Virtuoso

hey everyone,

we have an argument that figured up the angle in a double. We need to convert that double to a char and send it out the serial port. I've tried this:

char t1 = (char)A;
            comBobbySue.Write(A);

but i get errors. can someone give me a hand? :(

Duki 552 Nearly a Posting Virtuoso

another quick question that I can't find the answer to.

Is multithreading different for Linux? i.e., if I write my program on a windows machine, will it run in Linux?

Duki 552 Nearly a Posting Virtuoso

excellent! thanks a ton!

Duki 552 Nearly a Posting Virtuoso

Probably a bit of an advanced question...

How hard is it to allow for multi threading support with C#? For example, we have a motherboard that has the capability for two processors with four cores each (dual xeon quad cores). We want to dedicate one processor (or core) to calculating a task, such as vision, and the other cores to do other tasks. Is this something that is coded in C#? If so, is it different for Windows and Linux?

Many thanks to anyone who can provide information on this, or even point me in the direction to where I can find information

Duki 552 Nearly a Posting Virtuoso

thanks I'll test that out and post the code if I have problems

Duki 552 Nearly a Posting Virtuoso

Hey again,

Is there a way to capture multiple key presses? Here's what we want to do:

When a user wants to drive the robot manually from the keyboard, we want to allow them to press WASD to determine the direction they move. The problem we've run into is say for example the user wants to make a right turn... our program doesn't recognize that both W and D are being pressed. Is there a way to capture two keys as well as just one?

Thanks!

Duki 552 Nearly a Posting Virtuoso

thanks

Duki 552 Nearly a Posting Virtuoso

I wanted to start a new thread that was focused on this topic.

Cursor.Capture doesn't exist (according to VS2008)

Also, it kept clipping to the wrong portion of the screen. Couldn't figure out how to move the clipped portion to be in the same position as the picture box.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

is this the most efficient way to round a decimal number to two decimal places?

txtXaxis.Text = String.Format("{0:F2}", A); //show 2 decimal places
            txtYaxis.Text = String.Format("{0:F2}", V); //show 2 decimal places

thanks!

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I want to restrict cursor movement outside of a picture box when the user clicks a button. Here's what my code looks like so far:

private void btnX_Click(object sender, EventArgs e)
        {
            if (remote == false)
            {
                remote = true;
                Cursor.Position = pctRemote.PointToScreen(gridCenter);  //centers the cursor on the grid
            }
            else
            {
                remote = false;
                Cursor = Cursors.Default;
            }
            
        }

PictureBox = pctRemote

I've tried a lot of cursor.clip functions but I can't seem to get it working.

Duki 552 Nearly a Posting Virtuoso

Thanks for the output Jackstar,

The VISTA computer doesn't show an IP address tied to the networking card. Make sure your network connection is enabled on the vista computer.

To enable your connection:
1. go to control panel > network and internet > network connections.

2. select the connection you want to modify.

3. right-click and click enable (if it's already enabled this won't be an option)

Also make sure you're getting flashing lights from your networking card to make sure the cable is connected good. I see a couple that say "Media Disconnected" which means your networking cable may not be connected right.

Let me know if any of this helps.

Duki 552 Nearly a Posting Virtuoso

If anyone else has an emulator solution, please post as well. The loopback will work for my home PC, but I often code from school machines and would like to have a software solution available.

Thanks!

Duki 552 Nearly a Posting Virtuoso

Ya Nice,

>>To Clip the Cursor, you have to Capture it First. To do use Cursor.Capture = true in button1_Click.

>>Another thing is to set the Bounding Rectangle of the Clipping area.

Cursor.Clip = Clipping Rectangle

In this case pictureBox1.ClientRectangle
Cursor.Clip = pictureBox1.ClientRectangle

but Cursor.Clip requires coordinates in Screen position so Convert the Rectangle to Screen Position First using pictureBox1.RectangleToScreen ()

>>Then set this rectangle to Cursor.Clip. It will clip the cursor right now.

- To finish the Clipping, that is when click the button again, set Cursor.Clip to Screen Bounds and Cursor.Capture = false to the previous state(inside button1_click when remote = true).


To Center the Cursor
>> First calculate the Center using pictureBox1.Width/2 and Height/2

>> Use Cursor.Position to center the cursor.
>> But it also requires the coordinates in Screen position So convert the Center point into Screen coordinate using pictureBox1.PointToScreen().
>> Then set Cursor.Position = Center

I've given the direction, i hope you will develop the code.

Thanks, that helps a ton! I'm going to start coding again tomorrow after class. I'll let you know how it works!

Be aware in your code if you did apply the clip you wouldnt be able to press the button.

I was thinking about that myself. What I'll probably do is modify the button to be a small "x" in the center of the coordinate plane. Thanks!

Duki 552 Nearly a Posting Virtuoso

Thanks!

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I'm trying to write code that will be sent out of the COM port to a PIC microcontroller. However, I don't have the controller available yet. Is there an emulation software that will allow me to virtualize a COM port and capture the data that's being sent to it? Maybe that will help me to make sure I have the code functioning properly.

I've tried one program but I must have been doing something wrong, because when I try to transfer data to it, it says Access Denied in the debugger. However, when I try to send data to the actual COM port on my computer without the emulator running, everything looks to be running fine. But I can't be positive about that until I can actually capture the data leaving my COM port.

Thanks for any help!

Duki 552 Nearly a Posting Virtuoso

I got the first part to work!!
Can you help with the Cursor.Clip part now? Also, how can I make the cursor start at the center of the picture box?

Here's my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Anassa
{
    public partial class Form1 : Form
    {
        bool remote = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (remote)
            {
                label1.Text = e.X.ToString();
                label2.Text = e.Y.ToString();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (remote == false)
                remote = true;
            else
                remote = false;
        }
    }
}

Thanks!!

Duki 552 Nearly a Posting Virtuoso

Do you have a static IP available for a NAT translation?
Which model router do you have?

Duki 552 Nearly a Posting Virtuoso

My suggestion: http://www.cdw.com/shop/products/default.aspx?EDC=871657&cm_sp=Product-_-Overview-_-Main+Tab

I've never used Linksys in a production environment. However they are built by Cisco Systems, which has to count for something. They are much cheaper than the fully loaded Cisco series switches, however I doubt you would be using the functionality that wouldn't be included with a Linksys model.

This switch would provide a decent scalability solution as well, if the company were to grow further. You could use LACP with a couple of the Gigabit ports to connect them to the server (assuming the server has two 1GB NICs), and still have two Gigabit ports available to add more switches in the future.

Hope this helps.

Duki 552 Nearly a Posting Virtuoso

Simply put, the Linksys router also has a switch built into it. This is how multiple people are able to access the same internet connection. The router transfers information back and forth to the built-in switch.

Unfortunately, this means that both of you will be on the same network. If you have any shared files and whatnot, anyone plugged into that switch could view them. Also, most new home-office routers have wireless built in. That means not only could someone plug into your router and be on your network, but they could also potentially connect from across the street without you even knowing it.

Not trying to scare you or anything, I just want you to be thoroughly informed especially considering it's not simply your personal data at risk, but also your clients'. There are many ways to protect your computer though, most of which are very simple.

The easiest way of course would be to say, "I'm sorry, but I have an obligation to my clients to protect their confidentiality, so I don't think we can share the same Internet connection." However, that doesn't sound like a good solution for you in this case (could be wrong).

If you DO decide to share your connection, reply here and I'll post some very simple security tips.

Also, regardless of if you decide to share your connection or not, you should consider purchasing a router. This can act as the first layer of defense between your …

Duki 552 Nearly a Posting Virtuoso

Hey Anupkumar!

Not sure about the simulators, but you can do some research on OSPF, EIGRP, BGB, and IS-IS as these are the most common routing protocols used today.

There are many simulators out there, but I wouldn't recommend spending any money on them. If you're serious about it, search ebay for a cisco 2600 router and start building your own test lab. I've worked with a couple of simulators, and only one worth anything was actually free from Cisco. Unfortunately the only way to obtain it (that I know of) is to be a member of the Cisco Networking Academy. It's called PacketTracer.

If you need anymore information just reply to this... hope it helped.

Duki 552 Nearly a Posting Virtuoso

Welcome to the forums!
Which model router did you get?

Also, can you do the following (on both computers) and post your output:

start->run...->type cmd->OK

type "ipconfig /all" (without the quotes) and hit enter. Post the output of this command and we'll have a look.

Duki 552 Nearly a Posting Virtuoso

Thanks for the reply. When I run the program nothing happens to label1 and label2 when I move my mouse over the box. The text stays at "label1" and "label2" :(

Also about the Cursor.Clip... I have no clue how to use that. What does it do?

Thanks for the help!

Duki 552 Nearly a Posting Virtuoso

Hi and welcome,

Have you configured DNS on the server?

Duki 552 Nearly a Posting Virtuoso

Here's what I have so far... but nothing happens:

private void groupBox1_MouseMove(object sender, MouseEventArgs e)
        {
            int x;
            int y;
            x = e.X;
            y = e.Y;

            label1.Text = x.ToString();
            label2.Text = y.ToString();
        }
Duki 552 Nearly a Posting Virtuoso

so if I have a PictureBox... where would I code the MouseMove event? Sorry for being soooo new ... sort of embarrassing actually. I know C++ well, i just heard that C# is easier than Visual C++. :(

Duki 552 Nearly a Posting Virtuoso

I suppose. I just have no clue how to use what you gave me. I've never really used C#

Duki 552 Nearly a Posting Virtuoso

Thanks for the help.
Do you think you could provide an example?

Duki 552 Nearly a Posting Virtuoso

To be more thorough, here's what I'm trying to do...


I need to be able to allow a user to click a button within a frame on the form. Once the user clicks the button, I need the cursor to be confined to only that frame until the button is clicked again. Also, after the first click, I need to continuously output the x and y coordinates of the cursor. This information will later be sent to a controller via com port.

If you can vision the program in your head, it's sort of a remote control program for our robot. We have a wireless keyboard with a mouse built onto it that we use to drive the robot. depending on how far up the frame we move the cursor (and in what direction) determines how the robot responds.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I'm completely new to C# so I'm sorry if I don't make sense.
I need to capture the x and y position of the mouse cursor within a group box (or some other frame). How can I do that?

Duki 552 Nearly a Posting Virtuoso

Hey guys,

We're trying to work with a driver program for our robot. If we can grab the x and y coordinates of the Mouse we could send them to the controller for driving. Does anyone know how to capture the mouse movement into an integer?

Duki 552 Nearly a Posting Virtuoso

Ah ok, that's kind of similar to the VB code. Here's what we have right now:

commLMS.PortOpen = True
commGPS.PortOpen = True

Then later within the same code it communicates through a function called

CalOutput()

That code looks like this:

Dim Vout As Integer
Dim Aout As Integer
Dim Vchr As String
Dim Achr As String

Vout = Int(((127 / 100) * V) )
Aout = Int(128 + (127 / 180) * (180 - A))
Vchr = Chr(Vout)
Achr = Chr(Aout)
commBobbySue.Output = Vchr
commBobbySue.Output = Achr

commBobbySue is the PIC controller.
V is velocity
A is angle

Hope that makes sense
Is this similar to what it would look like in C++? Not the declarations, just the port openings.

Duki 552 Nearly a Posting Virtuoso

A very funny (and borderline absurd) article I thought many of you would enjoy: http://www.pbm.com/~lindahl/real.programmers.html

:)


-hope this is the best place to post this

Duki 552 Nearly a Posting Virtuoso

Wow, thanks for the advice!
How do you create listening threads? Is that in the code?

I'm so glad to find someone that has this type of experience! I'm sure you and I will be talking a lot over the next couple of months :)

If that's ok with you of course...

Duki 552 Nearly a Posting Virtuoso

MS-Windows Communications Reference here. I think it even has examples.

>>which is connected to the computer system via the "ninth" COM port
Does that mean the computer has a COM port expansion board installed, there are several 8, 16 and 32 port boards and each has a device driver so that your program can reference the ports as COM1, COM2, COM3, ... COM32. Just use the port number in the CreateFile() statement (see the examples previous linked).

>>How can we transfer information to and from the GPS device
I have no idea about how to communicate with the GPS device -- you will have to read the manufacturer's programmer's reference documentation for that. But you set up the com port's parameters via the functions/examples previously described.

Thank you!! I'm completely new to interfacing with anything other than the cmd line. Currently there are about 150 pages of VB6 code that control the robot; my friend and I are converting everything to C++ (2008), which should have been done a few years ago.

Again, thanks a bunch for your help!! Do you have much experience with interfacing with devices other than the cmd line?

Do you need to talk to the comm port using Windows or Linux?

It's currently Windows XP that runs the bot... we (my friend and I) suggested a transfer to Linux, which will be done as soon as we convert the VB6 code.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

A friend and I are trying to figure out how to interface C++ 2008 with COM ports for our robotics team. Is there a simple "template" we could go by, or is it different for every device? Could someone provide an example of how to transfer data to COM ports via C++?

For example: The robot operates off of GPS, which is connected to the computer system via the "ninth" COM port at 19200 baud. How can we transfer information to and from the GPS device? If you need more information, let me know.

Thanks for any help!