Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How to connect voltage monitoring meter with RS485 out, to a computer with Modbus RTU? Should I use a converter to RS232 and connect to serial COM port of computer? Should I use RS485 to USB converter to connect? Can I connect directly to serial COM port from A,B and Ground of RS485 using D9 connector pin? Then A,B and Ground to which pins of D9 in Modbus RTU?
ND20 pinout
RS485 Details
Yes, you should use a RS485 to USB converter to connect the ND20 with your computer.
At minimum you need to connect the A (sometimes called "-") and the B (or "+") line of your ND20 to the same lines of your RS485/USB adapter. Check your RS485/USB adapter manual for the pinout. Remember, the "A" line can alternatively be called "-", and "B" might be called "+". See here for more RS485 application info.
Connecting GND is recommended, though in most situations it should work without.
You need to know the baud rate / bits per second (9600? 19200?) the ND20 uses. You need to set this in the PC application.
After having everything connected and ready to operate, you need use a PC application that accesses the RS485 converter ("COM" device on Window, e.g. "COM6"). The PC application needs to request measurement values and receive the results according to MODBUS RTU protocol specification. Our free Docklight evaluation can help with MODBUS, but the most convenient solution is a small MODBUS master tool like this new freeware called QModMaster.
option 1: PC --> USB to RS232 --> RS232 to RS485 --> RS485 device
option 2: PC --> USB to RS485 --> RS485 device
option 3: PC --> RS232 to RS485 --> RS485 device
you need usb to rs485 / rs232 to rs485 convertors
As rs485 is floating, you may need ground to be connected for reliable comms
You can connect using USB-RS485 converter. Don't know about other methods but It worked for me.
For details how to communicate from start to end have a look at this video:
https://www.youtube.com/watch?v=X3RW-0e_PSI
This program worked windows & raspbian only difference was port name in both...
#THIS IS MY PYTHON PROGRAM
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client = ModbusClient(method='rtu', port='COM4', baudrate=2400, timeout=1)
client.connect()
read=client.read_holding_registers(address = 222 ,count =10,unit=1)
//Address is register address e.g 30222,
//and count is number of registers to read,
//so it will read values of register 30222 to 30232
//unit is slave address, for 1 device leave it 1
data=read.registers[int(2)] #reading register 30223
print(data) #printing value read in above line
Related
I want to send data through USB between STM32 and Raspberry Pi. I don't want to use USB to Serial convertor, but instead have a actual USB Connection (maybe CDC class). I have to send data at high rate (Full speed). Please guide on how to achieve this?
A USB-serial connector is simply a microcontroller implementing a USB CDC/ACM virtual COM port and bridging to a UART which you would connect to a microcontroller's UART interface.
In your case you can simply implement the CDC/ACM directly on the STM32 using either of its USB device controller peripherals (USB support varies depending on the specific device https://www.st.com/resource/en/application_note/dm00296349-usb-hardware-and-pcb-guidelines-using-stm32-mcus-stmicroelectronics.pdf).
How you actually implement that will depend on what specific part, and what library or framework ecosystem you are using (e.g. SPL, CubeMX, Mbed). There are reference implementations, examples, drivers and libraries for all of these.
Your milage may vary, but I have measured ST's own USB library and example CDC/ACM virtual COM for STM32F1xx on a 72MHz MCU achieving 700kbits/s. Note that the performance is independent of the baud rate you might set on the host when you open the he VCP. Setting the baud rate simply sends a control packet to the device that can be used to set the baud rate of a UART in bridging applications. In your case such control packets can be ignored. There are similar packets for modem control signals such as DTR, RTS, CTS and RI, which you might choose to us for flow control or other signalling.
I've been tasked with figuring out how to get a mobile app to communicate with an MCU then in turn control a stepper motor. Right now I'm trying to get the WiFi module (ESP8266-01) and MCU (NUCLEO-F030R8) to play nice with each other. The catch is I have little to no experience and no education in this field. The closest experience I have is simple Arduino sketches from years ago (IE photo-resistor values driving a stepper motor) and making desktop applications with C#. I am using STM32CubeIDE but if there's a better option I can switch to that.
What I would very much like help on is send and receive simple data between a smartphone and the MCU via the WiFi module. I've read through documentation and other questions but still don't exactly know where to start.
I understand this is probably a large topic in its own right and a short blurb on the internet won't do it (and undoubtedly its multiple subcategories) justice. But I might as well ask.
Sorry if this is too much and thank you in advance.
This project would involve making the following connections.
The UART connection between STM32 and ESP8266.
The WiFi connection between ESP8266 and the mobile.
The application layer protocol between ESP8266 and the application running on the mobile.
For 1, you can actually program the ESP8266 using Arduino IDE and simply connect the UART TX/RX pins of ESP8266 with RX/TX pins of STM32 respectively. You can create a test project in which ESP8266 sends data to STM32 over UART to verify this connection.
For 2, you need to consider the wifi network mode i.e identify whether the wifi connection is going to be ad-hoc (mobile connects to ESP8266 directly) or in infrastructure mode (mobile and ESP8266 connected via a shared access point). You can configure the ESP8266 in both modes. You just have to program the SSID and password of the Wifi network in the ESP8266 (in case of ad-hoc, it is the SSID of the network advertised by ESP8266 and in the infrastructure mode, it is the SSID of the common AP). This wifi functionality is also easily programmable in Arduino IDE for ESP8266.
Finally, once the physical connection has been established between the ESP8266 and mobile device, you need an application-level protocol to connect the application running on the mobile with the ESP8266. You can either use socket connection between ESP8266 and mobile application or use a higher-level communication protocol for IoT devices like MQTT, which is also available in the Arduino IDE.
Final connection diagram could be something like this:
application -> mqtt msgs -> wifi packets -> esp8266 recv pkts -> parse mqtt msgs -> forward data to STM32 over UART
we are doing a project for receiving data from a device using a RS232 to ethernet converter (gridconnect net 232+) onto to a Atmel board. When we connect the converter to the PC, we are getting the output but not when connected to the microcontroller board. We need to know if there has to be some network confirguration to be done on the converter in order to receive it on the microcontroller.
Thanks !
I haven't worked with that board or device, but with any RS-232 communication channel you should check that all RS-232 parameters are set up correctly on both sides. Databits, stopbits, parity settings, etc. Even one setting being off will completely stop RS-232 communications.
Once that is done, I'd hook up a terminal emulator of your choice to simulate the microcontroller side and make sure that you're getting the right traffic from the Ethernet side. You might get lucky at that point and everything might start working. ;)
I've been trying to figure out how to turn my Raspberry Pi into a USB to Bluetooth serial adapter. I want to be able to send data over Bluetooth to the Pi which has a USB thermal printer registered at /dev/usb/lp0.
Using only standard command line apps such as hciconfig, hcitool, rfcomm, and sdptool I have been able to see the Pi as visible, and pair to it from an Android tablet using a Bluetooth SPP app on the Store. However, the tablet disconnects immediately, and no data is sent. rfcomm listen /dev/rfcomm0 1 also waits for a connection forever.
I think I'm able to achieve what I need without custom code, using solely standard command line apps, but I'm not entirely sure. socat will likely be of use to finally connect the sockets.
Figures that I'd get it right after posting. To anyone else looking to do something similar:
Pair with bluez-simple-agent
Create your serial port channel with sdptool add --channel=x sp
Listen for a connection on that channel with sudo rfcomm listen /dev/rfcomm0 x
Cross the streams with socat /dev/rfcomm0 /dev/usb/lp0
Beautiful. It's all so simple now.
I have a development board of stm32f103VE and i want to use enc28j60 to send data to PC .
I have a sample code from st.com .I used it but there wasn't any response and when i joint the cable from my board to PC ,the orange and green LED weren't on. I am not very familiar with this protocol to transmit data.
Can anybody help me to dissolve this problem?
Should i configure something in my PC?
Two ethernet devices would communicate if they are in the same subnet. so the subnet mask of the pc and what you set in your microcontroller must be same.
If you are directly connecting to PC (without any switch), use a cross ethernet cable