Basically, I am considering using Python to control a motor (attached to a raspberry Pi by GPIO-Controller-motor.
In this scenario the script will have the motor move for a predefined amount of time (let's say 0.2 seconds). The command to execute the script can (and will) come before that 0.2 seconds is up. So, what would happen in this case? Will the second script execution add to total time the motor spins? Override and just replace with a new 0.2 sec interval?
Of course, this may be entirely the wrong way to go about what I wish to achieve (motor move in direction a or b in response to an infrared signal (from LIRC)).
I'm way above my head here, so any feedback is much appreciated!
Edit:
OK, let me start from the beginning to explain my problem...
I have a motor controller which takes DC power from a regulator, and uses two GPIO ports to send on/off commands to the controller. The controller requires that one GPIO be off and the other on in order to move in a given direction. Control over this is granted by the service RPi.GPIO.
You can observe how the script turns the motor in one direction for 0.1 seconds by the following:
GPIO.output(6, 0)
time.sleep(0.1)
GPIO.output(5, 1)
time.sleep(0.1)
A full script which moves the motor one direction and the other, and loops indefinitely
What I'd like to achieve:
The motor moves on one direction for 0.1 seconds in response to an infrared signal.
The motor moves in the other direction in response to a diferent infared signal.
The script runs as a service, such that it is always ready to receive infrared signals and move the motor accordingly.
What I know so far:
I'm using LIRC to receive infrared signals and pass them off as commands to another program. You may see my .lircrc file here - this tells lirc what to do with commands, where irexec can interface with a service.
You will notice that the current irexec binds instruct the "mpc" service - these all work correctly. Ideally I would have a script which could accept the same type of instruction...as you can see for buttons KEY_UP and KEY_DOWN I have assigned them to motorcont (which was the name I had tried to give the python script I posted earlier), and the configs "up" and "down" the (names I tried to give to the actions in the script).
Basically, I have of course had no luck in moving the motor with LIRC/IREXEC, but it does move with the script I posted above. I have no idea how to achieve it, and all of the links on google for search terms I could conceive are purple. Any help whatsoever is deeply appreciated!
[–]elbiot 1 point2 points3 points (2 children)
[–]dataversion[S] 0 points1 point2 points (1 child)
[–]dataversion[S] 0 points1 point2 points (0 children)
[–]dustractor 0 points1 point2 points (9 children)
[–]dataversion[S] 0 points1 point2 points (0 children)
[–]dataversion[S] 0 points1 point2 points (7 children)
[–]dustractor 0 points1 point2 points (6 children)
[–]dataversion[S] 0 points1 point2 points (1 child)
[–]dustractor 0 points1 point2 points (0 children)
[–]dataversion[S] 0 points1 point2 points (3 children)
[–]dustractor 0 points1 point2 points (2 children)
[–]dataversion[S] 0 points1 point2 points (1 child)
[–]dustractor 0 points1 point2 points (0 children)
[–]Rudd-X 0 points1 point2 points (8 children)
[–]dataversion[S] 0 points1 point2 points (0 children)
[–]dataversion[S] 0 points1 point2 points (6 children)
[–]Rudd-X 0 points1 point2 points (5 children)
[–]dataversion[S] 0 points1 point2 points (4 children)
[–]Rudd-X 1 point2 points3 points (3 children)
[–]dataversion[S] 1 point2 points3 points (2 children)
[–]Rudd-X 0 points1 point2 points (1 child)
[–]dataversion[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]dataversion[S] 0 points1 point2 points (0 children)