PDA

View Full Version : Serout to serial servo



azmax100
- 17th July 2009, 14:20
Hi,

I need to send serial protocol to serial servo. I have success with BS2 and want to transfer to PIC as it has more memory.
But I cant make the servo moving using Picbasic Pro.

I am doing this for a humanoid robot.

I am using PIC 16F877A for testing.

Please Help.

Here I include my BS2 code and Picbasic code.

BS2 code
[QUOTE]
' {$STAMP BS2}
' {$PBASIC 2.5}



Lleg CON 8

PAUSE 1000

SEROUT Lleg,396,[255,5,0,101,181,154,00,186]
SEROUT Lleg,396,[255,5,125,101,181,154,126,182]
SEROUT Lleg,396,[255,5,124,101,181,154,125,180]
SEROUT Lleg,396,[255,5,124,101,181,154,124,179]
SEROUT Lleg,396,[255,5,123,101,181,154,124,178]'
SEROUT Lleg,396,[255,5,123,101,181,154,123,177]
SEROUT Lleg,396,[255,5,122,101,181,154,122,175]
SEROUT Lleg,396,[255,5,121,101,181,154,122,174]
SEROUT Lleg,396,[255,5,121,101,181,154,121,173]
SEROUT Lleg,396,[255,5,120,101,181,154,120,171]
SEROUT Lleg,396,[255,5,120,101,181,154,120,171]
SEROUT Lleg,396,[255,5,119,101,181,154,119,169]
SEROUT Lleg,396,[255,5,118,101,181,154,118,167]
SEROUT Lleg,396,[255,5,116,102,182,154,118,167]
SEROUT Lleg,396,[255,5,113,103,184,154,118,167]
SEROUT Lleg,396,[255,5,111,103,184,154,118,165]
SEROUT Lleg,396,[255,5,110,103,184,154,118,166]
SEROUT Lleg,396,[255,5,109,103,184,154,118,165]
SEROUT Lleg,396,[255,5,107,103,184,154,118,163]
SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT Lleg,396,[255,5,120,73,184,154,120,146]/QUOTE]



Picbasic Pro Code:
[QUOTE]
include "BS2DEFS.bas"
DEFINE OSC 20
DEFINE SER2_BITS 8
OPTION_REG.7 = 0
Trisb = %00000000 'Setup port b as all outputs
Lleg Var portb.0

PAUSE 1000

SEROUT2 Lleg,396,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,
SEROUT2 Lleg,396,[255,5,124,101,181,154,125,180]' B4 'raise leg at hip
SEROUT2 Lleg,396,[255,5,124,101,181,154,124,179]' B3
SEROUT2 Lleg,396,[255,5,123,101,181,154,124,178]' B2
SEROUT2 Lleg,396,[255,5,123,101,181,154,123,177]' B1
SEROUT2 Lleg,396,[255,5,122,101,181,154,122,175]' AF
SEROUT2 Lleg,396,[255,5,121,101,181,154,122,174] ' AE
SEROUT2 Lleg,396,[255,5,121,101,181,154,121,173]' AD
SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
SEROUT2 Lleg,396,[255,5,119,101,181,154,119,169]' A9
SEROUT2 Lleg,396,[255,5,118,101,181,154,118,167]' A7 ' repeated 16X
SEROUT2 Lleg,396,[255,5,116,102,182,154,118,167] 'other joints begin motion
SEROUT2 Lleg,396,[255,5,113,103,184,154,118,167]' A7
SEROUT2 Lleg,396,[255,5,111,103,184,154,118,165]
SEROUT2 Lleg,396,[255,5,110,103,184,154,118,166]
SEROUT2 Lleg,396,[255,5,109,103,184,154,118,165]
SEROUT2 Lleg,396,[255,5,107,103,184,154,118,163]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146] ' 73 second servo
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]/QUOTE]

aratti
- 17th July 2009, 16:36
With OPTION_REG.7 = 0 you have enabled the Weak Pull-UP's and this could disturb the serial connection.

Tray this code:


INCLUDE "BS2DEFS.bas"
DEFINE OSC 20

ADCON1 = 7 ' all digitals
CMCON = 7 ' all digitals

TrisB = %00000000 'Setup port b as all outputs
Lleg Var portB.0

PAUSE 1000

