Simple G2 controller alternate I2C for Arduino

I have 2 G2 units so I set unit B to I2C address 12 (even tried 15) via the windows command console. However, with the Arduino setMotorSpeed function, nothing happens to the motor other than when I use address 13.

How do I get it to work.

The code is simple, straight from the example

void setMotorSpeed(int16_t speed)
{
  uint8_t cmd = 0x85;  // Motor forward
  if (speed < 0)
  {
    cmd = 0x86;  // Motor reverse
    speed = -speed;
  }
  
  Wire.beginTransmission(smcDeviceNumber);
  Wire.write(cmd);
  Wire.write(speed & 0x1F);
  Wire.write(speed >> 5 & 0x7F);
  Wire.endTransmission();
}

I set smcDeviceNumber=12 (or whatever the setting is) and nothing happens.

Hello.

Can you successfully move your motor using the slider in the “Status” tab of the Simple Motor Control Center G2? Also, are any errors showing that they are stopping the motor (or have a non-zero count) in that same tab of the control center?

If you set smcDeviceNumber to 13, does your program work with your SMC G2 that is still using the default device number (which is 13)? Could you post pictures of your setup that show all of your connections? Also, could you post a copy of the settings files from each of your SMC G2 controllers (indicating which one is which)? You can save a copy of the settings file from the “File” drop-down menu of the Simple Motor Control Center G2.

Brandon

If I use the center, the motor moves, but it is using a usb, not i2c, so I don’t see the relation.

This is on an Arduino. I posted my code and I only change the i2c number to make either work or not work (obviously changing the configuration). There are only 3 connections, the 2 i2c and one gnd. The motor power comes through the VIN end.

Attached is the setting file (if I can figure out how)

# Pololu Simple Motor Controller G2 settings file.
# https://www.pololu.com/docs/0J77
product: 18v15
input_mode: serial
mixing_mode: none
serial_mode: binary
enable_i2c: true
serial_device_number: 12
crc_for_commands: false
crc_for_responses: false
uart_response_delay: false
use_fixed_baud_rate: false
fixed_baud_rate: 9600
rc1_alternate_use: none
rc1_invert: false
rc1_scaling_degree: 0
rc1_error_min: 2000
rc1_input_min: 4000
rc1_input_neutral_min: 5900
rc1_input_neutral_max: 6100
rc1_input_max: 8000
rc1_error_max: 10000
rc2_alternate_use: none
rc2_invert: false
rc2_scaling_degree: 0
rc2_error_min: 2000
rc2_input_min: 4000
rc2_input_neutral_min: 5900
rc2_input_neutral_max: 6100
rc2_input_max: 8000
rc2_error_max: 10000
analog1_alternate_use: none
analog1_pin_mode: floating
analog1_invert: false
analog1_scaling_degree: 0
analog1_error_min: 0
analog1_input_min: 40
analog1_input_neutral_min: 2015
analog1_input_neutral_max: 2080
analog1_input_max: 4055
analog1_error_max: 4095
analog2_alternate_use: none
analog2_pin_mode: floating
analog2_invert: false
analog2_scaling_degree: 0
analog2_error_min: 0
analog2_input_min: 40
analog2_input_neutral_min: 2015
analog2_input_neutral_max: 2080
analog2_input_max: 4055
analog2_error_max: 4095
pwm_period_factor: 0
motor_invert: false
coast_when_off: false
speed_update_period: 1
forward_max_speed: 3200
forward_max_acceleration: 0
forward_max_deceleration: 0
forward_brake_duration: 0
forward_starting_speed: 0
reverse_max_speed: 3200
reverse_max_acceleration: 0
reverse_max_deceleration: 0
reverse_brake_duration: 0
reverse_starting_speed: 0
current_limit: 921
current_offset_calibration: 993
current_scale_calibration: 8057
min_pulse_period: 9
max_pulse_period: 100
rc_timeout: 500
consec_good_pulses: 2
vin_scale_calibration: 1148
temp_limit_gradual: false
over_temp_complete_shutoff_threshold: 800
over_temp_normal_operation_threshold: 700
low_vin_shutoff_timeout: 250
low_vin_shutoff_mv: 5500
low_vin_startup_mv: 6500
high_vin_shutoff_mv: 25000
disable_safe_start: false
ignore_pot_disconnect: false
ignore_err_line_high: false
never_sleep: false
command_timeout: 0

I got it to work, but I honestly don’w know what I did to make it work. Since I have multiple G2 devices connected together on the i2c link, I just tried each separately, then together, then with and without the i2c connections. Put it all back the way I started and it all magically started working again.

That is strange, but I am glad you got it working. Thank you for letting us know.

My guess would be that it was a connection issue; for example, maybe there was an intermittent connection in one of your wires or from a breadboard, if you are using one, but it’s hard to say for sure.

Brandon