Python Forum
Raspberry PI writing to RS485 driver, DIR pin not holding state
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Raspberry PI writing to RS485 driver, DIR pin not holding state
#1
Photo 
Hello. I am writing data to my modbus DRIVER and learning about modbus in general. I am using logic analyzer to check my signals.

I have noticed a very strange behaviour of my DIR pin. Before I send data to RS485 driver, I toggle DIR pin HIGH and keep it HIGH until the data transfer is finished.
The code:
# \x02 - trigger scanning
# \x03 after scanning is done
import serial
import RPi.GPIO as GPIO
import time
sendSerial = serial.Serial ("/dev/serial0", 9600)
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(16, GPIO.OUT) # Set pin 10 to be an input pie to be pulled low (off)

GPIO.output(16,1)
sendSerial.write (str.encode("hello"))
GPIO.output(16,0)

print("done")


sendSerial.close()
And the signal analzyer shows:
https://ibb.co/xsJR28b

As you can see from the image above, the DIR pin does not want for the serial write to finish

I have tried to add :
sendSerial.flush() after the writing but it looks even more strange:
https://ibb.co/qy0CDXv

Now its holding DIR pin for way too long.

Can someone help me understand this strange behaviour and how to fix it?
Reply


Messages In This Thread
Raspberry PI writing to RS485 driver, DIR pin not holding state - by zazas321 - Oct-29-2020, 10:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Difference between method and attribute holding a function ulrich 2 1,038 Jun-30-2024, 08:35 AM
Last Post: snippsat
  Python code a Max7219/7221 7 segment driver Aggie64 11 6,660 Dec-01-2022, 02:24 AM
Last Post: Larz60+
  help with code for USB-RS485 korenron 3 5,041 Nov-17-2022, 09:04 AM
Last Post: wiseweezer
  Help reading data from serial RS485 korenron 8 19,730 Nov-14-2021, 06:49 AM
Last Post: korenron
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 3,314 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  Stepper motor/Easy Driver/HELP Harney 1 2,823 Jul-31-2021, 08:05 AM
Last Post: Harney
  Writing device driver to stop electric supply to any I/O port sumandas89 0 2,258 May-02-2019, 10:22 AM
Last Post: sumandas89
  State graph Kaluss 1 2,992 Mar-18-2019, 05:29 PM
Last Post: nilamo
  how to upload a file to my gmail driver after login ?? evilcode1 5 5,448 Nov-06-2018, 07:33 AM
Last Post: evilcode1
  Raspberry + RS485 shield | pySerial Coada 6 9,735 Apr-13-2017, 07:24 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020