PDA

View Full Version : Fingers Program using C #‏ Microsoft robotics studio



jems
09-03-2008, 01:45 AM
Hi Guys


Currently i m doing a robotics fingers project needed to run 15 servo motor simultaneously. Which means 1 finger to 3 servo motors. Due to some situation instead of using Visual Show automation i needed to use C# to combine with another project but some how i m unable to run it simultaneously even by combining 2 mini ssc2 together to make it from 0-7, 8 -15 servo motors.

I m able to run the motor 0 - 8 but unable to run 8 - 15. I have checked my connection everything seems right. When i deleted the 0 - 8 servo motor program part and run motors 8 - 15 part i m able to to run it. Could you kindly check my program and see what can be done thank you very much guys. I have enclose my program. My current program is program to open and close the fingers of the robot.

Thanks
Jeremy

using Microsoft.Ccr.Core;
using Microsoft.Dss.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using Microsoft.Dss.ServiceModel.DsspServiceBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;
using W3C.Soap;
using i_limb = Robotics.I_Limb;
using System.IO.Ports;

namespace Robotics.I_Limb

{

/// <summary>
/// Implementation class for I_Limb
/// </summary>
[DisplayName("I_Limb")]
[Description("The I_Limb Service")]
[Contract(Contract.Identifier)]
public class I_LimbService : DsspServiceBase

{
//Initialize the port, setting port, baud rate....
private SerialPort port = new SerialPort("COM1", 2400, Parity.None, 8, StopBits.One);


private byte Sync = 0xFF; //Initialize the Sync

private byte M0 = 0x00; //Initialize the Motor num
private byte M1 = 0x01; //M0 equal to Motor 0
private byte M2 = 0x02;
private byte M3 = 0x03;
private byte M4 = 0x04;
private byte M5 = 0x05;
private byte M6 = 0x06;
private byte M7 = 0x07;
private byte M8 = 0x08;
private byte M9 = 0x09;
private byte M10 = 0x0A;
private byte M11 = 0x0B;
private byte M12 = 0x0C;
private byte M13 = 0x0D;
private byte M14 = 0x0E;
private byte M15 = 0x0F;


/// <summary>
/// _state
/// </summary>
private I_LimbState _state = new I_LimbState();

/// <summary>
/// _main Port
/// </summary>
[ServicePort("/i_limb", AllowMultipleInstances=false)]
private I_LimbOperations _mainPort = new I_LimbOperations();

/// <summary>
/// Default Service Constructor
/// </summary>
public I_LimbService(DsspServiceCreationPort creationPort) :
base(creationPort)
{

}

/// <summary>
/// Service Start
/// </summary>
protected override void Start()
{
base.Start();

Console.Clear();

port.Open();//Open the port, so that data can be written to port

position_1();


// Add service specific initialization here.
}

void position_1()
{

while (true)

{

Console.WriteLine("\nSending Data In Process");

System.Threading.Thread.Sleep(1000);
port.Write(new byte[] { Sync, M0, 0x00 }, 0, 3); //writing to the port(COM1), the sync, the servo num, and position
port.Write(new byte[] { Sync, M1, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M2, 0x00 }, 0, 3); //// OPEN FINGERS
port.Write(new byte[] { Sync, M3, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M4, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M5, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M6, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M7, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M8, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M9, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M10, 0x00 }, 0, 3); //// OPEN FINGERS
port.Write(new byte[] { Sync, M11, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M12, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M13, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M14, 0x00 }, 0, 3);
port.Write(new byte[] { Sync, M15, 0x00 }, 0, 3);


System.Threading.Thread.Sleep(2000);

port.Write(new byte[] { Sync, M0, 0xFF }, 0, 3); //writing to the port(COM1), the sync, the servo num, and position
port.Write(new byte[] { Sync, M1, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M2, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M3, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M4, 0xFF }, 0, 3); // CLOSE FINGERS
port.Write(new byte[] { Sync, M5, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M6, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M7, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M8, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M9, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M10, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M11, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M12, 0xFF }, 0, 3); // CLOSE FINGERS
port.Write(new byte[] { Sync, M13, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M14, 0xFF }, 0, 3);
port.Write(new byte[] { Sync, M15, 0xFF }, 0, 3);

System.Threading.Thread.Sleep(2000);



Console.Clear();

System.Threading.Thread.Sleep(1000);//If too fast, set delay

}
}

/// <summary>
/// Get Handler
/// </summary>
/// <param name="get"></param>
/// <returns></returns>
[ServiceHandler(ServiceHandlerBehavior.Concurrent)]
public virtual IEnumerator<ITask> GetHandler(Get get)
{
get.ResponsePort.Post(_state);
yield break;
}
}
}

Adrenalynn
09-03-2008, 01:53 AM
What serial ports are each of them on? Remember that some serial port interrupts are shared.

jems
09-03-2008, 08:38 AM
I only use Serial port com 1. Not too sure what u meant probably you would like to elaborate abit thanks

Adrenalynn
09-03-2008, 11:31 AM
Sorry - I'm just trying to understand better, and I've clearly missed something: You're combining two mini-SSC2 on one com port - I'm not familiar with the mini-SSC. I'd need to look 'em up. I've done a lot of work in C# with the SSC32 fullsize units - in fact, I posted some tutorial code on talking to the SSC32 from C# just a couple days ago.