SEROUT2 Lleg,396,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,
SEROUT2 Lleg,396,[255,5,124,101,181,154,125,180]' B4 'raise leg at hip
SEROUT2 Lleg,396,[255,5,124,101,181,154,124,179]' B3
SEROUT2 Lleg,396,[255,5,123,101,181,154,124,178]' B2
SEROUT2 Lleg,396,[255,5,123,101,181,154,123,177]' B1
SEROUT2 Lleg,396,[255,5,122,101,181,154,122,175]' AF
SEROUT2 Lleg,396,[255,5,121,101,181,154,122,174] ' AE
SEROUT2 Lleg,396,[255,5,121,101,181,154,121,173]' AD
SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
SEROUT2 Lleg,396,[255,5,120,101,181,154,120,171]' AB
SEROUT2 Lleg,396,[255,5,119,101,181,154,119,169]' A9
SEROUT2 Lleg,396,[255,5,118,101,181,154,118,167]' A7 ' repeated 16X
SEROUT2 Lleg,396,[255,5,116,102,182,154,118,167] 'other joints begin motion
SEROUT2 Lleg,396,[255,5,113,103,184,154,118,167]' A7
SEROUT2 Lleg,396,[255,5,111,103,184,154,118,165]
SEROUT2 Lleg,396,[255,5,110,103,184,154,118,166]
SEROUT2 Lleg,396,[255,5,109,103,184,154,118,165]
SEROUT2 Lleg,396,[255,5,107,103,184,154,118,163]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146] ' 73 second servo
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]
SEROUT2 Lleg,396,[255,5,120,73,184,154,120,146]


......... and see if it works.

Al.

azmax100
- 19th July 2009, 08:08
Hi Mr aratti,

I've tried the code but still didn't work.

I can do it easily with BS2 but it seem difficult with Pic. It's almost the same between Pbasic(BS2) and Picbasic Pro(Pic) but yet its not working.

aratti
- 19th July 2009, 16:48
Tray adding a pace delay (see pag 140 PBP manual) number represent milliseconds delay between characters.

example:


SEROUT2 Lleg,396,1,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,


This will delay 1 millisecond, perhaps you will need it longer.

Al.

azmax100
- 28th July 2009, 18:32
Still can't get it to work.

Any other suggestion?

I really need help from forum members.

mackrackit
- 28th July 2009, 20:01
I have to ask. Can you make an LED blink with the correct timing?
What do you get if you connect the PIC to a terminal? Is it sending anything?

azmax100
- 29th July 2009, 05:17
I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.

Archangel
- 29th July 2009, 06:49
I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.Hi azmax100,
Let's pretend we never used a BS2, and we are using just PICs, and lose Include BS2Defs . . . and all their hokey renaming of ports cause it really just confuses hell out of me anyway.
Go back to the basics, check your config settings, did you set tris and port registers properly, disable all the analog . . . does your chip have ansel, adcon, adcon1, adcon0, cmcon, cmcon0, cmcon1, . . . . Did you DEFINE OSC ? Does it match the config ? Is mclr or mclre enabled? If so do you have a pullup resistor ? Make sure the LED is not reverse biased (this is an issue, I have LEDs where the Anode is the long lead and I have LEDs where the cathode is the long lead). Is the power supply voltage correct and of sufficient power output? Is it filtered properly? Make sure LVP is disabled, until all is working, enable PWRTE and WDT

mackrackit
- 29th July 2009, 10:29
I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.
I was afraid of that. So, like Joe said, lets start from scratch.

First, these are a must read:
http://www.picbasic.co.uk/forum/showthread.php?t=561
http://www.picbasic.co.uk/forum/showthread.php?t=562
http://www.picbasic.co.uk/forum/showthread.php?t=543

Now for the configs. In the PBP directory you will see *.inc files as the thread above talks about. Comment out the correct lines. Make it look like this.


NOLIST
ifdef PM_USED
LIST
include 'M16F87xA.INC' ; PM header
; device pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F877A, r = dec, w = -302
INCLUDE "P16F877A.INC" ; MPASM Header
; __config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST

I will assume you are using Micro Code Studio. Make sure MPLAB is installed and have MCS set to use MPASM. This is not really needed for this PIC but in the future it will be so we will start off right. In MCS tool bar - View-Compiler and Program Options- then the Assembler tab. Check use MPASM.

Now for some basic code to see if all is working.


'16F877A HEART_BEAT
DEFINE OSC 20
'####################
@ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF &_BODEN_OFF
ADCON1=7
CMCON=7

START:
HIGH PORTD.2
PAUSE 100
LOW PORTD.2
PAUSE 100
GOTO START

When the above is working we can do a simple serial output to a terminal. MCS has on built in.

