Shop OBEX P1 Docs P2 Docs Learn Events
Please tell me why this doesnt work well. — Parallax Forums

Please tell me why this doesnt work well.

radialrandyradialrandy Posts: 78
edited 2010-09-04 18:37 in Propeller 1
This is a simple program to read the time between 3 low to high transistions.
pin 1 is used to start it via a button.
pin 2 in input for the signal.
im using the pulse generator output on the professional development board ran through a button.
when i run the program i push the button on pin 1 to start the rest of the program. then i push the button to let the signal from the pulse generator feed to pin 2. program takes measurements on the first 3 low to high. Problem is that using the terminal to view the result I'm seeing inconsistant results. I would think if I feed the measurement with a pulse generator signal then the counts between pulses should be very close. But there off from alittle bit to sometimes alot. I dont know what I doing wrong. I'm very new at this. Please help.
thanks

Comments

  • T ChapT Chap Posts: 4,223
    edited 2010-09-04 17:40
    How is the button connected? Pulled up or down? You don't show any debounce method so a regular button would probably have some bounce to it. I would put a set of statements at the top to catch the button transition, then put a statement at the end to 'park' the code until the button is released.
     
    repeat
       if buttonpin == 1
          waitcnt(100_000) 
          if buttonpin == 1
              'run your code
               repeat until buttonpin == 0
    
    
  • bill190bill190 Posts: 769
    edited 2010-09-04 18:37
    When I load that program, the lines under repeat are not tabbed or spaced over.

    See how repeat is used in the propeller manual and how the lines under it you want to repeat are spaced over.
Sign In or Register to comment.