SX1509 and PENGLIN PWM

Hello Team,

I have an SX1509 IO Expander Board connected with a raspberry PI. I want to control a PWM connected to the IO Expander but have no idea how it works :shock:

This is the connected module (pin 8)

“DC 5V-36V 15A (Max 30A) 400W Dual High-Power MOSFET Trigger Switch Drive Module 0-20KHz PWM Setting Electronic Switch Control Board Motor Speed Control”

Could you help me with a python sample code?

I want to control the speed of aa mixer motor connected to the PWM.

Many thanks in advance.

https://forum.micropython.org/viewtopic.php?t=9178

I hope this will help you a bit.

Hi,

Thank you so much, but it does not help with what I am looking for.

Let me describe my need a bit better …

I have a mixer, and I connected the motor to a PENGLING PWM and the PWM MOSFET with the J1 pint to PIN 8 on the Raspberry.

What I would like to achieve is that control the speed of the mixer via the Raspberry.

I made a sample function below - would it work that way?

import busio
import board
from adafruit_bus_device.i2c_device import I2CDevice
import time
import SX1509
import IO_Types


Frequency = 20000


DEVICE_ADDRESS = 0x3E  # device address of SX1509

#Set up I2C
comm_port = busio.I2C(board.SCL, board.SDA)
device = I2CDevice(comm_port, DEVICE_ADDRESS)

#Initialize the expander
IOExpander = SX1509.SX1509(comm_port)
IOExpander.clock(oscDivider = 4)
IOExpander.debounceTime(32)

IOExpander.pinMode(8, IO_Types.PIN_TYPE_ANALOG_OUTPUT)


Def Mixing(MixTime_ms, Speed_%)
	DutyCycle = Frequency / 400000
	HighTime = DutyCycle * Speed_%
	LowTime = DutyCycle - HighTime
	
	While MixTime_ms < PassedTime:
		IOExpander.analogWrite(8, 1)
		Time.Sleep(HighTime)
		IOExpander.analogWrite(8, 0)
		Time.sleep(LowTime)
		PassedTime = PassedTime + HighTime + LowTime

have a mixer, and I connected the motor to a PENGLING PWM

No idea what this is. Links? Photos showing how it’s hooked up? What is it doing? What are you expecting it to do that it isn’t?

Hi,

Thanks for your reply. Here is a picture of how it is connected.

[

I am trying to run the mixer motor at different speeds while sending a PWM signal from the SX1509 Pin 8 to the PENGLIN PWM.

There is a PWM function on the raspberry where you define the frequency. I could not find the same for the SX1509 in the documentation.

I was wondering if I could generate the signal myself in a loop while turning it off and on. I just shared my idea here for the code but wasn’t sure if this is the right approach.

# Duty Cycle Is 20 kHz and should be 0.05 ms
# I want to give 50 % of the voltage to the motor so HighTIme = LowTime = 0.025

IOExpander.analogWrite(8, 1)
Time.Sleep(HighTime)
IOExpander.analogWrite(8, 0)
Time.sleep(LowTime)

I hope this describes it a bit better.](PNGLIN-PW-SX1509 hosted at ImgBB — ImgBB)