Kwatters has been talking about a software servo that could use either a continous rotation servo or some other motor using an analog feedback from a potentiometer and a configurable PID.

I think that all the bits and pieces are there now to build that type of servo. But before I start building, I prefer to get some input about the archtecture of that service, because I always find many different alternatives to boild things. Good software architecture makes it fun to build, and bad architecture is a pita. I think MRL has a very good architecture and it gets improved over time.

The way I think of it now is that the new servo should be it's own class, i.e it should not be in the current Servo class. 

The new servo class should implement ServoControl, so that it can be used the same way as the current Servo. But it also needs a few other methods so that it can be configured.

So the type of configuration needed is that the new servo needs to know what MotorController to attach to, and it also needs to know what PinArrayControl to attach to.

It should create a PID Peer, and perhaps a Motor Peer, but since PinArrayControl is implemented in both Arduino and Ads1115, I don't want to start a Peer for the Analog input.

I was first thinking that it should be able to use either a MotorController or a ServoController, but i changed my mind to think that it only should use a MotorController. So how about continous rotation servos ? Right now I think that the best route is to add a new MotroConfig<Servo>  that can be used for continous rotation servos ( i.e. hacked servos but withot any feedback )

Happy to hear any input.

/Mats

kwatters

7 years 8 months ago

I think the general idea is for a DIY servo that you want to have a standard motor controller, a regular potentiometer, and a software based PID control system.

So, I think making a new Service named  "DiyServo" is the way to go.  It should create these other services as peers, and implement ServoControl..  

Similar to how the InMoov is a collection of lower level services; the DiyServo would be similar in that it's a collection of lower level services thare are coordinated to implement a greater functionality 

...

woohoo!  The peices are definitely in place now for this to happen.  Especailly with all the work that everyone did to refactor MrlComm,  I think it will better accomidate trying to do something like this.

 

I'm planning to make it configurable, so that you can choose how to use it. So connect any motor using the Motor service. The plan is to extend the Motor service so that a continous rotation servo can be used as a motor. l already modfified the Adafruit16CServoDriver service so that it can be used to drive a motor.

Same thing with the Analog input. It can be any service that can send an analog value. I will test using both an Arduino and Ads1115 that is i2c enabled.

If you choose to use i2c, both the Arduino and RasPi can do that.

i2c works a bit slow on the Arduino but very well on the RasPi. 

One of the motors that I'm experimenting with is from a cordless 12V drill, but my L289N overheated. Luckily it has thermal protection, so no smoke, just odd behavior. I started, run a few seconds and then stopped, and the it started again, and stoppped and so on....

This motor has a built in gearbox and high torque. Somehere about 8Nm = 80 kg cm. So about twice what you get from a servo + speed is much higher. And the cost for it is less that what a HS805BB servo cost, and that it includes a 12V battery and a 12 battery charger. 

 

juerg

7 years 8 months ago

In reply to by Mats

Yes, sounds great. I have also installed fuses to protect my servos now and it's the same behavior - you run the servo repeatedly for and back and at some point it stops. Aber the cool down of the fuse the motor resumes its action.

So you have to add cooling to the L289N or use a replacement that allows for more current? Can you also give the part information of the motor and gearbox?

Ads1115 looks to be cheap. Is it L289N or L298N you used so far? L298n says to allow for 3 amps, that's a good amount of power.

The first version of DyiServo is now available in MRL. Many tests remain to be done, but the basic structure is there. The script below can be used to test it. It's a java implementation that uses a MotorController service like the Arduino or Adafruit16CServoDriver. It subscribes to a pin from any analog input that publishes a pin, for example theArduino or the Ads1115. It doesn't require any new MRLComm. The example script uses pin 10 and 11 for pwm and A0 ( pin 14 ) as analog input. This is because I test on an Arduino Uno. 

It's important to connect the motor pins to pwm enabled pins as described here: http://myrobotlab.org/service/Motor

Connect the middle pin of a potentiometer to the analog pin that you want to use. One pin to VCC and the other pin to GND.

# Start of script for DiyServo
# Analog input A0 is the same as digital 14 on the Arduino Uno  
A0 = 14
# Start the Arduino
arduino = Runtime.createAndStart("Arduino","Arduino")
arduino.connect("COM3")
# Start Servo
servo = Runtime.createAndStart("Servo","DiyServo")
servo.setPwmPins(10,11)
servo.attach(arduino)      # Attach the motorcontroller
servo.attach(arduino,A0) # Attach the analog pin 0 
servo.moveTo(90)
# End of script for DiyServo

The idea is that the DiyServo should be able to use any MotorController ( ie Arduino or Adafruit16CServoDriver ) and any service that implements PinArrayControl (i.e Arduino or Ads1115. Perhaps this requirement could be relaxed so that DiyServo can listen to any service that can publish an analog value. 

For example, it would be very nice to be able to use the measurements from a gyro/accelerometer as input to this service. 

The PID settings may need to be changed depending of the motor and mechanical build.