Servo Motor on HandyBoard V1.21

4 replies [Last post]
zico
Title: NooBot+
Joined: 12/03/2009
Posts:
BotPoints: 16
User offline. Last seen 10 years 30 weeks ago.

Hello,
I am trying to control a Servo motor from Digital port 9 on a HandyBoard V1.21 (with no expansion board). I have followed the instructions:
http://handyboard.com/hb/software/libraries/servo-motors/

1. I copied the files "servo_a7.icb" and "servo_a7.asm" to the Interactive c - Lib - Handyboard folder.
2. I then loaded "servo_a7.icb" into IC, via a .lis file as the ICGUI won't open *.icb files only *.is, *.c or *.lis. Anyway this appears to download fine as when I look at the list of functions servo_a7_init is listed.
3. When I try to download another program with the line "servo_a7_init (1);". I get an error "servo_a7_init function undefined".
4. It seems that when I download my program it removes the "servo_a7_init" function

Does anyone have an ideas as to what I am doing wrong?
Regards,
Zico.

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

Hi Zico,

What version of IC are you using? KIPR IC has been rewritten several times during the XBC era, and I suspect that Handy Board wasn't thoroughly tested after these rewrites. (I remember finding glitches in RCX in later versions of KIPR IC.) In fact, when I mentioned ICB to the IC 6.x and 7.x maintainer, he didn't know that the feature existed, meaning he probably wouldn't have noticed if it had been broken.

You might want to try an older version of IC, including the 2.x version on HandyBoard.com. Let us know if you have any luck.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

zico
Title: NooBot+
Joined: 12/03/2009
Posts:
BotPoints: 16
User offline. Last seen 10 years 30 weeks ago.

Hi Jeremy,
I have it working now almost!
It's OK once I use the line #use "servo_a7.lis" as this file loads the servo_a7.icb file. My problem was that I loaded it manually and every time I loaded my actual program it removed the servo_a7.

Anyway, now that this is resolved, I can get the servo to move. However the line " servo_a7_pulse =200;" doesn't control the servo movement. I can only seem to do this by shortening or lengthening the sleep time. I have attached my code if you could see if I am doing something wrong?

I also don't seem to be able to get the servo to move in the reverse direction?

Regards,
Zico.

The code I use is as follows:
#use "servo_a7.lis"

void main()
{
while(1)
{
if (start_button ())
{
printf("G'day!!!\n");
beep();
sleep(1.0);
beep();
servo_a7_init(1);
servo_a7_pulse =200;
sleep(0.3);
servo_a7_init(0);
}
else if (stop_button ())
{
printf("Hello\n");
beep();
sleep(1.0);
beep();
sleep(1.0);
servo_a7_init(1);
servo_a7_pulse =-2000;
sleep(0.02);
servo_a7_init(0);

}

}

}

zico
Title: NooBot+
Joined: 12/03/2009
Posts:
BotPoints: 16
User offline. Last seen 10 years 30 weeks ago.

Hello,

I forgot to say that I am using IC ver. 4.3

Regards,

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

I haven't used this particular library, but servo positions are usually measured as a pulse duration. The docs for the library you linked to say that the units for the lib work out to a range of 400 to 4800. 200 will strain the servo at one extreme (possibly damaging the servo), and I have no clue how a negative duration would be interpreted (but it would almost certainly not be desirable). Try numbers within the 400 to 4800 range and let us know if you have any luck.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS