analogue into an arduino a-star controlling a robo claw controller in encoder mode hooked up exactly like in page 48 in the orion manual
analogue into an arduino a-star controlling a robo claw controller in encoder mode hooked up exactly like in page 48 in the orion manual
Dear: Allan
You said to element 14 that you are not getting how to use a rotary encoder but what are you not getting? You are not very specific.
From: Noah
I am trying to write a program for the arduino a-star to accept analog input from a pot with 0 to 5 volt output, go threw the arduino a-star and come out of it with packet serial to the roboclaw in encoder feedback mode like a servo.
is line 9( RoboClaw roboclaw(5,6);) for PWM input on pins 5 and 6?
I am getting an error in this line terminal.print(“Encoder1:”); terminal.print(enc1,HEX); terminal.print(“ “); terminal.print(status,HEX); terminal.print(“ “);
And I think the error says, stray "(" in program
Dear: Allan
Sorry it took me so long to respond to your post I was running into a problem with my computer. No pins EN1 and EN2 are your pin inputs and outputs to your encoder. EN1 which stands for encoder 1 is your pins for your first encoder. Pins EN2 which stands for encoder two is your second encoder. Good luck.
From: Noah
is this what you mean terminal.print(“En1:”); terminal.print(enc1,HEX); terminal.print(“ “); terminal.print(status,HEX); terminal.print(“ “);
Give this code a shot I am pretty sure it will work
//Basic Micro RoboClaw Packet Serial Mode.
//Switch settings: SW3=ON, SW4=ON, SW5=ON
#include “BMSerial.h”
#include “RoboClaw.h”
#define address 0x80
#define Kp 0x00010000
#define Ki 0x00008000
#define Kd 0x00004000
#define qpps 44000
BMSerial terminal(0,1);
RoboClaw roboclaw(5,6);
void setup() {
terminal.begin(38400); roboclaw.begin(38400);
roboclaw.SetM1Constants(address,Kd,Kp,Ki,qpps); roboclaw.SetM2Constants(address,Kd,Kp,Ki,qpps);
}
void loop() {
uint8_t status;
bool valid;
uint32_t enc1= roboclaw.ReadEncM1(address, &status, &valid);
valid = terminal.print("Encoder1:") && terminal.print(encl,HEX) && terminal.print(" ") && terminal.print(status,HEX) && terminal.print(" ");
uint32_t enc2 = roboclaw.ReadEncM2(address, &status, &valid);
valid = terminal.print("Encoder2:") && terminal.print(enc2,HEX) && terminal.print(" ") && terminal.print(status,HEX) && terminal.print(" ");
uint32_t speed1 = roboclaw.ReadSpeedM1(address, &status, &valid);
valid = terminal.print("Speed1:") && terminal.print(speed1,HEX) && terminal.print(" ");
uint32_t speed2 = roboclaw.ReadSpeedM2(address, &status, &valid);
valid = terminal.print("Speed2:") && terminal.print(speed2,HEX) && terminal.print(" ");
terminal.println();
delay(100);
}
From: Noah
do I write this to the roboclaw or to the a-star or both?
I am pretty sure you send it to the robo claw but what is the difference?
Dear: Allan
It is neither this code is supposed to work with arduino uno. But you could probably make it compatible with the board and in that case I wish you good luck!!!
From: Noah
Thank you I will try to make it work.
Allan Manuel
Thank you I will try to make it work.
Allan Manuel