Shop OBEX P1 Docs P2 Docs Learn Events
Clreol? — Parallax Forums

Clreol?

Keith HiltonKeith Hilton Posts: 150
edited 2004-12-10 19:46 in Learn with BlocklyProp
tongue.gif·I am in class at OTC right now, trying Jon Williams suggestion of the following program on a BS-2 and it is telling me CLREOL is a undefined symbol, it also told me hertz was a undefined variable.· I made herts VAR word above the program.· Can't find the term CLREOL in my Basic Stamp Manual.
Sorry, the teacher is gone to Florida and I need help.
Here is what Jon sugested:roll.gif
Main: Count 0, 1000 hertz
DEBUG, HOME, DEC hertz,CLREOL
GOTO Main

Post Edited By Moderator (Jon Williams) : 12/10/2004 5:55:47 PM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-10 17:58
    Make sure you're using the PBASIC 2.5 declaration in your program:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    You can find CLREOL in the help file which is newer than the manual -- make sure you have the latest version of the BASIC Stamp editor (you can download it from our web site).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-10 18:17
    Thanks Jon. Here is my program:
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    hertz VAR word
    Main: COUNT 0,1000, hertz
    DEBUG HOME,DEC hertz, CLREOL
    GOTO Main
    I am feeding in a signal from a function generator--sign wave set at 1K hertz.
    The 1K hertz signal is sent to a LM324, then to a 74HC14, then to BS2. The DEBUG screen is reading 3000 hertz. Jon, why isn't the DEBUG screen reading 1K hertz?
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-10 18:27
    It should be reading 1000. Possible bugs:

    1. You don't have a common ground.

    2. You have 'ringing' on the line.

    3. Your sine wave is not zero-referenced.

    4. Why send the 1 KHZ signal to an LM324 op amp? For buffering?

    5. What does your function generator expect its signal to be terminated by. Typical value 50 ohms.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-10 18:27
    If you're using a BS2 (not a BS2sx or BS2p), then the problem must be with your hardware -- I ran your code on an NX-1000 and got correct results from the pulse generator. You should look at the signal (on pin 0)·with a scope to see what's going on.

    You can add this to the top of your program to make it work the same with any BASIC Stamp 2 module:

    #SELECT $STAMP
      #CASE BS2, BS2E
        DurAdj      CON     $100            ' / 1
      #CASE BS2SX
        DurAdj      CON     $280            ' / 0.400
      #CASE BS2P
        OneSec      CON     $37B            ' / 0.287
      #CASE BS2PE
        OneSec      CON     $163            ' / 0.720
    #ENDSELECT
    
    Capture         CON     1000            ' 1 second
    
    

    Then you would adjust your COUNT line like this:

      COUNT 0, (Capture */ DurAdj), hertz
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 12/10/2004 6:30:31 PM GMT
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-10 19:02
    Jon, miricles happen all the time! Here is what I did and the program is running perfect for me now.
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    hertz VAR word
    Main: COUNT 0,1000,hertz
    DEBUG HOME, DEC hertz /2, CLREOL
    GOTO Main
    Don't why it works but it works? I am now going to put the LCD in the program.
    Then when I go home ,I am going to hook up my guitar to the same place I hooked up the signal generator. By the way allanlane5, thanks for trying to help. I don't need the LM324 with the signal generator--you are right about this, but I will need it with my guitar, because the signal from a magnetic pickup is weak. Jon wonder why this works?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-10 19:20
    Danger Will Robinson!

    You really should know why it works before proceeding -- you may be bitten by your ignorance later. Connect a 'scope to see what you're actually getting into the BASIC Stamp for the COUNT function.

    Also, can you post your schematic for others to consider?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-10 19:21
    Got the LCD working also, here is the program add in: SEROUT 8, 16468, {254,1]
    SEROUT 8, 16468, [noparse][[/noparse]DEC hertz /2, "HZ"]
    GOTO main
    Now if I can get get my guitar to work and read out hertz on a picked string, so I can tune to the hertz I want. Got to thinking I was stupid for a while, maybe there is some hope for me Jon.
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-10 19:37
    Jon, I suspect the problem is in my hookup arrangement of the LM324.· I looked at the output of the LM324·on the 0-scope before the signal got to the schmitt trigger.· It did not look even like it should, it looked doubled up.· This may be why I am getting 2 times the signal.· I will have to check the data sheets on the LM324, maybe the function generator is driving it to hard.tongue.gif
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-10 19:46
    What I believe may be happening is that your LM324 circuit is acting like a full-wave rectifier, so you're getting both halves of the sine cycle, effectively doubling your frequency. This could prove useful -- IF you know that this is a constant behavior. If your input is actually twice the source frequency, you can update your LCD at twice the rate:

    COUNT 0, 500, hertz

    Since your input frequency (to the BASIC Stamp) has been doubled, you only have to sample for half the time.

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