Powered by Invision Power Board


Forum Rules Forum Rules (Please read before posting)
  Reply to this topicStart new topicStart Poll

> How To Control Rs485 Tx Enable On Zynq, Fpga
Sherldonnnn
Posted: June 16, 2017 06:56 am
Reply to this postQuote Post


Newbie
*

Group: Members+
Posts: 7
Member No.: 40,209
Joined: July 21, 2016




I am testing infrared temperature sensor. It is connected to SP485(converter rs485 to rs232?) which is connected to ZYNQ,FPGA.

user posted image

I have to input High when I send Tx. After all of messages was sent, I will input Low to this Enable pin.

Simple approach is to do with one bit width GPIO. Make High just before Write(). After Write() is finished, make GPIO LOW. I thought..it will be work. but it wasn't. Code is like as below...(I use libmodbus library to communicate using rs485)

CODE
write(fd,"1",1); // make gpio(enable pin) high.
req_length = modbus_send_raw_request(ctx, raw_req, 6 * sizeof(uint8_t)); //write
write(fd,"0",1);//After write(), make gpio low to receive messages from sensor.
int response_length = modbus_receive_confirmation(ctx, rsp);


This code was not working properly. Write() is not write immediately.. or the prosess is working independently.(so there is possibility that when I input Low, write() is not finished).

I don't know reason actually. it's just my assuming.

So I added usleep();

CODE
write(fd,"1",1); // make gpio(enable pin) high.
req_length = modbus_send_raw_request(ctx, raw_req, 6 * sizeof(uint8_t)); //write
usleep(9050); //waite until write is finished
write(fd,"0",1);//After write(), make gpio low to receive messages from sensor.
int response_length = modbus_receive_confirmation(ctx, rsp);`


This code is working sometimes..... it also not the best answer. the result is here. After 1'22, it's working.

enable Pin is connected to FPGA (ZYNQ)

It is difficult to add other circuit to control enable pin. it is more convenient to make a design on the FPGA.

user posted image

Should I control this by software?(controlling gpio) or Hardware?

Let me know the best way, approach.. Thank you.
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 


:: support us ::




ElectronicsSkin by DutchDork & The-Force