Menu

Encoder instead of buttons?

2021-08-07
2021-08-27
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-07

    For quite some time I was using my own simple focuser electronics design (without processor, schematic attached).
    It was working OK for me for years, but after building my permanent setup, I wanted remote focus control.. and Ascom focuser is ideal solution.
    However, I am wondering now if using the encoder as input device instead of buttons for stand-alone use would be beneficial (for me it would be)? How hard would it be to modify the code for this ?

     
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-07

    Robert,
    sorry for dxf (sent in error), here is jpg.
    I just found rotary encoder mentioned in configuration file, but apparently it is not available in ULN2003 build.
    I can see that encoder is connected to pins 9, 10, 11, so I can't have buttons at the same. which is fine. How can I activate it?

     

    Last edit: Bojan Stajcar 2021-08-07
  • brownrb

    brownrb - 2021-08-08

    I did not make a rotary encoder version for ULN2003, so you would have to make your own design + code.

     
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-08

    OK, thank you.
    I am working on it now, if/when done I will put it here.

     
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-22

    Robert,
    I managed to "marry" ULN2003 board and rotary encoder - it is a bit of a patchwork, but it reads encoder and moves the motor accordingly, apart from other functionality relevant to ULN2003 board.
    I noticed it doesn't automatically update the focuser position as encoder is moved, to do it I have to click on "Get Position" button. Is this is how the other variants of f/w behave, or should I try to implement this as well?

     
  • brownrb

    brownrb - 2021-08-23

    You have to change the state of
    myfocuser.lcdupdateonmove

    You can do this on the Windows app-
    on the Display Tab, by Checking this
    Update Position When Moving (Controller)

    Once checked, the position will update on the Display of the controller when moving.

     
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-23

    Robert,
    Thank you.. I tried your suggestion, but it still works only if I click "Get Position" on Main tab, so something is still missing in that code. Never mind, what I have now (remote via USB and local encoder) is quite sufficient for my needs at the moment.
    BTW, I don't have LCD display, the circuit is very basic - I have only ULN2003 and encoder connected to Nano board.
    Thanks again,
    Bojan

     

    Last edit: Bojan Stajcar 2021-08-24
  • brownrb

    brownrb - 2021-08-25

    When connected
    On the logging tab you will see a group "Position update"
    set the time to 5s by clicking the 5s radio button
    Check refresh position checkbox
    and it will update position every 5s

    It is worth noting, that if you were to do the following
    1. use +500 to goto 5500
    2. wait for the move to end
    3. use the rotary encoder to move +20 steps
    4. use +500 again
    the focuser should end up 6200

    Before any move request is done using the windows app, the position is read from the controller first, and does not use the position in the text box. . It does it that way for exactly that reason (push buttons, rotary encoder, infra-red remote, joystick) all alter the position without the application knowing.

    The application also queries the ismoving state from the controller before deciding if it should send the move request. This is so that if the focuser is moving because of some other reason (rotary encoder), it does not cause a conflict.

    There are three properties that can be returned at any time (even if the focuser is moving), These are
    temperature
    ismoving
    position

    Most of the Arduino type implementations use a simple send response exchange
    The application sends a command, the arduino responds with an answer

    This makes code easy to write. However, if you want the Arduino to be able to send data at any time (indicating a change) then it becomes more complicated (not impossible - just more code)

    Regards
    Robert

     
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-25

    Robert,
    Final position is displayed correctly after clicking "Get" or jog or "Go to", but when I set logging to 5s and move encoder, after some time (longer than 5 sec) there is a message displayed "Focuser is moving, update ignored".
    So it seems my "patchwork" is still not complete, app thinks motor is moving but this is definitely not the case. I have to have another look into the code...
    But... as I mentioned earlier, it OK as it is.
    I asked the question only because I think the position was updated after pressing a button.. and now there is no change when encoder stops moving.

     

    Last edit: Bojan Stajcar 2021-08-25
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-25

    Well, now it works, refreshing position every 5 sec. Not sure why it didn't work last time....
    Maybe my PC is playing me.
    Thanks again,
    Bojan

     
  • brownrb

    brownrb - 2021-08-27

    Hi Bojan

    Thanks for adding the RE code. It will be part of the next update.
    I added a few checks - RE uses the same pins as Nokia Display, InfraRed remote and Bluetooth so that needed to be done. I also added the full Rotary Encode support in there as well.

    Attached is what will be available with the next update

    Cheers
    Robert

     
  • Bojan Stajcar

    Bojan Stajcar - 2021-08-27

    Thank you!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.