azmax100
- 29th July 2009, 16:40
I am very sorry to trouble you people with my problem. I really appreciate your help.
Now I can make the leg moving but after three or four move it will stall. It's seem like I have to off and on the signal voltage to make it move smoothly. I don't know what happen.
This is my first time with serial servo and humanoid.

here is my code:
[/CODE]

include "BS2DEFS.bas"

@ DEVICE HS_OSC ' System Clock options
@ DEVICE LVP_OFF ' Low-Voltage Programming

DEFINE OSC 20
ADCON1 = 7 ' all digitals
CMCON = 7 ' all digitals

TrisB = %00000000 'Setup port b as all outputs
Trisd = %00000000
PortB = %00000000
PortD = %00000000

Rleg var portb.2
Lleg Var portd.1




pause 1000



PAUSE 1000
GOSUB Stand
GOSUB PostR
gosub R1a
pause 1000
gosub R2a
pause 1000
gosub R3a
pause 1000
gosub R4a
pause 1000
gosub R5a
pause 1000
gosub R6a
pause 1000
end
R1a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
SEROUT2 Lleg,396,20,[255,5,90,110,161,144,145,145]
PAUSE 500
return

R2a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
SEROUT2 Lleg,396,20,[255,5,40,110,161,144,145,95]
PAUSE 500
return

R3a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,150,145,94,111,120,115]
SEROUT2 Rleg,396,20,[255,5,150,145,94,111,120,115]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
SEROUT2 Lleg,396,20,[255,5,40,150,161,144,145,135]
PAUSE 500
return

R4a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
SEROUT2 Lleg,396,20,[255,5,40,60,131,144,145,15]
PAUSE 500
return
R5a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
PAUSE 1000
Return
R6a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
SEROUT2 Lleg,396,20,[255,5,50,110,161,94,145,55]
PAUSE 1000
Return
R7a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
PAUSE 1000
Return
R8a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,105,65]
PAUSE 1000
return
R9a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
SEROUT2 Lleg,396,20,[255,5,50,110,161,144,145,105]
PAUSE 1000
return
R10a:
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
SEROUT2 Lleg,396,20,[255,5,140,110,161,144,120,170]
PAUSE 1000
return

Stand:
SEROUT2 Lleg,396,20,[255,5,125,110,161,144,120,155]
SEROUT2 Lleg,396,20,[255,5,125,110,161,144,120,155]
SEROUT2 Lleg,396,20,[255,5,125,110,161,144,120,155]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,135,110]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,135,110]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,135,110]
PAUSE 1000
RETURN

PostR:
SEROUT2 Lleg,396,20,[255,5,130,110,161,144,110,150]
SEROUT2 Lleg,396,20,[255,5,130,110,161,144,110,150]
SEROUT2 Lleg,396,20,[255,5,130,110,161,144,110,150]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
SEROUT2 Rleg,396,20,[255,5,130,145,94,111,110,85]
PAUSE 1000
RETURN



[CODE]

mackrackit
- 29th July 2009, 17:30
Joe and I must be good!!! You went from not being able to make an LED blink to having the leg move very quickly :D

Take a look at the flow of your code.

I see it GOSUBing right to END. I do not see any place that LOOPs.

azmax100
- 30th July 2009, 02:55
The code is for the left and right leg. I am using gosub to make the leg move in different angle.
I am not sure either this is the correct way but I am just trying a lot of time to makes thing correct.

The angle of the leg move up to gosub R2a then it stall. The servo is holding the position and not moving to other angle.

Am I doing the right thing?

One more thing. I got this when I compiled the code -

Warn Isobot1.ASM 893 :[102] code cross bounadry @800h
Warn Isobot1.ASM 1549 :[102] code cross bounadry @1000h


What is that mean.

mackrackit
- 30th July 2009, 03:50
One of your questions and maybe future questions is answered here.
http://www.picbasic.co.uk/forum/showthread.php?t=11116

your code.

If that is just the leg routine and you have more then I do not see a problem there. And with it only getting part way through it....

Kind of sounds like it good be a power supply problem causing a brown out. Can you monitor the voltage coming into the PIC? Maybe add if you do not have one a capacitor or two between VSS and VDD.

At this point a schematic, configs and the whole code might help us figure it out. I am guessing you did rewrite this as Joe suggested and loose the BS2 stuff?

