Java code for Bosch seat motor with DIO kit

Investigating the use for this motor.

Would someone have an example for programming the motor and encoder using the Andymark DIO kit in java command based?

Sent from my iPhone using Tapatalk

Hi Coach Seb,

Sorry for late reply. Do you still need support on this? Our programming team (FRC 862) was able to get this to work using Java. I can have them add an example.

Hello, can anyone help me with this? Our team is having trouble
Coding and generally getting the Bosch seat motor to work using the chip and dio .

Okay the first thing to realize is that the hall effect information is really a counter, not a true encoder – we are getting movement information, not direction. So to use it as an encoder it is necessary to integrate it with your control signal as well.

Counter motorCounter = new Counter(new DigitalInput(1));

will get you the “tick” count on the motor. The next step is to maintain a second variable that keeps track of your position (this would do well in periodic function in a subsystem)

// a field variable
private int position 0;

public void periodic() {
   if (going_forward) {
      position += motorCounter.get();
   } else {
      position -= motorCounter.get();

Now the position variable is a reasonable encoder value. In my experience there is some loss of precision due to switching between moving up and down, so it is worthwhile to have either limit of travel sensors that also inform your position variable or at least a single “reference point” sensor to keep error from building up.

Have you verified you are getting a good signal? The chip you buy from AndyMark is a bit tricky to solder and if you get any bridging it will affect the output. The DIO needs a nice clear output between the min threshold. Typically with a bad solder you’ll see a bunch of noise or a signal that only drops a few mV which can’t be read by the DIO.