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.
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.
Tray adding a pace delay (see pag 140 PBP manual) number represent milliseconds delay between characters.
example:
This will delay 1 millisecond, perhaps you will need it longer.Code:SEROUT2 Lleg,396,1,[255,5,125,101,181,154,126,182]' B6 'repeated 7X,
Al.
All progress began with an idea
Still can't get it to work.
Any other suggestion?
I really need help from forum members.
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?
Dave
Always wear safety glasses while programming.
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
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
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.
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.Code: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
Now for some basic code to see if all is working.
When the above is working we can do a simple serial output to a terminal. MCS has on built in.Code:'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
Dave
Always wear safety glasses while programming.
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]
Last edited by azmax100; - 29th July 2009 at 16:43.
Bookmarks