Using Ripmax SB09 Servo

Hi everyone,

I am completely new with Arduino, and I am feeling a bit overwhelmed, so I would like some guidance.

I am trying to use a Ripmax SB09 Servo (see here for the exact product) with my Arduino Uno R4 Minima coupled with a Grove - Arduino starter kit.

More specifically, my (simplified) project would be to use the SB09 that should be both a potentiometer and a servo in one like follows:

  1. the user set the SB09 to a certain angle (directly with their own hands),
  2. the user both a button (I understand that part),
  3. the SB09 go to another given position depending on the set angle.
    Rince and repeat.

My problem is I have absolutely no idea how to do that, from the linking of the SB09 to the board to what software to write to make it work. I suspect that I would need to use an analogue port, but can the same port be used for both INPUT and OUTPUT? And similarly software-wise? Since the SB09 is not "plug-and-play" compatible with the Arduino, how to I make it work? I suspect that both the <Servo.h> library and the standard use of pinMode(potentiometer, INPUT); in the software cannot be enough if the component is both.

Could you kindly share with me some insights? Thank you in advance.

As a start, I have successfully followed a few tutorial project with the kit, so you may not need to mention the preliminary step of learning how to do the most elementary tasks with the board.

Stop right there

Servos are not designed to be used as input devices. Turning the output arm by hands can easily strip the servo gears. To add to your problems such a servo has no means of outputting its position so that it can be read by the Arduino

A rotary encoder would be a better choice of input device. The user could turn the encoder to the required angle, press the button (often part of the encoder mechanism) and have the servo move to the required position

Another product that exists and is affordable that is exactly why you want might be exactly what you should use.

google

  motorized potentiometer rotary

and look for what is a regular pot with a gear motor attached, designed to be turnt either by hand or the motor.

Your idea practicalized.

I clicked for images and spotted one from Mouser I'd link except the information device I'm using here won't let me go to Mouser and I'm not figuring that out in any thing like record speed.

HTH

a7

I guess Mouser doesn't want my business, such as it was.

But they did let me see the data sheet.

https://www.mouser.com/datasheet/2/54/PRM16-778060.pdf

a7

I thought that the SB09 could be used as input device as well given the technical details of the product, but I guess I misunderstood it. Thank you for correcting me. I'll look for an alternative.

Thank you for your answer, this is exactly what I am looking for! And what I thought I had...
The product you point out however seems to be working with a voltage of 150V, which are two order of magnitude higher than the standard output from the Arduino. As, ideally, and want to power everything with a 9V battery, it would not be my first choice.

Assuming it would fit, how would I handle it to use it through the Arduino?

Please don't tell me that you intended to use a PP3 battery ...

I'm in transit so I'll look when I'm in my lab, but this is almost certainly a wrong interpretation of something you are reading in the datasheet.

Let us hope.

a7

Probably this section

Power Rating
B3 Taper ...................................................................................................................................... 0.1 watt
Other Tapers .............................................................................................................................. 0.05 watt
Maximum Operating Voltage ................................................................................................... 150 Vac

I did. Given your reaction, I suppose it would not last long? I want it to last for about 10 days only, with the possibility to change the battery a couple of times.

Indeed, this is the section I was looking at.

It won't

It might help if you described your project in more details

Of course: I am trying to build an analog to a qubit. The idea is that the potentiometer is the (fake) qubit, taking any value between 0 and 360° (or as much as mechanically possible) with 0° being the 0 state and 180° being the 1 state. Once the user set whatever angle they want, they push a button to do a "measurement". The result of the measurement depends on the set angle and a probability distribution handled by the Arduino. A LED would lit up if the measure is 1, and would stay off otherwise. In addition, the potentiometer would rotate to set itself to the pure 0 or 1 configuration (0° or 180°) according to the measure result. The random part when the initial configuration is not pure is handled by the Arduino.
The whole system would be mounted up on a panel to put at a temporary exhibition in a museum for an upcoming event, with little maintenance during the event.

OK. So that motorized pot will work well.

It has but you will not need its ganged pair, for stereo I imagine.

The motor runs on 4.5 volts, that can be controlled by one output pin. You'll need a driver moduke or a simple circuit of a transistor, a diode and two resistors.

The pot can be wired as a votage divider, and be read using one analog input.

The coding of the qubit is trivial. Because I know nothing about what you are talking, I cheerfully assume you got that part, or at least have the maths and the algorithm handled.

The supply of power remains an issue. If you absolutely cannot plug this thing in (best), you could use beefy rechargeable batteries that might each easily power it for hours, maybe even from opening to closing of the exhibit daily.