robot maker
09-03-2008, 03:55 PM
wthout looking at the data like most servo controllers you should be able to have them in a cascoding setup and use only one port and the way he said 0-7 and 8-15 and maybe is a switch on the board or jumper
looking at the data you need to place a jumper on 8-15 ,serial address pins,might be why you are only getting 0-7 working only

now in software i dont know if you need to add address,just start to learn programming
adrenalynn is one of the best here for that


Sorry - I'm just trying to understand better, and I've clearly missed something: You're combining two mini-SSC2 on one com port - I'm not familiar with the mini-SSC. I'd need to look 'em up. I've done a lot of work in C# with the SSC32 fullsize units - in fact, I posted some tutorial code on talking to the SSC32 from C# just a couple days ago.

jems
09-04-2008, 10:56 AM
Yup i had put a jumper over to enable servo motor 0-15 to work but somehow the the hand goes haywire haha...still trying to figure out anyway thanks for the reply so far guys

Adrenalynn
09-04-2008, 11:06 AM
If it goes haywire first thing I'd ask is: Where is the power coming from? The onboard regulator can't handle that many simultaneous servos.

jems
09-04-2008, 11:20 AM
http://img78.imageshack.us/img78/2674/p1010323gr4.jpg

I at first use the batteries pack as i do not want to drain out those batteries i use a power supply at the left back to do my trouble shooting

Adrenalynn
09-04-2008, 11:36 AM
Neat Design!

The power supply is set for regulated power unlimited current, right? (It looks like a 20A+, maybe 30A power supply from here, so if that's the case, I'm less worried about the power supply)

Adrenalynn
09-04-2008, 11:41 AM
Did you set the ID jumper on the second board? (reading the datasheet now)

jems
09-04-2008, 11:50 AM
Wala!! it maybe due to the power supply my power supply i doubt it have so much current...i m sorry if i m not wrong simultaneous servo motor take lots of current rougly how much current is needed?

And sometimes my power supply surge but i didn't give a thought since it work well with 7 motors Thanks probably this is one of the MAIN factors that lead to the haywire. Yup i did put a jumper on the second board. You have been a great help Adrenalynn

Will check my power supply ratings tommorow. Will let update my progress here again thanks...

Adrenalynn
09-04-2008, 12:12 PM
Hi Jems,

I'd expect that power supply to be cleaner - what is it exactly, can't quite tell from the photo (make and model)

I don't think you mentioned what servos you're using and what voltage (Watt's Law tells us that current is related to voltage) you're running them at.

Assuming that you're running let's say eight HS-475HB servos (small hobby servos), and they're all running under load simultaneously - we could expect to see as much as about 6A @ 6v under moderately heavy load - and being a design-geek, I would always try to double my rating if at all possible, but +33&#37; would be my personal minimum. Most components don't like being run at the edges of their ratings.*

Make SURE your logic voltage is CLEAN. Those things will get funky and reset the CPU if it's not.
Servos aren't very tolerant of dirty voltage either - they're meant to run from clean batteries. Do you have an oscilloscope that you can put on that power supply and make sure it's giving you clean DC if you don't trust it?

Happy to help!

* As an aside: If a component is rated for some number maximum, what that *really* means is that they tested some percentage of a lot and found that n_low% failed below that number, n_median% failed at that number, and n_high% were happy beyond that number. The reputation of the company is likely to dictate n_median%. There's always some discreet chance that you got an n_low% part. The more parts in a system, the more likely some critical part is n_low% - that's the reason I advise never pushing a system to its ratings and always build a 33%-100% safety margin into my designs... There's also something called down-binning and up-binning - briefly: you may sometimes get a better part that is stamped as a lesser part. This commonly happens when a company has so many orders for the lesser part that they can't fill it, so they take a more expensive part and "down-bin" it - move it into the lesser part's bin so that they can fill the pending orders at a little lower margin. Alas, some disreputable suppliers have decided to get cute with the "up-binning" - moving a lesser part into a higher priced part bin and passing it off at its absolute limit hoping that some reasonable percentage will survive the tom-foolery. IMHO - those folks should be broiled in their own juices, but that's my own bugaboo... ;)

Matt
09-04-2008, 12:15 PM
^^^ +1 rep for helping other people solve problems :)

Adrenalynn
09-04-2008, 12:52 PM
Thanks Matt! :D

4mem8
09-04-2008, 12:55 PM
Nice solution Adrenalynn, I am also please jems that your problem got solved.

robot maker
09-04-2008, 08:14 PM
nice to see that i was able to help too and you got the problem fixed

jems
09-04-2008, 11:57 PM
http://img391.imageshack.us/img391/8428/p1010384ro9.th.jpg (http://img391.imageshack.us/my.php?image=p1010384ro9.jpg)

I m currently using this power supply the haywire probably is cause of the lack of current. i m unable to run the 8 motors as my max current is only 3A. Currently i m using Hitec HS-65MG, which if i m not wrong it's peak current is at 650mA. For now i looking for a much higher current power supply. Thanks guys as i m new to all this stuff and trying out my own.

Thanks
Jems

Adrenalynn
09-05-2008, 12:13 AM
Well, that is dependant upon what voltage you're running them at, but assuming you're not running them at stall, I think that's a reasonable number to operate from.

Does it work as expected from battery power? If it does, then I think we can safely call it the power supply. If it doesn't we need to look elsewhere.