Society of Robots - Robot Forum

Software => Software => Topic started by: RobotFreak on August 18, 2010, 12:04:17 PM

Title: Hitec Servo Programming for Irobot Create
Post by: RobotFreak on August 18, 2010, 12:04:17 PM
Hi all,

I'm working on a project with an approaching deadline so any immediate help would be great!  I'm trying to get a servo operate with the iRobot Create's command module.  I've wired it with ground and power correctly and the signal line into pin B2 (right eport) on a breakout board.  I'm just testing the code piece by piece to make sure everything is working, so all I want right now is the servo to turn....Unfortunately, that's not happening.  Below is the code, which was partially hacked from admin's iRobot Create mod project.  Any suggestions?

void ServoTurn(void)
{
     //60 degree turn--> .17sec/60 degrees
     delayMs(170);
     while(timer_on)
     {
           //DDRB |= 0x02;
                    PORT_ON(PORTB, 2);
                    delayMs(1);
          PORT_OFF(PORTB, 2);//keep off
          delayMs(1);
     }
}

In the main im just calling this function repeatedly in a while loop to see if I can get any motion at all. Please advise.

Thanks,
IA
Title: Re: Hitec Servo Programming for Irobot Create
Post by: waltr on August 18, 2010, 02:58:59 PM
A standard hobby servo uses a positive pulse between 1 & 2msec to indicate position repeated about every 20msec.

It looks like your code is sending a 1msec high then a 1msec low, if the delay function is properly calibrated. Try upping the delay after the PORT_OFF to 19msec.
Title: Re: Hitec Servo Programming for Irobot Create
Post by: RobotFreak on August 23, 2010, 10:45:40 AM
Hmmm...its still not moving.  You mentioned the pulse specs for a standard hobby servo....could the timing be different for a Hitec 5625MG?  Any other ideas?

The relevant code (slightly modded cuz I had to shift ports) is below:

void ServoInitialize(void)
{
     //Pin B1 as an output (trigger)
     DDRB |= 0x02;
}

void ServoTurn(void)
{
     //60 degree turn--> .17sec/60 degrees
    
     for (i=0; i<=10; i++) //just run 10 cycles
     {
                    PORT_ON(PORTB, 1);
                    delayMs(1);
           PORT_OFF(PORTB, 1);//keep off
           delayMs(19);
     }
}
Title: Re: Hitec Servo Programming for Irobot Create
Post by: waltr on August 23, 2010, 11:04:57 AM
I'm doing some googling and see that the Hitec 5625MG is a Digital servo. But a doc I found states that it uses a 1-2msec, 1.5msec = neutral,  pulse to set position.
Other information I found says that it can be programmed but I don't know what can be changed. This:
http://www.rcuniverse.com/forum/m_5568787/anchors_5568787/mpage_1/key_/anchor/tm.htm#5568787 (http://www.rcuniverse.com/forum/m_5568787/anchors_5568787/mpage_1/key_/anchor/tm.htm#5568787)
seems to indicate some reliability issues.

I couldn't find any info on the Hitec web site of what digital means with this servo or anything about programming it except this:
http://www.hitecrcd.com/products/servos/programmers/hfp-20.html (http://www.hitecrcd.com/products/servos/programmers/hfp-20.html)
 ???

Title: Re: Hitec Servo Programming for Irobot Create
Post by: Razor Concepts on August 23, 2010, 12:12:25 PM
Digital/analog as no affect on the pulse received, it will operate the same as an old analog servo. The digital/analog only refers to the position feedback the servo uses, not something to worry about.
Title: Re: Hitec Servo Programming for Irobot Create
Post by: waltr on August 23, 2010, 12:19:26 PM
Razor,
What about the info that this servo can be 'Programmed'? and the reports of it 'losing' its programmed settings?

Title: Re: Hitec Servo Programming for Irobot Create
Post by: Razor Concepts on August 23, 2010, 12:32:33 PM
It isn't really programming, more like setting adjustment. Even if the servo is left default, or "lost" settings, it will still operate like a normal servo.

The servo should be operating correctly, that single forum post is one in a million, hitec is a very reliable brand.
Title: Re: Hitec Servo Programming for Irobot Create
Post by: RobotFreak on August 23, 2010, 12:50:22 PM
Ok, assuming that there is nothing inherently defective about the Servo (because buying another one is kinda of out of my budget right now, only a last resort really), do you guys see anything else wrong with the code?  Any other possible sources of error?  I tried pulses of 1, 1.5, 2 (high) and no movement at all.  Suggestions please!

BTW, I realized I left out the part where I defined what Port_On means, for example.  Maybe this will provide more insight....Any help is greatly appreciated! Thanks!

/define port functions; example: PORT_ON( PORTD, 6);
#define PORT_ON( port_letter, number )         port_letter |= (1<<number)
#define PORT_OFF( port_letter, number )         port_letter &= ~(1<<number)
#define PORT_ALL_ON( port_letter, number )      port_letter |= (number)
#define PORT_ALL_OFF( port_letter, number )      port_letter &= ~(number)
#define FLIP_PORT( port_letter, number )      port_letter ^= (1<<number)
#define PORT_IS_ON( port_letter, number )      ( port_letter & (1<<number) )
#define PORT_IS_OFF( port_letter, number )      !( port_letter & (1<<number) )

~IA