Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7253

Automation, sensing and robotics • Trying to Control JF-0530B 12V Solenoid with RPI3B and 12V Modbus Relay Module over RS485

$
0
0
I am trying to control a series or Linear Solenoids using two daisy-chained Modbus Relay Modules and a USB RS845 Adaptor.

The Linear Modules aren't firing and I need a fresh set of eye son the set up.

I don't have an oscilloscope but I see Voltage changes coming through the AB of the USB Adaptor so the signals are being sent to the Relay Board.

I've checked each of the Relay Outputs, between NO and COM as well as NC and COM but there's no voltage.

The Channel LEDs on the Modules do not light up but the RED Pwr LED flickers when I clear the ports down.

I'd appreciate any advice on how to debug ro if I've wired something up incorrectly?

See Attachment for Wiring diagram

Thanks
Kevin

Code:

import minimalmodbusimport time# Create instrument for each RS485 relay modulerelay1 = minimalmodbus.Instrument('/dev/ttyUSB0', 1)  # Port and slave addressrelay2 = minimalmodbus.Instrument('/dev/ttyUSB0', 2)  # Same port, different slave ID# Configure settingsfor relay in [relay1, relay2]:    relay.serial.baudrate = 9600    relay.serial.bytesize = 8    relay.serial.parity   = minimalmodbus.serial.PARITY_NONE    relay.serial.stopbits = 1    relay.serial.timeout  = 0.5    relay.mode = minimalmodbus.MODE_RTU# Relay channels are usually coil addresses 0–15def activate_relay(module, channel):    print(f"Activating Relay {channel + 1} on Module {module}")    if module == 1:        relay1.write_bit(channel, 1, 5)    elif module == 2:        relay2.write_bit(channel, 1, 5)def deactivate_relay(module, channel):    print(f"Deactivating Relay {channel + 1} on Module {module}")    if module == 1:        relay1.write_bit(channel, 0, 5)    elif module == 2:        relay2.write_bit(channel, 0, 5)# Example: Extend actuator on channel 3 (relay 4 on module 1)activate_relay(module=1, channel=3)time.sleep(2)deactivate_relay(module=1, channel=3)
RS485 Relay_r1_c1.jpg

Statistics: Posted by KevinSRussell — Wed Jun 25, 2025 7:18 pm — Replies 1 — Views 131



Viewing all articles
Browse latest Browse all 7253

Trending Articles