Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Controlling USB on Raspberry Pi

by afoken (Canon)
on Dec 05, 2020 at 11:55 UTC ( #11124700=note: print w/replies, xml ) Need Help??


in reply to Controlling USB on Raspberry Pi

I am considering building a controller using a Raspberry Pi Zero and a relay module.

So you need to configure two GPIO pins as outputs and set the logic level to high or low. And you don't have any strict timing requirements. It simply does not matter if it takes 0.1 ms, 1 ms, 10 ms or 100 ms to switch the relais. So, you can use the sysfs interface of the Raspi. All you need to do is to write some virtual files, which is trivial in Perl and bash.

Controlling relais isn't that hard either, Amazon has a lot of simple relais modules that accept a 3.3 V logic level input and can switch 110 V or 230 V. Just make sure the relais can switch the current (A) and voltage (V) required by the electric curtains.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Controlling USB on Raspberry Pi
by Bod (Curate) on Dec 05, 2020 at 12:29 UTC

    It simply does not matter if it takes 0.1 ms, 1 ms, 10 ms or 100 ms to switch the relais

    Too right...the script to open/close the curtains will probably run from CRON every 10 minutes or so with an updater script running from CRON a couple of times a day. So timing is not critical.

    Just make sure the relais can switch the current (A) and voltage (V) required by the electric curtains

    The curtain motor is 12V 1A so no worries there. It probably doesn't actually need a relay as a thyristor should do it but relays are simpler as I won't have much access to the motor setup whilst building the controller.

      It probably doesn't actually need a relay as a thyristor should do it

      Thyristors have a very different switching behaviour compared to a relais. Once triggered by a gate pulse, they stay on until the load current drops (close) to zero. On a DC supply, a thyristor stays on until power is switched off or the motor burns out. However, with pulsing DC current (i.e. AC after a rectifier, but no capacitor), the thyristor will switch off at the end of a half wave. This allows tricks like a crude PWM regulator by triggering the thyristor somewhat after the begin of a half wave (Proxxon uses this trick for their "DC" minimot tools).

      For driving AC motors, a thyristor won't help you much, as it either isolates or behaves like a diode, so the AC motor gets either no current or pulsed DC.

      For full control of a DC motor on a DC supply, you typically use an H-bridge setup with bipolar or MOSFET transistors. This allows PWM for speed control, turning left and right, braking (not with every controller) and coasting. There are severel very clever H-bridge driver ICs available that add a lot of protection for both motor (e.g. stall and overcurrent detection) and driver transistors (overcurrent, short circuit detection). Some H-bridge driver ICs even include the transistors. And yes, there are cheap, ready-to-use modules with H-bridges.

      H-Bridge drivers either accept a direction and a speed signal (on/off or PWM), or a left-turn and a right-turn signal (again either on/off or PWM). If breaking is supported, the direction-and-speed signals need a third signal to switch between breaking and coasting, the left/right approach can use the illegal state (left and right on at the same time) for breaking, or also use a third signal line. After all, driving a solid-state H-bridge is not too different from driving two relays. Two "slow" bits are sufficient for switching left/off/right, you may need to add a third bit for breaking. With a direction-and-speed driver, change one "slow" bit to PWM output to allow speed control.

      L298-based modules seem to be very popular (two motor up to 46 V, each 3 A abs max peak, each 2 A operating, logic supply 4.5 V to 7 V, logic levels should be just about compatible with 3.3 V signals, motor drivers can be paralleled for double output current), just add a heatsink, four diodes per motor and some passives to the chip and you have a driver module. Only downside is that the L298 is everything but smart, no protection except for shorting out the motor supply.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124700]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-05-25 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?