Tic control function wanted

After looking at the code some more, I realized get_pin_state() is not the method you want; that returns whether the pin is an input (high impedance or pulled up) or output (low or high). For reading the voltage on an input pin, you actually want get_digital_reading() (which returns a bool).

If you use that, does it work? Do you see your “Switch pressed” message in the debug output?

By the way, if there’s anything else related to using the Tic’s variables that you’re unsure about, it might be useful to look at print_status.cpp in the cli directory since it’s a pretty good demonstration of interpreting all the variables and printing them in a human-readable way.

Kevin

int switchState = variables.get_digital_reading(TIC_PIN_NUM_SCL);

did not work either.

tried running from the build directory where the compiled code was installed but both ticcmd and ticgui failed to open because of the following:

ticcmd code execution cannot proceed because libgcc_s_seh-1.dll was not found.

ticcmd code execution cannot proceed because libstdc+±6.dll was not found.

ticgui code execution cannot proceed because libgcc_s_seh-1.dll was not found.

ticgui code execution cannot proceed because Qt5Gui.dll was not found.

ticgui code execution cannot proceed because Qt5Core.dll was not found.

ticgui code execution cannot proceed because Qt5Widgets.dll was not found.

Could you be more specific about what isn’t working for you? I tried building the Tic software with your additions and was able to see debug output indicating that the switch is being pressed, so at least that part seems to be working:

warning: Switch pressed. Encoder scaling mode: 1
warning: Switch pressed. Encoder scaling mode: 2
warning: Switch pressed. Encoder scaling mode: 3
warning: Switch pressed. Encoder scaling mode: 4

I haven’t been able to test with an encoder and motor yet to see if the rest of the code reads the encoder and sets the target position appropriately, but I will try to do that when I get a chance.

As for your latest post, unfortunately, I’m not sure if it’s practical to run the compiled program directly from the build directory. Is installing it normally (with ninja install as indicated in the build instructions) problematic for you?

Kevin

Thanks for checking the code! No, following the build instructions is not problematic to me, I was simply being stupid and not using ninja install, only ninja. I will try to redo the build properly!

OK! it works! The ticgui and ticcmd applications were loaded:

$ ninja install
[3/4] Install the project…-- Install configuration: “Release”
– Installing: C:/msys64/mingw64/include/libpololu-tic-1/tic.h
– Installing: C:/msys64/mingw64/include/libpololu-tic-1/tic.hpp
– Installing: C:/msys64/mingw64/include/libpololu-tic-1/tic_protocol.h
– Installing: C:/msys64/mingw64/lib/pkgconfig/libpololu-tic-1.pc
– Installing: C:/msys64/mingw64/lib/libpololu-tic-1.dll.a
– Installing: C:/msys64/mingw64/bin/libpololu-tic-1.dll
– Installing: C:/msys64/mingw64/bin/ticcmd.exe
– Installing: C:/msys64/mingw64/bin/ticgui.exe

Bugs:

  1. ticgui Input and motor settings tab does not reflect the pre and postscalar values properly though the encoder action seems to be correct with each switch press.
  2. ticgui window is missing exit and sizing buttons.

Thanks for your help. Almost there!
Tomm

cleared up error 2. The initial window sizing was a bit large and the buttons were obscured.
Tomm

Now that I have the features working in ticgui, can you tell me how to make an installer so I can have a portable version to load on other computers without doing the build process?

Thanks,
Tomm

Sorry for the late response.

Since you built your software with MSYS2’s MINGW64 environment, you have native Windows executables. You can copy them to other computers as long as you copy all the DLLs in MSYS2 that they depend on. To list most of those DLLs, run:

pacman -S $MINGW_PACKAGE_PREFIX-ntldd
ntldd ./ticgui.exe ./ticcmd.exe

You can make a new folder and simply copy the EXEs and all the MSYS2 DLLs they depend on to that folder. (Do not copy the DLLs from C:/Windows). You should test it on your computer by running it outside the MSYS2 environment. There is probably a Qt platform plugin DLL that you need to copy, which is not listed by ntldd because it gets loaded in a different way (I think it’s /mingw64/share/qt5/plugins/styles/qwindowsvistastyle.dll). Once it’s working, you can put the folder in a ZIP file to make it easier to copy around. If you are distributing these binaries to people outside your organization, keep in mind that most of it is copyrighted, but you can get redistribution permission by following the requirements in the respective open source licenses.

If you want to build a nice installer like the ones we distribute, that will involve a Linux machine and some extra tools you have to install on both Linux and Windows, but I could help with that too. The starting point for that would be to follow the steps in the “Building from source on Linux with nixcrpkgs” section in BUILDING.md.

–David