Shop OBEX P1 Docs P2 Docs Learn Events
dual stepper motors CLOSING IN FAVOR OF OF PROP C - Page 4 — Parallax Forums

dual stepper motors CLOSING IN FAVOR OF OF PROP C



  • I still have no output.

  • GenetixGenetix Posts: 1,739
    edited 2022-01-30 07:16


    This is why 3B isn't working.
    You removed the Setup method and the call to it.
    You added the Freq_Out method but never use it.

    You could add an Init method before Main, and then have the last line of it be Main so that it then goes to your Main method.

    Are you sure that your wiring is correct?

    Try adding a message to each CASE to see if the program is working correctly.

    ser.Str(STRING("xyz button was pressed.", ser#CR)) ' Send a line of text to the terminal.

    You should see a different message as each button is pressed or if no button is pressed.

  • bbrienbbrien Posts: 561
    edited 2022-01-30 22:13

    The method was given to me but he never told me how to use it And I do not understand it, I must be stupid ,maybe I should give up on parallax. What is a" Init method " and how do I use it.

  • GenetixGenetix Posts: 1,739
    edited 2022-01-31 13:17


    If you go back to post #83, there were 3 comment lines that you didn't copy into your program.
    These 3 lines explained the 3 parameters that the method uses.

    pub freq_out(ctrx, px, fx)
    '' Sets ctrx to frequency fx on pin px (NCO/SE mode)
    '' -- fx in 0.1Hz units (100_0 = 100Hz)
    '' -- use fx of 0 to stop counter that is running
      if (fx > 0)
        fx := ($4000_0000 / ((clkfreq >> 2) / fx))                  ' convert freq for NCO mode
        fx := (fx + 5) / 10                                         ' round up if needed
        case ctrx
          0, "a", "A":
            ctra := (%00100 << 26) | px                             ' configure ctra for NCO on pin
            frqa := fx                                              ' set frequency
            dira[px] := 1                                           ' make pin an output
          1, "b", "B":
            ctrb := (%00100 << 26) | px
            frqb := fx
            dira[px] := 1
        case ctrx
          0, "a", "A":
            ctra := 0                                               ' disable counter
            outa[px] := 0                                           ' clear pin/driver
            dira[px] := 0
          1, "b", "B":
            ctrb := 0
            outa[px] := 0
            dira[px] := 0

    Add this to your program CON section.
    I might be completely wrong about what does what because your programs are constantly changing.

    CON ' Constants for the Parameters used by the Freq_Out method
       ' Counter, Pin, Frequency
       ' Parameters for R.A. Stepper
         RA_Counter = A ' Counter to use for R.A. Stepper
         RA_Pin = NS_PLS
         RA_Frequency = 8_0 ' 8.0 Hz
       ' Parameters for Declination Stepper
         DEC_Counter = B ' Counter to use for Declination Stepper
         DEC_Pin = EW_PLS
         DEC_Frequency = 10_0 ' 10.0 Hz

    Place this method before Main

    PUB Init ' Initialization method
       ' This will be the 1st method of the program executed since it comes first.
       ' Use this method to setup any I/O pins, Registers, or start any Objects.
       ' Start-up Serial Cogs (Moves the Starts from Main to here)
       ' Set-up I/O pins
         DIRA := $00000000 ' Make P0 to P7 Inputs
         OUTA := $00000000 ' Make P0 to P7 Low (if Outputs)
         ' The Propeller defaults to Input Low so these lines are needed but putting them here doesn't hurt.
       ' Set-up the Counters for Pulses
         Freq_Out(RA_Counter,RA_Pin,RA_Frequency) ' Start-up the R.A. Counter
         ' Freq_Out(RA_Counter,RA_Pin,0) ' Stops the R.A. Counter
         Freq_Out(DEC_Counter, DEC_Pin,DEC_Frequency) ' Start-up the DEC Counter
         ' Freq_Out(DEC_Counter, DEC_Pin,0) ' Stops the DEC Counter
       Main ' Go to the Main method
  • GenetixGenetix Posts: 1,739
    edited 2022-02-01 21:04


    Just so I understand it, what is connected to what?
    Which pins are connected to the DEC motor, and which pins are connected to the RA motor?

    I found a MAJOR error is your Telescope 3x program.
    CLKFREQ should be CLK_FREQ.
    CLKFREQ is a system variable that comes from _XINFREQ and _CLKMODE.
    Never ever ever ever touch CLKFREQ.
    Also any clock settings need to be in a CONstants block.
    This is Spin 101 stuff.

    I added comments, fixed a few errors, and added Debug (Print) statements.
    You should see messages on the screen as the program runs and as you press the different buttons.
    Do all of the buttons work?

  • Pin #17 is RA motor and Pin#19 goes to DEC motor. Telescope3_b setup section given to me by jonnyMac afterwards he abandoned me I guess. I will install rest to the setup section and test. Will get back to you later. Thanx;

  • GenetixGenetix Posts: 1,739
    edited 2022-02-01 21:03


    Try this - hopefully there are no errors because Propeller Tool is on my other PC.

  • bbrienbbrien Posts: 561
    edited 2022-02-03 21:21

    I get an error in CLK_FREQ = ((_clkmode - xtal1) >> 26) * _xinfreq) " expected "," or "end of line"

  • bbrien,

    There is an extra parenthesis, ), at the end of that line and I see it was like that in Telescope 3A but not in 3B.

    I ran the program through Propeller Tool and it compiles fine, but my QuickStart board wasn't where I thought it was so I haven't tested it.

  • I went back to dh15 and changed the first PUB section, haven't tested the serial section until I get the camera section working right. I have four LEDs connected to the output section and they all turn on but don't turn off unless I press a cam. switch.

  • bbrien,

    The program didn't run as I expected and it's not my QuickStart because Jon's QuickStart Demo runs fine.

    I didn't even get text on the screen which is baffling so either I am rusty in Spin or something in the program is wrong.

  • bbrienbbrien Posts: 561
    edited 2022-02-06 02:56

    Anything's possible now . dh15 is now renamed Telescope BS 3_C.

  • Pin #4 Swtch on ; reads 20 seconds -North
    Pin #5 switch on ; reads 30 seconds- South
    Pin #6 switch on ; reads 40 seconds - West
    Pin #7 switch on ; reads 50 seconds - East
    Pin #x Switch off ; reads 60 seconds - None

    I think I need Code to start at "0" and turn off when no button pressed , only Pin 17 outputs (West, "A" Freq =6). for now west := 1

  • bbrien,

    You keep adding and the removing the same sections of code and it is driving me crazy.

    Start with the basics and get rid of anything else.

    You still have the Dec Rate and Pin parameters backwards for North.

    Before you do anything else, are you getting your motor pulses?

  • bbrien,

    I have your older program working on my QuickStart.
    I added a bunch of DEBUG statements and I commented out sections of code that weren't being used.

    You will see another button scan method at the bottom of the program that I needed to add because the QuickStart doesn't have actual buttons.
    I commented on what changes I made to the Button scan call in Main so you can change it back.

    I can't remember if you turned off the unused Direction LED in addition to turning off the Pulse but I had to add that so it worked as it should.

    Now, you had commented that the RA is always pulsing - that is intentional.
    When no button is pressed it will pulse RA.

    I originally had it update at 50 Hz but dropped it down to 2.

    It works but it's ugly.

  • bbrienbbrien Posts: 561
    edited 2022-02-06 19:42

    I looked at your TelescopeTest QuickStart dand put it in my Demos Library and loaded it into The EEProm but all I get is a continuous pulse on P17 and a "1" on P16 but when I use the P4..P7 switches I get no changes. On Telescope BS 3_C I get change onP16..P19 when sw. on P4..P7. The Serial section with hand box is more needed. So I want to concentrate on the 3_C program.

  • bbrien,

    As I said, the QuickStart uses a different button method.

    In Main, look for nav := scan_.....
    I am using a button method specifically for the QuickStart, so change it to the other one.

  • Ok I copied The QuickStart program and deleted the last Scan method and I have proper function bnow I need to set up a Serial section for the hand box. Hand box currently running DH 9 program , I'll include it.

  • I copied the above file and renamed and added a few items and tried it but have no serial receive from the hand box. the other switches still work but serial terminal is garbled . please help. including new attempt.

  • bbrien,

    I've been busy this past week with work and stuff so sorry for not getting back to you.

    I thought you were going to move everything to 1 Propeller.

    Explain how the 2 Propellers are wired together and what data is sent between.

    I think the best way to write your programs is to use what's called a State Machine.
    The way a state machine works is that you have various States, where an Input will change the state and then the output will depend on what the current state(s) is.

    For example each direction may be a state, manual or auto moving may be a state, etc.

    This program that you modified looks like an older version because I changed Ser to Serial and that's serial TO THE PC.
    You added a Public method Serial, but it's never called.

    If you go back to the OBJects block you will see a line using fds that is commented out.
    I assume this will the serial to the handbox so it's better to call it Box or HandBox.
    I also assume that this is the Control Box Propeller.
    Which I/O pins are being used for Tx and RX of the CONTROL BOX?
    Also what baud rate is being used.

    The Rx of the Handbox should connect to the Tx of the Control Box.
    The Tx of the Control Box should connect to the Rx of the Handbox.
    They both need to use the SAME baud rate.

    The Control Box needs CONstants for the Rx and Tx TO THE HANDBOX.
    Another Serial Start needs to be added to Init for the HANDBOX serial to Start it up.
    Then I don't know what data is coming from or going to the Handbox.

    The PC and Handbox serial connections are different so don't mix them up.
    You could rename all the ser to PCser or just comment them out.

    Before we continue attach the last WORKING program that you have so it can be cleaned up.
    Whatever you do DO NOT TOUCH the working code!!!
    We will add to the working code but the working code WILL STAY THE SAME.

  • Me and Dave H. tried to put every thing on one prop using virtual serial, but nothing worked and unfortunately dave became very ill and I couldn't wait for him to get well (it's been two months now) been trying other methods that I tried before which may work ( didn't know my receive pin was burned out) Including PropC.
    The hand box connects to the mount brain through a 5ft, 4 conductor cable. Sends 4 bytes from state machine.(go to my other thread for the handbox program., fdserial between two propeller"Flip" modules.)
    Control box is what I refer to as "mount Brain". RX = 11 and TX = 10 and RX = 6 and TX = 5 in the handbox. Use 9600 baud rate.
    Telescope Test Gen-fixed 2_b is my last attempt. Unless you want my old C programs.

  • bbrien,

    Since the Handbox is just a bunch of switches, why have any 'brains' in it?

    Is there a reason that you just don't connect the switches directly to the BrainBox?
    5 switches would need 6 conductors; one for each switch and then ground.
    CAT-5 has 8 conductors.

  • I have already set up the new boards for the serial connections and I have little money left in my budget. Handbox is already built and tested with test given by Iseries.

  • bbrien,

    Actually 7 conductors would be needed because I forgot about Power to the switches.

    The Handbox only has switches so why send 4 bytes when you only care about which switche is being pressed.

    Can more than one switch be pressed at the same time?

  • What we have going here is four different speeds and four different directions and two motors each using two wires and that's in the hand box alone. Each byte is a direction and speed. In the old program that I was using , there were two parts and they were written by Chris Gadd they used objects to run the motors but the object written by D. Hein for the steppers failed. The present form uses a program similar to the LX50A program found in other thread.

Sign In or Register to comment.