gunhaxxor / me-high-power-motorboard-firmware

Custom built firmware for the atmega 328p on the Me High-Power Encoder Motor Driver board.
2 stars 3 forks source link

setting speed #3

Closed streakerau closed 6 years ago

streakerau commented 6 years ago

Hello, I successfully uploaded your firmware to the encoder board. I'm trying to set speed from a Me Auriga board.

We are using the MeEncoderNew library from Makeblock to do so...

//Setting up motors
MeEncoderNew motor1(0x09, SLOT1);
MeEncoderNew motor2(0x09, SLOT2); 

// initialise motors in Setup
motor1.begin();
motor2.begin();

// set mode
motor1.setMode(1);  //0:I2C_MODE;1:PWM_MODE;2:PWM_I2C_PWM;
motor2.setMode(1);

//set speed
motor1.runSpeed(11, 0);
motor2.runSpeed(11, 0);

We can control the motors correctly but the range is very small. With the previous firmware we could control speed setting a value from -255 to 255. With the current firmware with value 10 the motors move for one second and than stop and with value 11 they go extremely fast.

I was wondering if you could share the code you use to set speed from the external board. thanks!

gunhaxxor commented 6 years ago

Hmmm. I must confess I'm not that up to date with our code base to answer your question. And I'm currently on vacation so I don't have the hardware in front of me. But. I can share with you the code that is running on our Orion board. https://github.com/tiigbg/telepresence-motorcontrol/blob/master/motorcontrol/motorcontrol.ino Our robot has mecanum wheels, and we have some code on the orion to make the robot able to strafe. The orion code receives commands from a computer over serial. This command consists of a rotation speed, direction and movement speed. The Orion code then calculates the proper speeds for the four motors according to the algoritm/equations found in this paper: http://eprints.utem.edu.my/16543/1/Omni%20Directional%20Control%20Algorithm%20For%20Mecanum%20Wheel%2024%20Pages.pdf

Here is a link to the node program that sends the serial commands to the orion board: https://github.com/Dealerpriest/websocket-to-serial/blob/master/websocket-serial-server.js

I'm aware that this might be a lot to dig through, but as of now I can't provide that much more help.

A thought I had is that I see that your code calls setMode(1). In our code we never call setMode() i think. Maybe that could be an issue, even though I right now wouldn't know how.

streakerau commented 6 years ago

Thanks mate, I managed to make it work getting rid of the PID because we didn't really need it for our application. Thanks so much about your help, our robot is now way less noisy and annoying which is awesome!

gunhaxxor commented 6 years ago

Nice! We should document the firmware better. I hope to find some time after vacation to do that!