Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Connecting 7 in 1 Soil Sensor with GW1NSR-4C using UART

Jainesh

Newbie
Newbie level 1
Joined
Jul 20, 2024
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
40
I am trying to make a UART connection between the GW1NSR-4C Chip(LilyGO T-FPGA board) and the 7 in 1 Soil Sensor. The Soil Sensor follows the RTU Modbus Protocol, requires CRC error check, and by default, the baud rate is 9600.

I have to use the Gowin EDA software to program the GW1NSR-4C chip(C6/I5 Speed Grade)

The GW1NSR-4C chip on the LilyGO T-FPGA board is connected to a 27 MHz crystal oscillator which I am using to generate the baud rate. I have defined the UART.v file as the top module and I also have a Transmitter and a Receiver module with a CRC_16 module.

I need help with the code, as currently, I am trying to build the code to send the request frame to the sensor for all 7 parameters then receive back the response frame and further calculate the parameter values.

Currently, I am trying to just work on the transmitter part of the code and check the request frame output by connecting Arduino via UART and printing on the serial monitor. But the problem is in the current code, whatever data I am sending is sent twice, and after implementation of the CRC in the code, all the data sent is 0(sent twice). I don't know what to do and am I in urgent need to complete this project.

Can somebody help?

Please let me know if any more details are needed to be shared.



I have attached all the necessary code files.

Arduino Receiver code -


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
setup() {
Serial.begin(9600);
Serial.println("Uart Transmission");
}
 
void loop() {
while (Serial.available())
{
  uint8_t  received = Serial.read();
  // Serial.println("Received: ");
  Serial.println(received,HEX);
}
}



1721471804865.png


Current Output on Arduino Serial Monitor.
 

Attachments

  • 7 in Soil Sensor Datasheet.pdf
    352.1 KB · Views: 214
  • GW1NSR Chips Datasheet.pdf
    1.8 MB · Views: 142
  • T-FPGA-V1.0 CORE.pdf
    853.6 KB · Views: 124
  • BaudRateGenerator2.txt
    506 bytes · Views: 101
  • CRC_16.txt
    2.6 KB · Views: 86
  • UART.txt
    4.7 KB · Views: 101
  • Uart8Receiver.txt
    2.9 KB · Views: 98
  • Uart8Transmitter.txt
    2.5 KB · Views: 108
Last edited by a moderator:
Take a step back...

Are you sure the UART module inside the FPGA is working as it should?
Did you write a testbench to verify it using simulation?
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top