Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: empedokles on October 24, 2013, 05:36:25 PM

Title: A20 and motors
Post by: empedokles on October 24, 2013, 05:36:25 PM
Can I control a motor with the A20 using python responding to sensor input? How hard is this if I know some python?
Title: Re: A20 and motors
Post by: empedokles on October 29, 2013, 05:29:40 PM
Nobody knows?
Title: Re: A20 and motors
Post by: blejku on October 29, 2013, 06:54:33 PM
Virtually everyone .. even combustion :-)
Title: Re: A20 and motors
Post by: empedokles on October 29, 2013, 09:59:10 PM
Without C code?

Tutorials needed.
Title: Re: A20 and motors
Post by: blejku on October 29, 2013, 10:12:52 PM
Just look for the GPIO .. Well, but ok.

A20 issues on pin 7 slot 3 is high / low. By the way, the LED will flash. I think that enough is enough for you


#!/usr/bin/python
#-*- coding: utf-8 -*-
# Migamy dioda wbudawana olimex

# biblioteki
import A20_GPIO as GPIO
import time
# Zdefiniowane portu LED
# GPIO.PINx_y

# x - nr gniazda - socket
# y - nr pinu - pin

LED = GPIO.PIN3_7

# inicjalizacja GPIO
GPIO.init()

#ustawienie jako wyjscie - seting as output
GPIO.setcfg(LED, GPIO.OUTPUT)

def main():


        GPIO.output(LED, GPIO.HIGH)
        time.sleep(1)
        GPIO.output(LED, GPIO.LOW)
        time.sleep(1)


while 1 == 1 : main()
Title: Re: A20 and motors
Post by: empedokles on October 29, 2013, 10:47:14 PM
So I won't need anything else than this library for motors, sensors? A link would be neat (I found it over the blog).
Title: Re: A20 and motors
Post by: blejku on October 29, 2013, 11:04:48 PM
http://olimex.wordpress.com/2013/08/21/python-gpios-module-for-a20-olinuxino-micro/

Depends on what the sensors. But overall the python will are many at this time.
Do you have any experience with electronics?
Motor directly can not be controlled. What is needed is called. current amplifier. For example, transistor
Look for the Raspberry Pi projects. The principle is the same so it may be easier and cheaper to just use the Raspberry
Title: Re: A20 and motors
Post by: Tom on October 30, 2013, 12:18:20 AM
Sensors will have to be read manually though, because there still is no interrupt driven solution for the a20.
Title: Re: A20 and motors
Post by: empedokles on October 30, 2013, 12:56:03 AM
No experience with electronics. Is there no simple way to use Python for sensors and motors? Maybe I'm better off with an Arduino uno and some grove-sensorshield. But I would have to learn that C syntax.

What is meant with "have to be read manually"?
Title: Re: A20 and motors
Post by: martinayotte on October 30, 2013, 01:31:50 AM
There are lot of factors to consider, depending the project you have in mind.

First, what kind of motor ? stepping motor or DC motor ? which torque/power do you need ?
Stepper are more easy to control since they don't really need much feedback loop except limit sensors for positioning, but they usually less powerfull and more expensive than DC for the same torque.

Second, your sensor ? what kind of sensors do you have in mind ? limit sensors ? position sensors ?
Third, do you wish speed control ? many kind of feedbacks can be collected from a motor, that's why we call those motor controllers as "servos".

In some case, you probably end up with hardware servo, because CPU won't be able to process it properly if it is busy doing many tasks, so, you can have, for example, several small controllers such Arduino-Nano, one for each motor, and your Olimex board simply sending orders to those controllers.

Hope this help,
Martin
Title: Re: A20 and motors
Post by: pete_l on October 30, 2013, 01:57:50 PM
Quote from: empedokles on October 30, 2013, 12:56:03 AM
No experience with electronics. Is there no simple way to use Python for sensors and motors? Maybe I'm better off with an Arduino uno and some grove-sensorshield. But I would have to learn that C syntax.

What is meant with "have to be read manually"?
If that's all you need to do: have a sensor that controls the speed / direction of a motor, then yes - an Arduino would be a good choice. An A20 (or any Linux board for that matter) is overkill for an application like that and is quite complex, too.
However, if you need more - say to have a web interface and to control a motor over the internet and maybe log its activity, then an A20 would be a good choice.
Title: Re: A20 and motors
Post by: empedokles on October 30, 2013, 08:59:00 PM
QuoteFirst, what kind of motor ? stepping motor or DC motor ? which torque/power do you need ?

Probably stepping-motor (this is what others recommended). It's for a screw conveyor (wood drill in a pipe) to convey food (cat/dog dry food size). 40cm circumferance.

QuoteSecond, your sensor ? what kind of sensors do you have in mind ? limit sensors ? position sensors ?

