Shop OBEX P1 Docs P2 Docs Learn Events
Input From Function generator to basic stamp 2e — Parallax Forums

Input From Function generator to basic stamp 2e

krimskrims Posts: 8
edited 2009-03-18 15:00 in BASIC Stamp
hi,

I·am new to basic stamp.

I·configured pin 2 as input and pin 3 as output.
I would like to give the input(square wave form)·from the·signal generator at pin 2 and i has to replicate that wave form at output pin 3.

thanking you,
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-16 14:38
    1) How fast can the signal change? There's no way to directly connect the two pins internally and to copy the state of pin 2 to pin 3 takes a little time.

    2) What else does your program have to do?
  • krimskrims Posts: 8
    edited 2009-03-16 15:12
    Thanks for the reply,

    My signal is 1kHz from siganl generator given as input to pin 2(configured as input) . I want to check whether pin3 (configured as output) follows input(pin 2). I am checking both the wave forms on DSO(digital storage oscilloscope).


    this is my approach

    INPUT 2
    OUTPUT 3

    OUT3=IN2


    I am doing this, to check how basic stamp accepts input from external circuitary and gives output.
    Beacuse in later case the input pin 2 of my basic stamp will get signal from another circuitary which will be in the form of Bit Stream.
    So, i am checking here with signal generator .
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-16 15:21
    What you wrote will work, but only for a brief instant. You set the mode of the pins properly, then your program copies the state of pin 2 to pin 3, then stops You need to put this into a loop like this:

    copyIt:
    out3 = in2
    goto copyIt

    Don't be surprised if the fidelity of this is poor. Statements on the BS2 take several hundred microseconds to execute. Just these two will take maybe 500-600us. With a 1KHz signal, you'll get maybe one or two sample points in a single cycle. The only way to do better is to use a faster processor.

    Post Edited (Mike Green) : 3/16/2009 3:28:24 PM GMT
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-03-16 15:32
    That simple loop will be on the margin of working at 1000 Hz. PBASIC is an interpreted language that involves reading each instruction in sequence from the serial eeprom and then interpreting and executing it. The program loop,
    copyIt:
      out3 = in2
      goto copyIt
    


    will take about 500 microseconds to run, which is 1/2 cycle at 1000 Hz. For your experiment, you can tune the square wave generator up or down in frequency while watching the 'scope to see if the Stamp can keep up. Will your ultimate bit stream arrive at that rate?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • krimskrims Posts: 8
    edited 2009-03-16 15:50
    thanks for the prompt reply,

    But i am not getting wave form for output pin 3 on DSO.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-16 15:57
    What we've told you should work given the limited information you've provided. I'm assuming you have a digital signal generator producing a 1KHz pulse stream (500us on and 500us off) with +5V / 0V signal levels connected to I/O pin 2 and a conventional logic analyzer or digital oscilloscope connected to I/O pin 3. At this speed, you will not get the same waveform on the 'scope as both Tracy and I explained. You might start with a lower frequency pulse stream, like 100Hz.
  • krimskrims Posts: 8
    edited 2009-03-18 15:00
    thank you,

    my problem is solved.
Sign In or Register to comment.