Shop OBEX P1 Docs P2 Docs Learn Events
One Shot Toggle and Repeat — Parallax Forums

One Shot Toggle and Repeat

Rob7Rob7 Posts: 275
edited 2006-08-28 20:26 in Propeller 1
Hi all,

O.K.
I now have all the hardware I need for my next project.
I am trying to toggle 4 pins (Output) set to read an input, at 5 vdc each pin. (I haven't forgot the input resistor.)
Read pin x, if high, toggle pin output x, repeat for that pin if input is high.
4 input pins
4 output pins
All 4 input must be read in parellel.
I have run thru the tutorial, I just can't seem to get it !
I must be brain damaged...
Help!!!!!!!
Can someone please show me the correct way to start the program.·I think with this help I can add more pins later and modify them to my applications.

Rob7 cry.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-22 17:14
    Does this do what you want?
    PRI project | temp
      temp := ina[noparse][[/noparse]4..7]      ' reads pins 4..7 at the same time
      outa[noparse][[/noparse]0..3] ^= temp  ' exclusive or's (toggles) corresponding 0..3 pins that were high
    
    
  • Rob7Rob7 Posts: 275
    edited 2006-08-22 17:43
    Thanks, Mike

    I changed PRI to PUB to get it to load.

    I cannot seem to get an high output from the inputs ?



    Rob7
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-22 18:03
    Rob,
    This was only a code fragment to illustrate something. I assumed that you've already set up the pins for input or output and that the input pins were 4 through 7 while the output pins were 0 through 3. The routine only reads the input pins once and toggles (or doesn't toggle) the output pins once. You have to call the routine each time or put it in a repeat loop. If an input pin is high, the corresponding output pin will be toggled every time the routine is called. Is that what you want? Maybe you need to give more information about what you're trying to accomplish, perhaps with a schematic drawing.
    Mike
  • Rob7Rob7 Posts: 275
    edited 2006-08-22 20:10
    Thanks, Mike.

    Sorry for the confusion.

    The outputs work , I am having trouble with creating inputs to trigger the outputs.

    I have attached the outputtest. spin program.

    Here are the schematics for my input and output pcb's.

    Rob 7
    2338 x 1700 - 169K
    2338 x 1700 - 324K
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-22 21:00
    The 74LS14 is a TTL device and, as such, has a high output voltage of around 3.4 with a minimum of 2.7. The Propeller has a switch point of about 1/2 Vdd so this should be enough. Your input circuitry seems like overkill. The Propeller doesn't need an inverter. Would it work just to use the phototransistor to pull down the signal line with a resistor to Vdd (3.3V)? You could put the resistor on the Propeller end of the connector where there's 3.3V available. On the output end you could do something similar with the Propeller switching the other end of the LED to Vdd and the LED cathode grounded through an appropriate resistor.

    If you're going to use your existing circuitry, do check the output high and low levels with a voltmeter to be sure the voltage margins are adequate for the 3.3V CMOS inputs.
  • Rob7Rob7 Posts: 275
    edited 2006-08-22 21:10
    Yes, Mike.

    Overkill is right, However these boards were designed for another purpose. I can change the input resistance with the jumper resistor abd buffer all noise at the inputs.

    Rob7
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-22 21:25
    It should work. I'd check the voltage levels, then try it with the Propeller one input at a time with an LED (and resistor) on a Propeller I/O pin and use a simple program to just copy the value of the input pin to the output like:
      repeat
        outa[noparse][[/noparse]outpin] := ina[noparse][[/noparse]inpin]
    
    


    Then fiddle with the isolated input to see if the Propeller sees the proper signal level.
  • Rob7Rob7 Posts: 275
    edited 2006-08-22 21:54
    Cool,

    I will try it tonight !

    Thanks Mike for all your help !yeah.gif



    Rob7
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-08-22 22:08
    The inverter you use is a Schmitt trigger, so it might not be such a bad thing to leave in there. OTOH, if you were to use an H11L1 optocoupler, it has the Schmitt trigger built in, and you could get rid of all that external circuitry. Where you might be getting into trouble is the two LEDs in series on the input circuit. Just make sure your input signal is substantially higher than the sum of their two forward voltages. Also, since the outputs of your optocouplers are connected in a Darlington arrangment, they're not going to switch very fast. If your inputs are toggling back and forth quickly, the transistor circuit won't be able to keep up, and you won't see any transitions on the output. The H11L1 will solve that problem nicely.

    -Phil
  • Rob7Rob7 Posts: 275
    edited 2006-08-28 19:35
    O.K.
    I have two short programs and they work seperate. I am trying to combine them to creat a pulsout program but I am having problems.
    At the Outa := Pulsout I want to look down and run the pulseout string, but however I try. I cannot get it to work. Can someone please head me in the right direction.
    Here is the combined program.

    Thanks!

    Rob7
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2006-08-28 20:02
    Change your "repeat" loop to look something like...

     Repeat                                'Infinite loop
    ' 
       If Ina[noparse][[/noparse]0] == High                   'If pin is high
          Pulsout_uS(4,1000)               '   Pulsout
       Else
          Ina[noparse][[/noparse]4] := Low
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-28 20:11
    There's a comment that you're setting pin 0 to be an input, but the statement says "Dira := In". It shouldn't make any difference since all pins are input after a reset unless changed otherwise. What is "Outa := Pulsout" supposed to mean?
    If you want to call the routine from the BS2 object, you need a function call. Look at the comment in the routine for an example.
    Since you've incorporated the routine into your own program, the "BS2." is not used. A statement like "PULSOUT_uS(4,500)" will
    produce a 500us pulse. There is no such statement as "Low := Low". If you want pin 4 to become low, use "OUTA := Low".

    It looks like you're trying to use statements from PBasic on the Propeller. The Propeller is very different, but not hard to understand. On the Stamp, in addition to statements like LOW and HIGH, you can directly access the direction register and the input and output registers as if they were 16 bit words. On the Propeller, that's all there is. You have to do it that way.

    The BS2 object was written to help people make the transition from PBasic to SPIN by providing similar functionality, but they're
    not exact replacements. The routines have to be called with a SPIN function call (which is a statement too) and sometimes several routines have to be called to do what one statement in PBasic will do (like SERIN or SEROUT) because these operations are not built-in.
  • Rob7Rob7 Posts: 275
    edited 2006-08-28 20:26
    I see,

    Thanks Mike, for clearing that up for me.



    Rob7
Sign In or Register to comment.