AllenInstitute / pytic

PyTic - An Object-Oriented Python Wrapper for Pololu Tic Stepper Drivers
Other
10 stars 6 forks source link

Noob Problem Probably #3

Open EdV2 opened 4 years ago

EdV2 commented 4 years ago

Hi, when execute the code provided by Pololu https://www.pololu.com/blog/788/pytic-python-interface-for-pololu-tic-stepper-motor-controllers

I get the following error during the "# Connect to first available Tic Device serial number over USB"

File "C:\Anaconda3\lib\site-packages\pytic\pytic.py", line 113, in _tic_handle_open print(handle_p);

ValueError: NULL pointer access

Please advise.

Thanks!

ajbenz18 commented 3 years ago

I'm getting this error as well. Did you figure out why this was happening and how to fix it?

ajbenz18 commented 3 years ago

I managed to solve the issue by disconnecting the tic control center from the motor

Em607867 commented 2 years ago

I managed to solve the issue by disconnecting the tic control center from the motor

Were you able to load the yml file for the settings? I get an error message while trying to do that, any insights will be helpful.

Thanks!

bensmana commented 2 years ago

Unfortunately I no longer work for the company on who's behalf I was working with the motors, but I still have access to the code. It's been a while, so I don't really remember anything about the issue, so I can really only share with you the how I used the motor.

            # Connect to first available Tic Device serial number over USB
            serial_nums = tic.list_connected_device_serial_numbers()
            print(serial_nums)
            tic.connect_to_serial_number(serial_nums[0])
            tic.settings.load_config('tic_config.yaml')
            tic.settings.apply()  

tic_config.yaml:

tic_settings:
  product: TIC_PRODUCT_T825
  never_sleep: True
  auto_clear_driver_error: True
  ignore_err_line_high: True
  serial_crc_enabled: False
  command_timeout: 0
  target_velocity: 40000000
  max_speed: 40000000                 # pulses/s * 10^-4
  starting_speed: 0                   # pulses/s * 10^-4
  max_accel: 900000                  # pulses/s^2 * 10^-2
  max_decel: 900000                  # pulses/s^2 * 10^-2
  step_mode: TIC_STEP_MODE_MICROSTEP2 
  current_limit: 672 # mA (see table in Pololu manual for acceptable values)
  decay_mode: TIC_DECAY_MODE_T825_FAST 
  pin_settings:
    - pin_num: TIC_PIN_NUM_RX
      func: TIC_PIN_FUNC_USER_INPUT
      pullup: True
      analog: False

Perhaps share the error message you're getting, and I'll see if I can be of any more help.

EdV2 commented 2 years ago

Hi,    I discovered that I could do what I need with batch files.  I was just missing some understanding the commands. The SW folks are doing something similar using the same commands in json files so I am able to prototype the thing they don't have time to investigate and pretty much drop it in. Thanks for looking into my question. Best regards,                     Edward Vogel                     763-442-6083

On Friday, January 21, 2022, 07:06:08 PM CST, Em607867 ***@***.***> wrote:  

I managed to solve the issue by disconnecting the tic control center from the motor

Were you able to load the yml file for the settings? I get an error message while trying to do that, any insights will be helpful.

Thanks!

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

inregards2pluto commented 1 year ago

I managed to solve the issue by disconnecting the tic control center from the motor

I was also running into this situation and arrived at the same solution. My partner and I dug into the tic.h file from polulu that pytic references in its functions and found the following:

// tic_handle ///////////////////////////////////////////////////////////////////

/// Represents an open handle that can be used to read and write data from a
/// device.
typedef struct tic_handle tic_handle;

/// Opens a handle to the specified device.  The handle must later be closed
/// with tic_handle_close().
///
/// On Windows, if another applications has a handle open already, then this
/// function will fail and the returned error will have code
/// ::TIC_ERROR_ACCESS_DENIED.
TIC_API TIC_WARN_UNUSED
tic_error * tic_handle_open(const tic_device *, tic_handle **);

When the Tic Control Center is opened, it's using the handle, so that's what's causing it to have issues when you try to run pytic script while the tic gui is open.