Shop OBEX P1 Docs P2 Docs Learn Events
how do I do this? — Parallax Forums

how do I do this?

bobsmithbobsmith Posts: 36
edited 2004-12-03 16:04 in BASIC Stamp
I am programming a stamp so each time the microswitch is activated it activates the solenoid.

If microswitch = 1 then
High noid
Pause
Low noid
Pause

Etc etc

I want to read the number of cycles that happen per second to the solenoid. How do I do that?

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-02 19:54
    The ANT-8 logic analyzer will show you the signal cycle.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-03 16:04
    At what resolution?· You could do something like this:

    Fire_Solenoid: 
      fireCount = 0 
      FOR idx = 1 TO 20 
        IF (Fire = 1) THEN 
          fireCount = fireCount + 1 
          HIGH Solenoid 
        ENDIF 
        PAUSE 25 
        LOW Solenoid 
        PAUSE 25 
      NEXT 
      RETURN
    

    This subroutine runs for about 1 second (20 x (25 ms x 2).· On entry the fireCount variable is cleared and will be incremenet through the loop when the fire button is pressed.· What this code does not account for is the fire button being held.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.