We haven’t been able to fix our problem, regarding the java code for the micro serial-8 servo controller, in pololu mode
We are supposed to control a Lynx Robotic Arm with the help of a Modtronix SBC65EC and a Pololu Micro-8 servo controller, and we are supposed to use Muvium software (modified java code)
The blue jumper has been removed, and the servo controller is being powered up before the microcontroller. But still the only thing that happens is that the red light is glowing and the green light is flickering. Nothing more.
It started to move a little bit when there was a problem with the common ground a few days ago, but it was the wrong servos and movements. But it at least seemed like it was moving when it received commands from the controller. When we fixed the common ground again, we came back to the old problem with the red light etc.
Is there anyone that has an working java code example in java?
Here is a drawing of the wiring diagram:
CODE
import com.muvium.UVMRunnable;
import com.muvium.apt.*;
import java.io.*;
public class PololuTest extends UVMRunnable implements SerialPortListener
{
SerialPort vcom0;
OutputStream out1 ;
/**
* Echo the input..!
*/
public void serialEvent(SerialPortEvent event){ }
public void run(){
System.out.println("Starting..");
/**
* Setup COM0 (RB0)
*/
vcom0 = getPeripheralFactory().createSerialPort(
this,
PeripheralFactory.EVENT_PRIORITY_BACKGROUND,
SerialPort.COM0 |
SerialPort.IMPLEMENTATION_UART |
SerialPort.BAUD_2400);
vcom0.setOutputBufferSize( 50 );
try{
vcom0.start();
}catch(PeripheralUnavailableException e){
System.out.println("Err2");
}
out1 = vcom0.getOutputStream();
while(true){
try{
//servo 0 Set speed command 50
out1.flush();
//sleep(50);
out1.write(128);
//sleep(50);
out1.write(1);
//sleep(50);
out1.write(1);
//sleep(50);
out1.write(0);
//sleep(50);
out1.write(50);
//sleep(50);
System.out.println("Servo 0 speed set 50");
out1.flush();
sleep(100);
//servo 0 set position command 4000
out1.write(128);
//sleep(50);
out1.write(1);
//sleep(50);
out1.write(4);
//sleep(50);
out1.write(0);
//sleep(50);
out1.write(3968);
//sleep(50);
out1.write(32);
//sleep(50);
System.out.println("Servo 0 postion set 4000");
out1.flush();
sleep(2000);
//servo 0 Set speed command 110
out1.flush();
out1.write(128);
//sleep(50);
out1.write(1);
//sleep(50);
out1.write(1);
//sleep(50);
out1.write(0);
//sleep(50);
out1.write(110);
//sleep(50);
System.out.println("Servo 0 speed set 110");
out1.flush();
sleep(100);
//servo 0 set position command zero
out1.write(128);
//sleep(50);
out1.write(1);
//sleep(50);
out1.write(4);
//sleep(50);
out1.write(0);
//sleep(50);
out1.write(2944);
//sleep(50);
out1.write(56);
//sleep(50);
System.out.println("Servo 0 position set zero");
out1.flush();
sleep(2000);
}
catch(Exception e)
{
System.out.println("drittn verka no ikke en gang!");
}
doEvents();
}
}
}