During development, use a beefy 5 volt power supply, a so called wall wart or even just a 10 watt cellphone charging plug-in.

This will allow for development of the harder parts, as well as provide an opportunity to measure the current actually being drawn variously and to think about use patterns so that a watts-per-hour figure can be clacukated. This will inform battery selection.

I would use Lipo batteries and a step-down regulator, my go-to solution for portable things. Lipos are available in a wide variety of capacities, are relatively cheap and, treated well, a beautiful source of power.

An alternate might be a cell phone juice pack. Totally simple. I've used that for portable things, too.

HTH and we look forward to helping when we can see your code or get you started on it if you are out at sea on the whole idea of making a sketch for this. Except for the maths around the quvit, the rest of the sketch is nearly trivial, except for the inevitable pesky details that yet plague writing even the simplest of sketches.

a7

1 Like

Why don't you use a standard manual pot with a knob! Cheap as chips.

Thanks a lot for all of these suggestions!
I'll buy the pot then and hope for the best.

The coding of the qubit itself is already done by me, at least using a normal potentiometer (that doesn't move afterwards of course). You may find it here if you are interested (the use of the lcd screen is just me playing around). It was my plan C.

You'll need a driver moduke or a simple circuit of a transistor, a diode and two resistors.

I am not sure I fully understand this part (I am a theoretician). Do you mean something like this? What is it for?

Concerning the battery option, I can use an extra phone battery easily. Plugging is still on the table, but the panel is likely to be, among other, in the middle of the room, such that running a cable there is not ideal.

As a fall-back solution, it is indeed what I would do. Having a single knob that moves by itself when measured is however ideal for what I want to show.

No quite.

This

is what I have in mind. Someone at a higher paygrade can help with the fact the the motor want 4.5 volts, and this will, it seems, be delivering 5. Not a problem, but needs to be handled.



No good reason not to post the here, now, next.

Use the IDE Autoformat tool if your style is ragged.

Next use the IDE Copy for Forum tool on the sketch.

Then paste it in a new post on this thread.

So your code will look like code, we can copy it and play with it ourselves and so forth, viz:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

a7

No problem:

#include <Wire.h>
#include "rgb_lcd.h"

rgb_lcd lcd;

const int colorR = 255;
const int colorG = 0;
const int colorB = 0;
const int pinButton = 3;
const int pinLed    = 7;
const int potentiometer = 0;
int randomNumber;
int sensorPosition_2;
int proba;

void setup()
{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  lcd.setRGB(colorR, colorG, colorB);

  // Print a message to the LCD.
  lcd.print("Angle of potentio");
  // Configure the button's pin for input signals.
  pinMode(pinButton, INPUT);
  pinMode(potentiometer, INPUT);

  // Configure the LED's pin for output.
  pinMode(pinLed, OUTPUT);
}

void loop()
{
  // Read the value of the angle sensor.
  int sensorPosition = analogRead(potentiometer);
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(sensorPosition);

  if (digitalRead(pinButton)) // When the button is pressed,
  {
    // Read the value of the angle sensor.
    //int sensorPosition = analogRead(potentiometer);
    // The analog value from the angle sensor is between 0 and 1023, but
    // the is between 0 and 100; use the map()
    // function as a linear conversion between the two ranges.
    if (sensorPosition > 512)
    {
      sensorPosition_2 = 1024 - sensorPosition;
    }
    else
    {
      sensorPosition_2 = sensorPosition;
    }
    proba = map(sensorPosition_2, 0, 512, 0, 100);

    randomNumber = random(0 + proba, 100 + proba);
    if (randomNumber > 100)
    {
      //  turn the LED on.
      digitalWrite(pinLed, HIGH);
      delay(2000);
    }
    else
    {
      // Otherwise, turn the LED off.
      digitalWrite(pinLed, LOW);
      delay(2000);
    }
  }
  else
  {
    // Otherwise, turn the LED off.
    digitalWrite(pinLed, LOW);
  }

  delay(10);
}

// Read the value of the angle sensor.
int sensorPosition = analogRead(potentiometer);

// The analog value from the angle sensor is between 0 and 1023, but
// the servo only accepts values between 0 and 179; use the map()
// function as a linear conversion between the two ranges.
int shaftPosition = map(sensorPosition, 0, 1023, 0, 179);

Are there any relatively inexpensive servos that work as the OP wants?
Getting the position feedback should be relatively easy, but I'm not sure how one implements the mechanics to have the motor be moveable externally...