Motor Controller from Raspberry Pi
It took a little fiddling around, but I got the motor and raspberry pi powered from an ATX PSU and the pi's pins connected via an IDE cable to the L9110S module I got from ebay.
Then, I used gpiozero's PWMOutputDevice to create a forward device on one pin and a backward device on the other. I didn't even have to faff about with the frequencies - just set the value on the object and away it went!
So now, my plan is to build the base frame for my CNC router and attach this motor to a threaded rod and rotary encoder. Fingers crossed that tiny motor has enough torque to move the cutting tray. :S
Hi, this is from Japan.
ReplyDeleteCould you put the source code of it?
Thanks for the comment! I've got to get the source off my pi, but I'm planning to go back to this project at the weekend - I'll let you know!
DeleteIt took me a while to find the pi, but I finally have the code! I've tested it on the latest raspberry pi os image: https://www.raspberrypi.org/downloads/
Delete#!/usr/bin/python3
from gpiozero import PWMOutputDevice
from time import sleep
motorAForward = PWMOutputDevice(17)
motorABackward = PWMOutputDevice(18)
try:
while True:
motorAForward.value=1
sleep(1)
motorAForward.value=0
sleep(1)
motorAForward.value=0.25
sleep(1)
motorAForward.value=0
sleep(1)
motorABackward.value=1
sleep(1)
motorABackward.value=0
sleep(1)
except:
pass
motorAForward.close()
motorABackward.close()