I made it this way -
speed control of PSC 1f engine with Raspberry Pi 3
6 elements
DC side:
(1) Raspberry 3, 3V3 GPIO
(2) transistor 2N222, with resistor 220 Ohm at the gate
(3) Solid State Relay SSR 40 - DA
AC side:
(4) PSC motor, 1phase, 0,35 A, 1,5 mF
(5) double choke coil inductor 2x 10mH
(6) Inlet with Line Filter 250VAC 10A Chassis FBNAB2470ZG110
application
(1)
Raspberry give 3V3 signal to transistor at the gate (connection through resistor)
That opens way to 5V signal from Raspberry to SRR back to Raspberry ground pin.
(2)
Reason to use Transistor is that 3V3 signal won't give enough current to the SSR.
SSR is trigger by current at 7.5 mA @ 12V. (http://www.fotek.com.hk/solid/SSR-1.htm)
(3)
When SSR got 5V current, it let 230 V current to the engine.
(4)
Now: when we let power jump up and down, engine starts getting big impusles which in principle is harmfull - both to your engine and power system.
(5)
To avoid it, you connect in line a choke coil - to flattern the voltage - bigger : better. Hand made coils should do as well. Stator from other engine works great (photo).
(6)
Line filter helps the simmilar way. You can buy one, or with simple capacitor [schematics] make connection between L and N.
Be careful and have fun!
Code#1 python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import RPi.GPIO as GPIO
try:
while True:
# Use BCM GPIO references
# instead of physical pin numbers
GPIO.setmode(GPIO.BCM)
# Define GPIO to use on Pi
GPIO_RELAY_1 = 12
# Set pins as output and input
GPIO.setup(GPIO_RELAY_1,GPIO.OUT) # RELAY_1
# Set trigger to False (Low)
GPIO.output(GPIO_RELAY_1, False)
# Allow module to settle
time.sleep(0.1)
# Send 10us pulse to trigger
GPIO.output(GPIO_RELAY_1, True)
print "RELAY_1 ON"
time.sleep(0.5)
GPIO.output(GPIO_RELAY_1, False)
print "RELAY_1 OFF"
time.sleep(0.2)
# Reset GPIO settings
GPIO.cleanup()
except KeyboardInterrupt:
pass
GPIO.output(GPIO_RELAY_1, False)
print "Finito : Off"
GPIO.cleanup()
Code#2 python2.7
https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(12, GPIO.OUT)
frequency = 500
dc_low = 40
dc_mid = 75
dc_high = 100
p = GPIO.PWM(12, frequency) # GPIO.PWM(channel, frequency (in Hz)
p.start(0)
try:
while 1:
print "frequency = ", frequency
#dc_low
p.ChangeDutyCycle(dc_low)
print "dc_low =", dc_low
time.sleep(120)
#dc_mid
p.ChangeDutyCycle(dc_mid)
print "dc_mid =", dc_mid
time.sleep(120)
p.ChangeDutyCycle(dc_mid)
print "dc_high =", dc_high
time.sleep(120)
"""
for dc in range(0, 101, 5):
p.ChangeDutyCycle(dc)
time.sleep(0.1)
print "dc in range(0, 101, 5) =", dc
print "freqnecy = ", frequency
for dc in range(100, -1, -5):
p.ChangeDutyCycle(dc)
print "dc in range(100, -1, -5) = ", dc
print "freqnecy = ", frequency
time.sleep(0.1)
"""
except KeyboardInterrupt:
pass
p.stop()
GPIO.cleanup()