code conversion


Closed Thread
Results 1 to 20 of 20

Thread: code conversion

  1. #1
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42

    Default code conversion

    hi, i was wondering if it is possible to convert codes from picbasic pro to picbasic. i have a program in pro version and i only recently purchased the basic vesion... hehe couldn't afford the pro anyways can anyone help me or teach me. kinda new to this and need some help from ya all...

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    We can try if you post the code to be converted. Could be interesting...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default the code to be converted

    'Declare variables
    x1 VAR BYTE
    x2 VAR BYTE
    y1 VAR BYTE 'The movement is adjusted by varying the Y1 AND Y2 numbers in each movement.
    y2 VAR BYTE
    lp VAR BYTE

    'Declare array
    b VAR BYTE [12]
    Initialize array variables
    b(0) = 148 'Right ankle’ (vertical)
    b(1) = 121 'Right ankle’ (horizontal)
    b(2) = 204 'Right knee’
    b(3) = 126 'Right hip’
    b(4) = 150 'Left ankle’ (vertical)
    b(5) = 178 'Left ankle’ (horizontal)
    b(6) = 101 'Left knee’
    b(7) = 180 'Left hip’
    b(8) = 0 'counter’
    b(9) = 0 'counter’
    b(10) = 0 'counter’
    b(11) = 0 'Dummy value’



    Start:
    'Holding loop that holds upright position 3 seconds before moving

    b(8) = b(8) + 1
    GoSub servoout
    IF b(8) < 180 Then GoTo start
    b(8) = 0 'Reset the loop counter’
    '__________________
    For b(10) = 1 TO 3 'Take 3 steps forward’
    '__________________
    'Leg movement For one whole step
    '__________________

    'First movement
    x1 = 0 'Servomotor 0
    x2 = 4 'Servomotor 4
    y1 = 129 'Tilt right ankle (horizontal)
    y2 = 135 'Tilt left ankle (horizontal)
    lp = 106 'Loop counter
    GoSub m1
    '___________________

    'Second movement
    x1 = 5 'Servomotor 5
    x2 = 6 'Servomotor 6
    y1 = 2 'Left ankle (vertical)
    y2 = 70 'left knee
    lp = 140 'Loop counter
    GoSub m3
    '___________________

    'Third movement
    x1 = 4 'Servomotor 4
    x2 = 7 'Servomotor 7
    y1 = 150 'Left ankle
    y2 = 160 'Left hip
    lp = 75 'Loop counter
    GoSub m3
    '___________________

    'Fourth movement
    x1 = 1 'Servomotor 1
    x2 = 5 'Servomotor 5
    y1 = 132 'Straighten ankle
    y2 = 200 'Straighten ankle
    lp = 90 'Loop counter
    GoSub m3
    '___________________

    'Fifth movement
    x1 = 6 'Servomotor 6
    x2 = 0 'Servomotor 0
    y1 = 85 'Left knee
    y2 = 140 'Straighten ankle
    lp = 96 'Loop counter
    GoSub m2
    '___________________


    'Sixth movement
    x1 = 0 'Servomotor 0
    x2 = 4 'Servomotor 4
    y1 = 167 'Tilt right ankle
    y2 = 169 'Tilt left ankle
    lp = 80 'Loop counter
    GoSub m2
    '___________________

    'Seventh movement
    x1 = 6 'Servomotor 6
    x2 = 5 'Servomotor 5
    y1 = 101 'Tilt knee
    y2 = 178 'Tilt ankle
    lp = 95 'Loop counter
    GoSub m3
    '___________________

    'Eighth movement
    x1 = 2 'Servomotor 2
    x2 = 1 'Servomotor 1
    y1 = 244 'Right ankle
    y2 = 104 'Right knee
    lp = 140 'Loop counter
    GoSub m3
    '___________________


    'Ninth movement
    x1 = 3 'Servomotor 3
    x2 = 7 'Servomotor 7
    y1 = 140 'Right hip
    y2 = 180 'Left hip
    lp = 80 'Loop counter
    GoSub m2
    '___________________

    'Tenth movement
    x1 = 1 'Servomotor 1
    x2 = 2 'Servomotor 2
    y1 = 121 'Right ankle
    y2 = 204 'Right knee
    lp = 150 'Loop counter
    GoSub m3
    '___________________

    'Eleventh movement
    x1 = 0 'Servomotor 0
    x2 = 4 'Servomotor 4
    y1 = 121 'Straighten right ankle
    y2 = 204 'Straighten left ankle
    lp = 150 'Loop counter
    GoSub m1
    '___________________

    'Twelfth movement
    x1 = 5 'Servomotor 5
    x2 = 6 'Servomotor 6
    y1 = 217 'Left ankle
    y2 = 70 'left knee
    lp = 144 'Loop counter
    GoSub m3
    '___________________

    'Thirteenth movement
    x1 = 4 'Servomotor 4
    x2 = 3 'Servomotor 3
    y1 = 133 'Left ankle
    y2 = 126 'Right hip
    lp = 66 'Loop counter
    GoSub m1
    '___________________

    'Fourteenth movement
    x1 = 6 'Servomotor 6
    x2 = 5 'Servomotor 5
    y1 = 101 'Left knee
    y2 = 178 'Left ankle
    lp = 144 'Loop counter
    GoSub m3
    ‘___________________


    'Fifteenth movement
    x1 = 0 'Servomotor 0
    x2 = 4 'Servomotor 4
    y1 = 148 'Left knee
    y2 = 150 'Left ankle
    lp = 115 'Loop counter
    GoSub m2
    '___________________
    Next b(10) 'Next Step
    '___________________

    Hold:
    GoSub servoout
    GoTo hold

    ‘____________________

    Servoout:
    'Output servomotor position(s)
    PORTB = 0 'Prevent signal inversion

    Right Leg
    PulsOut PORTB.0, b(0) 'Send current servo 1 position out
    PulsOut PORTB.1, b(1) 'Send current servo 2 position out
    PulsOut PORTB.2, b(2) 'Send current servo 3 position out
    PulsOut PORTB.3, b(3) 'Send current servo 4 position out

    Left Leg
    PulsOut PORTB.4, b(4) 'Send current servo 5 position out
    PulsOut PORTB.5, b(5) 'Send current servo 6 position out
    PulsOut PORTB.6, b(6) 'Send current servo 7 position out
    PulsOut PORTB.7, b(7) 'Send current servo 8 position out
    Pause 5 '5 milisescond delay to generate 50Hz signal
    Return 'To servomotors
    ‘_____________________

    'The delay routines
    m1: '(Negative increment (s) -, -)
    b(8) = b(8) + 1
    IF b(9) = 2 Then m12
    b(9) = b(9) + 1
    GoTo m13

    m12:
    b(x1) = b(x1) - 1
    b(x2) = b(x2) -1
    b(9) = 0

    m13:
    IF b(x1) < y1 Then
    b(x1) = y1
    EndIF
    IF b(x2) < y2 Then
    b(x2) = y2
    EndIF
    GoSub servoout
    IF b(8) < lp Then m1
    b(x1) = y1
    b(x2) = y2
    b(8) = 0
    b(9) = 0
    Return
    '______________________
    M2: '(Positive increment (s) +, +)
    b(8) = b(8) + 1
    IF b(9) = 2 Then m22
    b(9) = b(9) + 1
    GoTo m23

    m22:
    b(x1) = b(x1) + 1
    b(x2) = b(x2) + 1
    b(9) = 0

    m23:
    IF b(x1) > y1 Then
    b(x1) = y1
    EndIF
    IF b(x2) > y2 Then
    b(x2) = y2
    EndIF
    GoSub servoout
    IF b(8) < lp Then m2
    b(x1) = y1
    b(x2) = y2
    b(8) = 0
    b(9) = 0
    Return
    '______________________

    M3: '(Positive-Negative increment (s) +, -)
    b(8) = b(8) + 1
    IF b(9) = 2 Then m32
    b(9) = b(9) + 1
    GoTo m33

    m32:
    b(x1) = b(x1) + 1
    b(x2) = b(x2) -1
    b(9) = 0

    m33:
    IF b(x1) > y1 Then
    b(x1) = y1
    EndIF
    IF b(x2) < y2 Then
    b(x2) = y2
    EndIF
    GoSub servoout
    IF b(8) < lp Then m3
    b(x1) = y1
    b(x2) = y2
    b(8) = 0
    b(9) = 0
    Return
    '______________________

  4. #4
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default what the code is for

    hi mister_e.... thanks for the reply... just posted the code.. its for a walker robot that i am building wif 8 servomotors using the PIC16F84 as the brains. the problem is that when i got the book i never realised it was written for the pro version. hope you can help me. i noticed its kinda long after posting the codes... here i have attached the walker code as a txt file.
    Attached Files Attached Files
    Last edited by saturnX; - 9th September 2005 at 09:01.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well the only thing is see is to change those () for [] when using array var.

    After that... can't see what else it have to be modfied.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Smile thanks..

    hi steve.. thanks for the update.... i forgot to update the post here but i managed to track down a copy of PICBasic Pro from a friend of mine and got him to compile the program for me. lol solves the problem and having to change the codes. Thanks anyways... oh any idea where i could find a virtual breadboard? not the one from http://www.muvium.com/ (previously virtualbreadboard.com). I came across a few versions written in java but does not have the 16F84 chip. anything that can help?

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Some will hate me but i assume my words 100%. I hate Virtual stuff as they never give the truth... well maybe close to but i'd and i'll never use and trust that kind of stuff. I still prefer spending time to build a real one... yeah i have that old manner to work.

    SO probably ISIS, VSM, PROTEUS( i can't remind wich is wich) from Labcenter could help.. see info on the link bellow
    http://www.labcenter.co.uk/

    Some said it's a great tool... can't commernt on. I have it, but never tested and i'll probably never.

    Sorry!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I'd be interested in knowing the name and author of this book. I have a book for a walking robot that uses just 3 servos. I'm interested in the 8 servo one.

    Bart

  9. #9
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default 3 motor robot

    The book is called PIC robotics by john iovine. Am interested in your 3 motor robot. Where can i have a look at that project???
    -·=»‡«=·- saturnX -·=»‡«=·-

  10. #10
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    Thanks. I'll check into that book.

    The book I bought is called "Insectronics" by Karl Williams.

    Web site: http://www.thinkbotics.com/

    I haven't built it yet, don't know if I ever will because I'm holding out for something with a bit more in the way of degrees of freedom.

    I looked at your code here too and as much as I wouldn't genrally disagree with Mister E (who is 1000X smarter than I) I don't think you can just make a couple changes to get it to work in PicBasic. The ENDIF statement alone would grind it to a halt so you are lucky to have found someone who can compile it for you with the Pro version.

    Bart

  11. #11
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    haha you know what though i managed to get a copy of the pro version last minute from a friend of mine. thank goodness! saved me a lot of work. lol... thanks for the link too. will look into it later on.
    -·=»‡«=·- saturnX -·=»‡«=·-

  12. #12
    Raycher's Avatar
    Raycher Guest


    Did you find this post helpful? Yes | No

    Default

    Hi, the code were used for a insec bot. I used the book called "Insectronics" by Karl Williams to built a six legged insec - works pretty well once one can program the chip.

    Regards
    r

  13. #13
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    i guess i have to go get the book huh bartman... lol... thanks raycher for the post
    -·=»‡«=·- saturnX -·=»‡«=·-

  14. #14
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I guess if you want it you'll need to buy it, yes. I don't want to sell or give mine away as it has useful information that may come in handy.

    I ordered the book you mentioned from Amazon. Came to $20.00 with shipping which seemed pretty reasonable.

    Bart

  15. #15
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    that isn't a too bad price i guess. have fun with it when you get the book. the problem about the book is that i find the author some times forget that there are newbies to the whole PIC programming and basic robotics so some of his projects seem a little way advance. plus when i first got the book and read the first few chapters i was under the impression that the projects would be written for PICBasic Compilers along with the Pro Compilers. when i finally purchased PicBasic i couldn't compile his codes for the walking robot which were written for the pro versions. i was new then some 20 posts ago Strange thing was the earlier projects before the walking robot had both basic and pro version of codes.
    -·=»‡«=·- saturnX -·=»‡«=·-

  16. #16
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I received the book you mentioned yesterday. I guess I should have taken a better look at the code you posted. I was thinking it was for a hexapod walking robot, but it really is for a bipedal robot you are referring to.

    The book I mentioned only deals with the haxapod walker so skip it if you are building a bipedal.

    Bart

  17. #17
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    sorry about that bartman... definately a miss communication. lols... i have this other book on hexapod walkers. first i have to go find it, lent it to a friend of a friend and has not returned it to me. will post it when i get it back. sell the book back on amazon maybe?
    -·=»‡«=·- saturnX -·=»‡«=·-

  18. #18
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    Yeah, we weren't on the same page, but that's okay. I'm still going to keep the book. Lots of useful information in it that may come in handy and I didn't spend a lot of money on it. If you get the name of that other book about the hexapod I'm interested in that too!

    Bart

  19. #19
    Join Date
    Sep 2005
    Location
    Malaysia
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    bartman.. not too sure if you still read this thread but just to update you.. the book that i lent to a friend of a friend... guess what that dude is not even in the country anymore and he took my book with him. but in the book that you bought there is a Hexapod Walker (Chapter 10) but its a basic one that you find on a lot of personal hobbist *there should be a spell check on the forum * websites. I suppose the reason its in the book is because it was easy to build for beginners. I just bought the AMPHIBIONICS the other day. next project at hand is building the robot snake.
    -·=»‡«=·- saturnX -·=»‡«=·-

  20. #20
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    Yes, I saw that. I am hoping to eventually find information on something with six legs and 12 servos. I know there are kits out there, but I'd like it to be more Do-It-Yourself.

    Bart

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts