Help interfacing Arduino and JrK 21v3


hi everyone,
i have project , want control linear actuator, lact6p, according values given accelerometer. accelerometer connected arduino , actuator controlled jrk 21v3. problem how interface arduino , motor controller.
i searched in many places on internet, found connection via serial possible using rx , tx inputs in boath board here's made:
i connected rx of 21v3 tx (pine 1) of arduino
i connected both gnd of 21v3 , arduino
i selected uart detect baude rate in configuration utility
i loaded code found on forum arduino:
code: [select]

/*
* motor control setup pololu jrk21v3 arduino uno r3, verified using linear actualtor lact2p
*
* pololu jrk config utility in serial mode using uart detect baud rate interface.
* starting default configuration settings lact2p linear actuators provided on pololu website
*
* pin 8 connected jrk pin rx
* jrk grnd connected arduino ground
*/


#include <softwareserial.h>
softwareserial myserial(7,8); // rx, tx, plug control line pin 8 , connect rx pin on jrk21v3

int mytarget = 0; // target position, 0-4095 range of jrk21v3 controller.

//stuff used input pc
char buffer[5] ;
int pointer = 0;
byte inbyte = 0;



// announcer pc serial output
void announcepos(int (position)) {
  serial.print("positiion set ");
  serial.println(position);
  serial.flush();
}




//sets new target jrk21v3 controller, uses pololu high resulution protocal
void move(int x) {
  word target = x;  //only pass ints, tried doing math in , remainder error screwed up
  myserial.write(0xaa); //tells controller we're starting send commands
  myserial.write(0xb);   //this pololu device # you're connected found in config utility(converted hex). i'm using #11 in example
  myserial.write(0x40 + (target & 0x1f)); //first half of target, see pololu jrk manual more specifics
  myserial.write((target >> 5) & 0x7f);   //second half of target, " " "





void setup()
{
  myserial.begin(9600);
  serial.begin(9600);
  serial.println("initialized");
  serial.flush();// give reader chance see output.

  int mytarget = 0; //the health level @ point in time
  serial.println("enter '#' , 4 digit position level (#0000-#4095)");

}

   

void loop()
{

  if (serial.available() >0) {
   // read incoming byte:
   
   inbyte = serial.read();
   delay(10);
   
   // if marker's found, next 4 characters position
   if (inbyte == '#') {
   

     while (pointer < 4) { // accumulate 4 chars
        buffer[pointer] = serial.read(); // store in buffer
        pointer++; // move pointer forward 1
      }
      serial.flush();
      //translating int
      mytarget=(buffer[0]-48)*1000+(buffer[1]-48)*100+(buffer[2]-48)*10+(buffer[3]-48);
      pointer =0;
   }
   
   
   //makes sure target within bounds
   if (mytarget < 0){
      mytarget = 0;
      }
   else if (mytarget > 4095){
      mytarget=4095;
      }
     
   move(mytarget); 
   announcepos(mytarget);


  }
}

when load arduino, there vibration in actuator seems happens, when open serial monitor , give values there no reaction @ all! notice actuator works when manually set target configuration utility.
can me plz, i'm not familiar language understand what's wrong code or make own!

that's pretty complex outfit, have no idea, but:
there search box @ top of page, "search arduino forum", type in:  jrk 21v3


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Help interfacing Arduino and JrK 21v3


arduino

Comments