Motion control uLisp?


#1

Hello,

I’m new to uLisp, and asking if anyone has advice and/or source code for driving steppers, servos, reading encoders, etc.

Thank you for your valuable time,

John


#2

Sorry for the delay in replying. There’s no built-in support in uLisp for driving steppers and servos or reading encoders, but you could add your own functions to interface uLisp to the Arduino libraries to do this. For more information see:

Adding your own functions


#3

Would love to see this. Not just for using servos, but also electronic speed controllers.

There are two corresponding Arduino functions involved.:
-servo.attach(pin)
-servo.write(angle)

Also, ‘servo’ above must be written as a variable of type ‘Servo’.

I’m having trouble though writing a new object ‘servowrite’ expression. I’m just a novice and having trouble dealing with those complications.

Is there anything similar done in lisp.ino that I might look to for insight? (I can’t see anything. Analogwrite is much more straightforward for example).

Any help appreciated.

Thanks.

edit - I see there may be even more to it than I originally thought. - http://playground.arduino.cc/Code/MegaServo

Also, an alternative approach might be to somehow convert the PWM of analogwrite to the needed PPM of servowrite using a hardware based solution. If anyone has any experience of this, please advise. Thanks again.


#4

It should be relatively easy to extend uLisp to add this. Have you thought what the syntax would look like in uLisp?

How many instances of Servo do you typically need?

By the way, the playground.arduino.cc link doesn’t work for me.
David


#5

Hi David. I had thought syntax could be as simple as servowrite(pin,angle).

It seemed to me it is the same as analogwrite only sending a different signal, Ppm rather than Pwm. (As per discussion here - https://forum.arduino.cc/index.php?topic=384423.0)

Now that you’ve asked question I will think some more about that.

I don’t know why the link’s not working for you. It is ok for me -
http://playground.arduino.cc/Code/MegaServo

I am planning on using ulisp and arduino for introducing my seven year old to programming, and playing with robots, so I’ve no typical requirement for number of instances.

Thanks. Ronan.


#6

It’s a bit more complicated than analogwrite because, looking at Servo.h in the Arduino Servo library, for each instance of Servo you allocate there are some internal variables to store the servo index, max, and min values.

One way round this in uLisp would be to provide a fixed number of 12 servos with:

Servo Servos[12]

and then provide uLisp versions of each of the Arduino Servo functions. Let me know if you want some more help.

By the way, that playground.arduino.cc link is working now - thanks.