Ideas: RFID. Motion sensor. And button push. But flexible for anything. The idea is the birds should get food if they do some action.

QuoteThird, do you wish speed control ? many kind of feedbacks can be collected from a motor, that's why we call those motor controllers as "servos".

I don't understand feedback. Does it collect resistance?

QuoteIn some case, you probably end up with hardware servo, because CPU won't be able to process it properly if it is busy doing many tasks, so, you can have, for example, several small controllers such Arduino-Nano, one for each motor, and your Olimex board simply sending orders to those controllers.

There is only one motor I guess. What is the benefit of a additional Arduino if ARM isn't realtime? It still won't be realtime controlling the motor with the Arduino, wouldn't it?
Title: Re: A20 and motors
Post by: empedokles on October 30, 2013, 11:46:31 PM
Found this:
http://www.youtube.com/watch?v=b4uhh_j8uR0

(Unfortunately there are no good Olimex-Howtos on Youtube)
Title: Re: A20 and motors
Post by: empedokles on October 31, 2013, 07:24:43 PM
Quote from: Tom on October 30, 2013, 12:18:20 AM
Sensors will have to be read manually though, because there still is no interrupt driven solution for the a20.

What do you mean by that? There are sensors available that can be used with the Raspi. Why won't this be possible with a Olimex A20?
Title: Re: A20 and motors
Post by: blejku on November 01, 2013, 01:00:02 AM
This means that the program will be a little slower and more complicated. Sensors need to query and not wait until the report change. That's all.
Title: Re: A20 and motors
Post by: empedokles on November 01, 2013, 01:02:03 AM
QuoteThis means that the program will be a little slower and more complicated. Sensors need to query and not wait until the report change.

So it isn't event-based? Will this be different on the Raspi?
Title: Re: A20 and motors
Post by: Tom on November 02, 2013, 03:29:47 AM
Quote from: empedokles on November 01, 2013, 01:02:03 AM
QuoteThis means that the program will be a little slower and more complicated. Sensors need to query and not wait until the report change.

So it isn't event-based? Will this be different on the Raspi?

Yes, the raspi has event based gpios. I experienced massive timing problems with the a20s gpios compared to the raspi. And "little slower" is not true, it kills the performance really bad, if you want to keep the delay very low. Sometimes you can even miss an event.
Title: Re: A20 and motors
Post by: empedokles on November 02, 2013, 12:35:32 PM
Quote from: Tom on November 02, 2013, 03:29:47 AM
Quote from: empedokles on November 01, 2013, 01:02:03 AM
So it isn't event-based? Will this be different on the Raspi?

Yes, the raspi has event based gpios. I experienced massive timing problems with the a20s gpios compared to the raspi. And "little slower" is not true, it kills the performance really bad, if you want to keep the delay very low. Sometimes you can even miss an event.

Thank you for your honest reply on that, Tom. Shall I look into the BBB as well or won't it come with event-based gpios. Technically the BBB appeals more to me, but their community seems much smaller, there are a bunch of tutorials on adafruit though.
Title: Re: A20 and motors
Post by: blejku on November 03, 2013, 02:53:29 PM
One more thing
Depends on how long an event .. Or rather, with what resolution and accuracy to be recorded. With very short events can help yourself electronics. You can also use the shift register. GPIO ports is a lot.

Title: Re: A20 and motors
Post by: empedokles on November 04, 2013, 01:15:45 PM
Quote from: blejku on November 03, 2013, 02:53:29 PM
One more thing
Depends on how long an event .. Or rather, with what resolution and accuracy to be recorded. With very short events can help yourself electronics. You can also use the shift register. GPIO ports is a lot.

What is a short event? What are shift registers? :-)
Title: Re: A20 and motors
Post by: blejku on November 05, 2013, 12:30:35 AM
http://en.wikipedia.org/wiki/Shift_register

short .. :-) For example, being one millionth of a second
Title: Re: A20 and motors
Post by: frafra on December 22, 2013, 12:37:01 PM
What about connecting A10/A20 to OLIMEXINO-85-ASM for example? Wouldn't be easier to control a motor like servo motor MS-R-1.3-9 from an Arduino like device?
Title: Re: A20 and motors
Post by: dave-at-axon on December 23, 2013, 03:53:49 AM
Or better still, find a motor controller with a serial interface. Your lack of electronics experience will mean a lot of work trying to get this working with GPIO as you'll need to know how to wire it up.
Title: Re: A20 and motors
Post by: frafra on December 25, 2013, 12:58:01 AM
I found this interesting project for Raspberry Pi: http://pythonhosted.org/RPIO/pwm_py.html#rpio-pwm-servo (http://pythonhosted.org/RPIO/pwm_py.html#rpio-pwm-servo)
Is it possible to do the same with A20?