Pololu TIC T500 Stepper Motor Library Help

I’m trying to move a linear actuator with the Pololu Tic T500 using I2C

I’ve got it working in Arduino IDE, but can’t get it in XOD. So, connections are correct.

I’m trying to adapt the library from Wayland ADS1115 to the tic_arduido stepper motor library.

It’s not clear how to ensure the I2C is connected, because I can’t access the begin command, since it’s not in the library, although the TicI2C is supposed to inherit wire, I think?? The address is defaulted to 14, but I’m not sure how to get a variable address. So, I hard coded the 14.

I’m trying to get confirmation by using the setProduct() command from the inherited TicBase, but I’m getting an error

Begin compiling code for the board Arduino Uno 📦


C:\Users\xxx\AppData\Local\Temp\xod_temp_sketchbookyFrQAO\xod_1639348563118_sketch\xod_1639348563118_sketch.ino: In member function 'void xod::____pic500::Node::evaluate(xod::____pic500::Node::Context)':
C:\Users\xxx\AppData\Local\Temp\xod_temp_sketchbookyFrQAO\xod_1639348563118_sketch\xod_1639348563118_sketch.ino:1175:15: error: base operand of '->' has non-pointer type 'TicI2C'
         sensor->setProduct(TicProduct::T500);
               ^~

Error during build: exit status 1
Compilation failed
Command Process exited with code 1
The generated C++ code contains errors. It can be due to a bad node implementation or if your board is not compatible with XOD runtime code. The original compiler error message is above. Fix C++ errors to continue. If you believe it is a bug, report the problem to XOD developers.

The setProduct is in the library in the Parent, ticBase

/// This is a base class used to represent a connection to a Tic.  This class
/// provides high-level functions for sending commands to the Tic and reading
/// data from it.
///
/// See the subclasses of this class, TicSerial and TicI2C.
class TicBase
{
public:
  /// You can use this function to specify what type of Tic you are using.
  ///
  /// Example usage (pick one of the following):
  /// ```
  /// tic.setProduct(TicProduct::T500);
  /// tic.setProduct(TicProduct::T834);
  /// tic.setProduct(TicProduct::T825);
  /// tic.setProduct(TicProduct::T249);
  /// tic.setProduct(TicProduct::Tic36v4);
  /// ```
  ///
  /// This changes the behavior of the setCurrentLimit() function.
  void setProduct(TicProduct product)
  {
    this->product = product;
  }

Can someone say how to get this device in XOD to use the commands like

/// This function sends a "Set target position" to the Tic.  If the Control
  /// mode is set to Serial/I2C/USB, the Tic will start moving the motor to
  /// reach the target position.  If the control mode is something other than
  /// Serial, this command will be silently ignored.
  ///
  /// See also getTargetPosition().
  void setTargetPosition(int32_t position)
  {
    commandW32(TicCommand::SetTargetPosition, position);
  }

I thought it was also strange that the enums were defined as a class, an not typedef as in the ADS1X15 library. I’m not sure how to access them in XOD, since you can only have one Using Type xxxx in the node?

This is the code I have for the device definition, but it’s not working, and gives the above error


// Tell XOD where it can download the libraries:
#pragma XOD require "https://github.com/pololu/tic-arduino"

//Include C++ libraries
#include <Tic.h>
#include <Wire.h>

node {

    meta {
        // Define our custom type as a pointer on the class instance
        using Type = TicI2C*;
    }

    // Create an object of class Adafruit_ADS1115
    TicI2C sensor = TicI2C( 14 ); //Open the TicI2C wih default address 14

    void evaluate(Context ctx) {
        // It should be evaluated only once on the first (setup) transaction
        if (!isSettingUp())
            return;

        auto wire = getValue<input_I2C>(ctx);
        //auto addr = getValue<input_ADDR>(ctx);

        
        // Try to initialize sensor
        //if (!sensor->begin(addr, wire)) {
        //    raiseError(ctx);
        //    return;
        //}
        sensor->setProduct(TicProduct::T500);
        
        emitValue<output_DEV>(ctx, &sensor);
    }
}

TIC.xodball (3.1 KB)

I got the thing working! And figured out how to 1) use different addresses, 2) use the class enum, 3) access functions in the library

Thanks @wayland for all your work elsewhere on libraries! It enabled me to do this!!

I made the first couple of nodes to demonstrate
image

TIC.xodball (13.9 KB)

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.