Shop OBEX P1 Docs P2 Docs Learn Events
Learning Process — Parallax Forums

Learning Process

KievlaninKievlanin Posts: 55
edited 2011-12-11 19:30 in BASIC Stamp
I am very interested on learning how to create programs using PBASICS.
Any suggestions?

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-28 01:20
    Kievlanin

    Its not as hard as it looks.And as You read,You can experiment!

    kf4ixm lists some really needed info.,But its not overwhelming or overly complicated.
    Remember if You get stumped on some thing, Thats what the Forums are for.

    Welcome to the Club.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • doggiedocdoggiedoc Posts: 2,240
    edited 2011-12-03 07:19
    Good Morning Kievlanin,

    At your request for help in your PM, I am reviving this thread for you. What are you working on and what parts do you have? Are you goals to learn PBASIC programming or do you have a specific task in mind? There are a lot of people on these boards that have a great understanding of PBASIC and Parallax products. How can we help?

    Doc
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 08:31
    I have designed the (2)two axis solar tracker mechanism.
    This includes:
    4 Photoresistors (from Radio Shack)
    2 Stepper Motors (from AutoMationDirect)


    <u>Description of operation:</u>
    1 step: PLC (microprocesor) reads value of two (90 degree apart) photoresistors on axle X
    2 step: compare two values (< or >)
    3 step: rotate Stepper (assigned amount of steps) on axle X accordingly (to try to equalise the values)
    4 step: pause 15 sec.
    5 step: repeate from step 1 until values are within +/-10%
    6 step: once result in step 5 are completed switch to axle Y alignment (similar procedure as for axle X, except using photoresistors on axle Y and Stepper Y)
    7 step: sleep mode for 15 minutes
    8 step: start from step 1

    This is not the best procedure (I know).
    I see the best procedure to be by tracking by "Astronomical Sun position", but this will require more expensive components like: Servo Motors and angular (lineiar) absolute transducers/encoders
  • FranklinFranklin Posts: 4,747
    edited 2011-12-03 09:12
    This is not the best procedure (I know).
    I see the best procedure to be by tracking by "Astronomical Sun position", but this will require more expensive components like: Servo Motors and angular (lineiar) absolute transducers/encoders
    Is there a program you have written to do this? And have you read the documents that were listed in the previous post? What have you accomplished in two years?
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 10:11
    Franklin, being as busy as I am now it is very hard to learn a programming.
    I did not learn any programming for this two years.
    However, I had quite a progress for the last month.
    All depends on my workload at work. And sometime, I am lazy...... Blame on me...:smile:

    Well, for the last month I have spent a good deal of time learning PBASIC.

    One thing is that last month, basically every evening I was drawing my SunTracker in Inventor Pro and I am now about 80% done with production drawings.
    All 3D design is done & confimed. Even some parts have been made.
    I do not know how long it will take to make all the parts, but at least a month, this is for sure!

    Programming and assembly of all electronic components (in one package) is my weak point. (I am a mechanical engineer, not electronic).
  • FranklinFranklin Posts: 4,747
    edited 2011-12-03 11:09
    The program will most likely depend on what parts you plan to use and how you plan to get your inputs and outputs. When you get those figured out let us know and we can probably help.
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 12:13
    Check this program. It is suppose to compare values of the photoresistors on axle X:

    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    'I would like to develop a simple program that will
    'compare value of photoresistors "NumberBX" & value of "NumberBX"
    'located on axle X AND OUTPUT the larger
    'variable name on the screen
    'I will have:
    'photoresistor AX
    'and
    'photoresistor BX
    'Variables list:
    SYMBOL ValueAX = B1 'This is a value of photoresistor AX after measured
    SYMBOL ValueBX = B2 'This is a value of photoresistor BX after measured
    SYMBOL PulseAX = PIN7 'Pulse input pin for photoresistor AX
    SYMBOL PulseBX = PIN6 'Pulse input pin for photoresistor BX

    Main:
    PULSIN PulseAX, 1, ValueAX 'measure positive pulse on pin7, on high, store in ValueAX
    PULSIN PulseBX, 1, ValueAX 'measure positive pulse on pin7, on high, store in ValueBX

    Run:
    IF ValueAX > ValueBX THEN AX_larger_then_BX
    IF ValueAX < ValueBX THEN AX_smaller_then_BX

    AX_larger_then_BX:
    HIGH PIN4 'turns ON LED on Pin4
    DEBUG "PhotoresistorAX is larger then PhotoresistorBX"
    AX_smaller_then_BX:
    HIGH PIN5 'turns ON LED on Pin5
    DEBUG "PhotoresistorAX is larger then PhotoresistorBX"
    PAUSE 1000
    GOTO Main
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 12:15
    Looks like something whent wrong with formatting...
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 12:21
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}

    'I would like to develop a simple program that will
    'compare value of photoresistors "NumberBX" & value of "NumberBX"
    'located on axle X AND OUTPUT the larger
    'variable name on the screen
    'I will have:
    'photoresistor AX
    'and
    'photoresistor BX

    'Variables list:


    SYMBOL ValueAX = B1 'This is a value of photoresistor AX after measured
    SYMBOL ValueBX = B2 'This is a value of photoresistor BX after measured
    SYMBOL PulseAX = PIN7 'Pulse input pin for photoresistor AX
    SYMBOL PulseBX = PIN6 'Pulse input pin for photoresistor BX

    Main:
    PULSIN PulseAX, 1, ValueAX 'measure positive pulse on pin7, on high, store in ValueAX
    PULSIN PulseBX, 1, ValueAX 'measure positive pulse on pin7, on high, store in ValueBX

    Run:
    IF ValueAX > ValueBX THEN AX_larger_then_BX
    IF ValueAX < ValueBX THEN AX_smaller_then_BX

    AX_larger_then_BX:
    HIGH PIN4 'turns ON LED on Pin4
    DEBUG "PhotoresistorAX is larger then PhotoresistorBX"

    AX_smaller_then_BX:
    HIGH PIN5 'turns ON LED on Pin5
    DEBUG "PhotoresistorAX is larger then PhotoresistorBX"

    PAUSE 1000
    GOTO Main
  • doggiedocdoggiedoc Posts: 2,240
    edited 2011-12-03 12:24
    If you enclose your program with [noparse]
    ...
    
    [/noparse] where the 3 dots are it should format it better for you.
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 14:53
    
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    'I would like to develop a simple program that will
    'compare value of photoresistors "NumberBX" & value of "NumberBX"
    'located on axle X AND OUTPUT the larger
    'variable name on the screen
    'I will have:
    'photoresistor AX
    'and
    'photoresistor BX
    'Variables list:
    SYMBOL  ValueAX    = B1           'This is a value of photoresistor AX after measured
    SYMBOL  ValueBX    = B2           'This is a value of photoresistor BX after measured
    SYMBOL  PulseAX    = PIN7         'Pulse input pin for photoresistor AX
    SYMBOL  PulseBX    = PIN6         'Pulse input pin for photoresistor BX
    
    Main:
      PULSIN PulseAX, 1, ValueAX      'measure positive pulse on pin7, on high, store in ValueAX
      PULSIN PulseBX, 1, ValueAX      'measure positive pulse on pin7, on high, store in ValueBX
     
    Run:
      IF ValueAX > ValueBX THEN AX_larger_then_BX
      IF ValueAX < ValueBX THEN AX_smaller_then_BX
    
    AX_larger_then_BX:
      HIGH PIN4                                                        'turns ON LED on Pin4
      DEBUG "PhotoresistorAX is larger then PhotoresistorBX"
    AX_smaller_then_BX:
      HIGH PIN5                                                        'turns ON LED on Pin5
      DEBUG "PhotoresistorAX is larger then PhotoresistorBX"
    PAUSE 1000
    GOTO Main
     
    
    
    
    
    
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 14:54
    Thank you!
    Still looks a bit different, but it is much better.
  • KievlaninKievlanin Posts: 55
    edited 2011-12-03 15:04
    Now it is looks like intended to.
    Thanks!
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    
    'I would like to develop a simple program that will
    'compare value of photoresistors "NumberBX" & value of "NumberBX"
    'located on axle X AND OUTPUT the larger
    'variable name on the screen
    'I will have:
    'photoresistor AX
    'and
    'photoresistor BX
    
    'Variables list:
    SYMBOL  ValueAX    = B1           'This is a value of photoresistor AX after measured
    SYMBOL  ValueBX    = B2           'This is a value of photoresistor BX after measured
    SYMBOL  PulseAX    = PIN7         'Pulse input pin for photoresistor AX
    SYMBOL  PulseBX    = PIN6         'Pulse input pin for photoresistor BX
    
    Main:
      PULSIN PulseAX, 1, ValueAX      'measure positive pulse on pin7, on high, store in ValueAX
      PULSIN PulseBX, 1, ValueAX      'measure positive pulse on pin7, on high, store in ValueBX
     
    Run:
      IF ValueAX > ValueBX THEN AX_larger_then_BX
      IF ValueAX < ValueBX THEN AX_smaller_then_BX
    
    AX_larger_then_BX:
      HIGH PIN4                                                        'turns ON LED on Pin4
      DEBUG "PhotoresistorAX is larger then PhotoresistorBX"
    
    AX_smaller_then_BX:
      HIGH PIN5                                                        'turns ON LED on Pin5
      DEBUG "PhotoresistorAX is larger then PhotoresistorBX"
    
    PAUSE 1000
    GOTO Main
     
    
  • KievlaninKievlanin Posts: 55
    edited 2011-12-11 19:30
    Below I have developed a code.
    I am learning. So if something looks funny...
    It is works. is measuring the light intencity and turning on the LED accordingly.
    The next step is the motor, to make turn CW or CCW. According with the LED's.

    This is my first program. (Well. not really. I made many "super shorties" for training, this weekend). It is not polished, not documented properly. Riugh draft.
    As you see it is based on BS1. For me there is plenty of learning even with this.
    I do have BS2 in my hands, but I will try tinkering with BS1 for the moment.

    Suggestions always welcome!
    
    ' POT.BS1
    ' This program demonstrates the use of the POT command.  Connect one side
    ' of a 10K potiometer to P0.  To the other side of the potentiomenter
    ' connect a 0.1 uF capacitor, and then connect the second side of the
    ' capacitor to Vss (ground).  Before running demo program, use the
    ' Run | POT Scaling dialog to determine the best Scale factor.
    ' The above used as template to start the development.
    ' The code below is edited from original.
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    SYMBOL  PotPin0          = 0             ' 10K pot connected to P0
    SYMBOL  Scale0           = 50            ' scale value for test circuit
    SYMBOL  PotPin1          = 1
    SYMBOL  Scale1           = 50
    
    SYMBOL  level0           = B2            ' storage of pot "level1"
    SYMBOL  level1           = B3            ' storage of pot "level2"
    Main:
    LOW 7
    LOW 6
    'Left photoresistor check
      POT PotPin0, Scale0, level0              ' read pot level
      DEBUG "Level0 = ", #level0, CR         ' display
    'Right photoresistor check
      POT PotPin1, Scale1, level1              ' read pot level
      DEBUG "Level1 = ", #level1, CR         ' display
      PAUSE 2000
      DEBUG CLS
    
      Compator:
      IF B2>B3 THEN lightb3
        lightb2:
        HIGH 7
        PAUSE 500
        GOTO Main
        IF B2<B3 THEN Repeate
        lightb3:
        HIGH 6
        PAUSE 500
    
    Repeate:                                ' short delay
      GOTO Main                             ' repeat forever
    
    
Sign In or Register to comment.