Shop OBEX P1 Docs P2 Docs Learn Events
telescope drive — Parallax Forums

telescope drive

Hi, I need some help with some spin code. I want to transfer a pulsed input to a output cog without changing the pulse. There are eight input lines and two motors. any ideas
will be most appreciated.
bbrien

Comments

  • What sort of precision do you need?

    What are these pulses like? What frequency and how long will the pulses be high vs low?

    I don't think I understand what you want to do. Do you need to the ability to change the pulses or do you just want to listen in to the pulses?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2016-06-07 00:47
    Here's an example of sending the inputs on P0 through P7 out on P8 through P15.

    You'll need to set the pins as outputs.
      dira[15..8] := $FF ' set pins as output
    

    Then you'll need a loop to monitor the inputs and set the output state.
      input := ina[7..0]
      outa[15..8] := input
    

    The above code preserves the input value so you can analyze it in the code if you want.
  • rjo__rjo__ Posts: 2,114
    How fast are the pulses? What Duane is saying is correct. But you might need to do this in PASM, depending on the signal. It is the same idea, but in PASM you would use pin masking to achieve the same end.

    Regards,

    Rich
  • I would like to launch 4 cogs using (coginit). I want to instruct the cogs to read 2 inputs and transfer data to assigned outputs. How do I do this. I need to get this done before
    the14-10-16. I leave for Thailand on16-10-16 I need the info. to program the mount over there.


    thanks
    Brien S

  • Is this for the Propeller 2 (on a FPGA) or Propeller 1?
  • I assume this is for Prop 1 since this is only your second post. Your other posts refers to a telescope drive, but it's not clear what kind of timing constraints you have. If Spin is fast enough you could do something like the following program.
    con
      _clkmode = xtal1+pll16x
      _clkfreq = 80_000_000
    
    var
      long stack1[10], stack2[10], stack3[10], stack4[10]
    
    pub main
      cognew(PinCopy(1, 2, 9, 10), @stack1)
      cognew(PinCopy(3, 4, 11, 12), @stack2)
      cognew(PinCopy(5, 6, 13, 14), @stack3)
      cognew(PinCopy(7, 8, 15, 16), @stack4)
    
    pub PinCopy(in1, in2, out1, out2)
      dira[out1] := 1
      dira[out2] := 1
      repeat
        outa[out1] := ina[in1]
        outa[out2] := ina[in2]
    
    However, it's not clear that you actually need to use 4 different cogs, or whether you need to use PASM to get higher speed and less jitter. Could you post more information about your application?
  • bbrien wrote: »
    I would like to launch 4 cogs using (coginit). I want to instruct the cogs to read 2 inputs and transfer data to assigned outputs. How do I do this. I need to get this done before
    the14-10-16. I leave for Thailand on16-10-16 I need the info. to program the mount over there.


    thanks
    Brien S
    You could start with:

    https://www.parallax.com/product/122-32305

    A free download.

    Another free download:

    https://www.parallax.com/news/2015-07-09/now-available-preview-whats-multicore-microcontroller-chapters-1-6



  • PublisonPublison Posts: 12,366
    edited 2017-01-28 22:35
    Sent to another thread. Moving it to here.
    Duane: one set of pulses are from a freq. gen. they will range from about 2 hertz to about 250 hertz, with about 50% duty cycle. The other signal runs about 1.0 k hertz and a variable pulsewidth ranging from5 to 95 % duty cycle.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-01-29 03:58
    The counters on each cog can be configured for logic mode where they can reflect the state of an input pin or pins. No PASM required, just a couple of lines of Spin to set and forget, but I'm not exactly sure what you are asking though. Check the appnote from Parallax about counter operation.

  • jonesjones Posts: 281
    edited 2017-01-29 22:16
    -deleted-
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    This thread is being moved to the Propeller 1 forum.
  • Dave Hein wrote: »
    I assume this is for Prop 1 since this is only your second post. Your other posts refers to a telescope drive, but it's not clear what kind of timing constraints you have. If Spin is fast enough you could do something like the following program.
    con
      _clkmode = xtal1+pll16x
      _clkfreq = 80_000_000
    
    var
      long stack1[10], stack2[10], stack3[10], stack4[10]
    
    pub main
      cognew(PinCopy(1, 2, 9, 10), @stack1)
      cognew(PinCopy(3, 4, 11, 12), @stack2)
      cognew(PinCopy(5, 6, 13, 14), @stack3)
      cognew(PinCopy(7, 8, 15, 16), @stack4)
    
    pub PinCopy(in1, in2, out1, out2)
      dira[out1] := 1
      dira[out2] := 1
      repeat
        outa[out1] := ina[in1]
        outa[out2] := ina[in2]
    
    However, it's not clear that you actually need to use 4 different cogs, or whether you need to use PASM to get higher speed and less jitter. Could you post more information about your application?

  • two of the inputs will control two outputs. Each input will consist of a pulsed signal with frequency between1 hertz and 1000 hertz. and a variable pulse width which will be copied to one output and a second output will go either high or low depending on which of two inputs is active.
  • Is there a command that I can use to ask the computer to test for the presence of a pulse.
  • I tried to use input if high copy input to output and make second output high and used a waitcnt at the end but motor runs at full speed when pwm is at 20%. what to do. please help.
    bbrien.
  • bbrien wrote: »
    Hi, I need some help with some spin code. I want to transfer a pulsed input to a output cog without changing the pulse. There are eight input lines and two motors. any ideas
    will be most appreciated.
    bbrien

    Eight input lines and two motors sounds like two bipolar steppers. Is that what you have?
  • MJBMJB Posts: 1,235
    edited 2017-05-16 16:31
    bbrien wrote: »
    I tried to use input if high copy input to output and make second output high and used a waitcnt at the end but motor runs at full speed when pwm is at 20%. what to do. please help.
    bbrien.
    If you draw a little picture of your signals going in and out and explain WHAT you want to achive instead of just HOW you want to do it,
    then we might be able to help you.
  • input signal is pulsewidth modulated signal around100 hertz and 5-95 % duty cycle. the two motors are DC clock motors driven by a L298 dual H-bridge chip. I want the signal at the input to match the output pin and a second pin to output a high or a low for the direction. My alternative is to not use a pulsed signal at the input but to use a PWM signal generated at the output by the output cog. I can use 3 or 4 different pulsed signals and use indexed button pushes but how do I do that.
    brien
  • Eight inputs are I/O pins are needed to read a pulsewidth modulated signal of around100 hertz and 5-95 % duty cycle and 4 pins that are pulled high and go low when active
Sign In or Register to comment.