serial.write to pololu motor controller not working

i am trying to make an inverted pendulum using 2 rotary encoders, a DC motor and a pololu motor controller. the code seems to be working properly, and i can get angle velocity outputs from the encoders but when i hook the motor controller up to the Rx output i am getting nothing from the controller. no voltage output to the motor from the controller.

i'm attaching the code. does something look off in here?

measure_states.ino (3.02 KB)

motor.ino (510 Bytes)

pendulum_program_PID.ino (3.15 KB)

I note the comment:

// because a 9V battery is used to power the motor

which immediate rings alarm bells.

this is cannibalized code and that was from someone else's project. my motor is much bigger and running off a 19.5V 7A power supply, i guess i missed that in the notes but the math in the code definitely shows 19.5V or else my output would be very wrong.

That's an awful lot of code when you don't know that the hardware works. Perhaps a much shorter sketch is in order, to test the hardware.

How is the Arduino putting out 19.5V for you?

By the way, which Arduino is this code running on?

all of this is on a mega2560 using the 2,3,20 and 21 interrupt pins. 19.5v is coming from an old laptop dc power pack plugged directly into the motor controller, arduino is running off usb port on laptop, rotary encoder 5V is running off arduino 5V pin. pin 18 outputs rx from the arduino to tx on the motor controller. i have test code that works to display counts, angle, and velocity in the serial monitor just fine so i know the sensors are reading properly on the arduino. it's orchestrating the motor to move based on these sensors that is now the problem.

i have been doing this all in ubuntu, but i just found pololu has a program in windows for the motor controller so i switched laptops and it seems to be the motor controller that is throwing errors and not giving the motor juice.

papayadialog:
a DC motor and a pololu motor controller.

What motor controller ?

Post a link to its datasheet.

...R

i am using the 24v12 simple motor controller with 19.5V into the Vin and ground, OutA and OutB go to motor inputs, and the Rx and Tx are linked via Arduino Mega 2560 pin 18 and the motor controller and the ground next to Rx is grounded to the Arduino. the error light on the arduino has not gone off since i plugged it in, but the Rx/Tx light is flashing like they're talking...

the error light on the arduino has not gone off since i plugged it in

That's a power light. It SHOULD be on.

papayadialog:
https://www.pololu.com/docs/pdf/0J44/simple_motor_controllers.pdf

There are over 100 pages in that document. Which page tells you what serial commands the controller uses?

I suspect Pololu has some simple example code that you should use to figure out how the thing works.

...R

page 94 has a very similar example code to what i am using if that helps?