How to get .hex from this code??


Results 1 to 13 of 13

Threaded View

  1. #5
    Join Date
    Jun 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Thank you guys for reply.
    Doesn't the code from Listing 3 below have to be somehow modified?
    Code:
    'Manual control of two servomotors using 2 SPDT switches
    
    'Use B1 to hold pulsewidth variable for servo 1
    'Use B2 to hold pulsewidth variable for servo 2
    
    'Initialize Variables
    
    B1 = 150
    B2 = 150
    
    'start servo 1 at center position
    'start servo 2 at center position
    
    start:
       IF pin1 = 0 Then left1
       IF pin2 = 0 Then right1
       IF pin4 = 0 Then left2
       IF pin5 = 0 Then right2
       PulsOut 0, B1
       PulsOut 3, B2
       Pause 18
       GoTo start
    
    'check for switch closures
    'is sw1 left active?
    'is sw1 right active?
    'is sw2 left active?
    'is sw2 right active?
    'send current servo 1 position out
    'send current servo 2 position out
    
    'Routines for Servomotor 1
    left1:
       B1 = B1 + 1
       PulsOut 0, B1
       PulsOut 3, B2
       Pause 18
       IF B1 > 225 Then max1
       GoTo start
    right1:
       B1 = B1 - 1
       PulsOut 0, B1
       PulsOut 3, B2
       Pause 18
       IF B1 < 75 Then min1
    GoTo start
    max1:
       B1 = 225
       GoTo start
    min1:
       B1 = 75
       GoTo start
    
    
    
    'increase the pulse width
    'send current B1
    'send current B2
    'set frequency update about 50 hz
    'maximum 2.25 millisecond
    
    
    'decrease the pulse width
    'send current B1
    'send current B2
    'set frequency update about 50 hz
    'minimum .75 millisecond
    
    
    'cap max B1 at 2.25 milliseconds
    
    
    'cap min B1 at .75 millisecond
    
    'Routines for Servomotor 2
    left2:
       B2 = B2 + 1
       PulsOut 0, B1
       PulsOut 3, B2
       Pause 18
       IF B2 > 225 Then max2
       GoTo start
    right2:
       B2 = B2 - 1
       PulsOut 0, B1
       PulsOut 3, B2
       Pause 18
       IF B2 < 75 Then min2
       GoTo start
    max2:
       B2 = 225
       GoTo start
    min2:
       B2 = 75
       GoTo start

    Because if i try to compile it with MicroCode Studio - PICBASIC PRO, i'll receive too many errors like:
    ERROR Line 15: Bad expresion. (ser1.txt)
    There are errors almost for each line.
    As i am absolute NOVICE in coding, those errors are bit over my head

    I have seen some codes, where guys had something like:
    Code:
    #include < blablabla.h >
    Does i need some .h file to be included?
    Last edited by irootsk; - 21st June 2009 at 02:26.

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 : 0

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