On 5/2/16 8:24 AM, Nick Sayer via time-nuts wrote:
To flesh this out a bit more, on a Raspberry Pi, it would be easy to make a 
cron job that would pulse a GPIO pin high. They really *want* you to use Python 
(thus the name), but this is easy to do in just a shell script. First, do this 
to set things up:

#! /bin/sh

GPIO_PIN=9 # pick whatever one you like

echo $GPIO_PIN > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${GPIO_PIN}/direction
echo 0 > /sys/class/gpio/gpio${GPIO_PIN}/value

Next, run this script out of cron:

#! /bin/sh

GPIO_PIN=9
echo 1 > /sys/class/gpio/gpio${GPIO_PIN}/value
sleep 1
echo 0 > /sys/class/gpio/gpio${GPIO_PIN}/value

That will make a positive going pulse with the leading edge synchronized to 
cron (for sufficiently vague definitions of “synchronized”).

As for the hardware side, take the GPIO pin and connect a 10k resistor between 
it and the base of a 2N4401 transistor. Connect the emitter to ground and the 
collector is a classic “open collector” switching output. Think of it like a 
switch connection to ground. When it’s on, there is a low impedance path to 
ground. When it’s off, it’s high impedance. You can use it to work a relay (be 
sure to add a flyback diode across the relay coil) or directly to switch any 
load that doesn’t exceed the abilities of the transistor.

If you want to be a little safer, you can use an opto-isolator instead. Connect 
the GPIO pin to a 150 Ω resistor and then to the anode of the LED in an 
optoisolator. Connect the cathode to ground. The optoisolator itself can be 
either a phototransistor type or a driver triac type (the latter would be used 
to drive a power triac to switch AC loads on and off).



Or just buy a DC controlled solid state relay.. The NPN open collector current booster might be nice still, but the SSR takes care of all the galvanic isolation, etc.


The real question is whether "cron" is timely enough. No matter, just write a script (or python) that reads time in a loop (and you can put a sleep in there) and pulses the GPIO when needed.





_______________________________________________
time-nuts mailing list -- [email protected]
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.

Reply via email to