Archangel
- 30th July 2009, 17:13
I am very sorry to trouble you people with my problem. I really appreciate your help.
Wow, do not be sorry, it is a challenge, not a trouble, if we were not happy to help, we would not do it.
You have the code tags reversed, that is why they did not work for you, the [/code] goes after the code


Now I can make the leg moving but after three or four move it will stall. It's seem like I have to off and on the signal voltage to make it move smoothly. I don't know what happen.
This is my first time with serial servo and humanoid.

I agree with Dave, make sure to bypass the power supply line going to the servos, I would put a capacitor at each servo's connection.

I see it GOSUBing right to END. I do not see any place that LOOPs. Again I agree with Dave, your code executes to the end and has nowhere to go, put a label ( main: ) before your sub directories and a goto main after them or a goto somewhere else you want it to go, you need some kind of loop that checks for YOUR input, since this robot will likely be under Your control. I understand this is just 1 legs control software, but until it becomes just a part of a larger program, it should have some way back to you, yes the returns should do it everytime, but it only cost a word or 2 to have the insurance policy.
Try your PIC on a separate power supply (batteries) from your servos, as Dave pointed out it may be browning out or just getting a bunch of hash from the servos into it's power input.

Archangel
- 30th July 2009, 17:19
I am guessing you did rewrite this as Joe suggested and loose the BS2 stuff?
He didn't remove the include "BS2 stuff" and replace it with include "modedefs.bas" but he is using PBP nomenclature now. He is getting there.

mackrackit
- 30th July 2009, 18:12
I glossed over the part about being a trouble. Everything Joe said and I will add...
Pick a subject that you " think" you know. Then find someone that wants to learn it. Try teaching them or help them with a problem. You will quickly find out how much you really know. May not be as much as you thought.

For me this forum is a learning tool. So keep trying new things and share your problems.

azmax100
- 7th August 2009, 11:21
Hi,

Sorry for late reply.

I check the batteries in fact I fully charge it and try it again with additional
main: in the code but the problem remain the same.

Actually I am hacking an Isobot Robot.

Here's the video:http://www.youtube.com/watch?v=HR84q3zRKT8

By the way thanks to all who answered to this forum.

Archangel
- 7th August 2009, 17:40
Hi,


Actually I am hacking an Isobot Robot.

Here's the video:http://www.youtube.com/watch?v=HR84q3zRKT8

By the way thanks to all who answered to this forum.
Hey isn't that Michael Jackson ? :D looks like it's ready to do some Kung Foo . . ., teach that thing to moonwalk . . . What was the problem again? Oh yeah, servo stalls. Maybe it is losing the data connection when it goes into those antics, bad wire, bad connection . . . Try enabling WDT in case micro is locking up. You have a lot of PAUSE 1000 in your code. I would change them to for next loops, or better yet make a subroutine for next with say 0 to 100 pause 10 and when you move on to using interrupts your code will respond much faster. In thinking about it, I would move those serial routines to use HSEROUT and hardware serial routines, instead of all those bit banging serout2 commands.

azmax100
- 12th August 2009, 11:01
Joe S,

What do you mean WDT.Can you please elaborate more.

If i use the Hserout do I have to use Include BS2defs.bas.

mackrackit
- 12th August 2009, 11:27
WDT. Watch Dog Timer. This is one of the config settings. Look at the PICs data sheet.
You do not need the BS2 stuff with SEROUT2 or HSEROUT. In fact, being you still have that in you code might be causing some of the trouble. Not sure though.

Archangel
- 12th August 2009, 16:46
Joe S,

What do you mean WDT.Can you please elaborate more.

If i use the Hserout do I have to use Include BS2defs.bas.

http://www.picbasic.co.uk/forum/showthread.php?t=543
I strongly suggest everyone new to PICs read through all the posts in the FAQ section, really a lot of good things in there. WDT is what it it's name implies, it , like a watch dog, keeps an eye on your pic, and if allowed to time out, it resets it. After your code is perfect, turn it off if you like.


If i use the Hserout do I have to use Include BS2defs.bas.
I wouldn't put it in. It basically just redefines a bunch of stuff so you can use basic stamp syntax, it also includes modedefs.bas automatically, which you do not need to use hardware serial port either. You do need it (modedefs.bas) if using serout or serout2 and want to use the aliased baud notations like N9600 . . . instead of mode 396 . . . As far as BS2defs goes, I am assuming a 2 to 7 dollar PIC beats spending what . . . ? . . . 25 for a stamp ? I think you will not go back, so it's better to put that chapter behind you, with fond memories (of the money you spent), and get up to speed with PIC syntax. IMHO