madamic / zynq_tdc

A fast high-resolution time-to-digital converter in the Red Pitaya Zynq-7010 SoC
GNU General Public License v3.0
48 stars 23 forks source link

Board freezes after start reading #3

Open andr01d-1 opened 9 months ago

andr01d-1 commented 9 months ago

Hello,

Thanks for sharing your design! I really appreciate it. Recently, I got the same board and noticed your design. Excited to try it out. I don't have access to MATLAB, so instead of using the GUI app, I am using a socket client to interact with the onboard server.

When I enable TDCindex 0, op 1

The board stuck, socket connection lost. Wonder what would be the potential issue and how to debug it. Thanks!

madamic commented 9 months ago

Hello! I'm happy you're interested in my design! How exactly are you interacting with the Red Pitaya without the MATLAB app? The app is sending commands to the Red Pitaya's C server, which expects a very specific command format. If you haven't replicated that correctly, the board might behave unexpectedly. I suggest you use the MATLAB app! Even if you don't have the full MATLAB installation, you can download MATLAB Runtime, which I believe is free and will enable you to run the app. Let me know if you have any issues with that. Alternatively, you can of course write your own server and your own app, which is probably the best long-term solution for this. I realize MATLAB is not free and it's one of the main drawbacks of this TDC system.

andr01d-1 commented 9 months ago

Thanks for getting back to me! I pretty much use the same server.c file you provided other than adding some debugging printout and ACK back response, if I understand correctly.

https://gist.githubusercontent.com/andr01d-1/cc27c28bf9ce1b03ac497e9c85c2ff7f/raw/c612aaff7b47337dda569705ed93c914313bfc32/TDCserver.c

This is the client file I use to send commands to onboard server

https://gist.githubusercontent.com/andr01d-1/cc27c28bf9ce1b03ac497e9c85c2ff7f/raw/eeb0e1083630756323671774f1f1454c9d9192ce/client.py

madamic commented 9 months ago

What is the Red Pitaya printing out if you SSH into it? The server prints out diagnostic messages, maybe you can use that or add your own messages to figure out where the problem is. I'm not an expert on sockets, I pretty much reused the standard server stuff I found elsewhere. My main focus of this project was on the RTL code / firmware.

andr01d-1 commented 9 months ago

Thanks for the suggestions!

I haven't figured out how to use Matlab Runtime, from the online docs, it seems the original app need to be compiled in with an "Application Compiler" not part of the runtime. I will keep looking, but for now I will stay with python client for testing.

(Socket) connection is okay.

The onboard server receives and parse TDCindex and op properly.

From PC client, two sets of commands are sent to the board.

First enabled the channel 0 TDC by sending op : 1 TDCindex: 0,

Then I tried to perform "Speed Test" by sending op: 7, TDCindex: 0

*** TDC Server Online ***
Listening on port 1001 ...
Connection accepted!
Rx: 2 ..... 
command: 100: 
TDC index: 0, op: 1: 
TDC[TDCindex].enabled? : 0
TDC[TDCindex].conf? : 0
Trying to enable now:   TDC[TDCindex].enabled: 1
Rx: 2 ..... 
command: 100: 
TDC index: 0, op: 1: 
TDC[TDCindex].enabled? : 1
TDC[TDCindex].conf? : 0
Trying to enable now:   TDC[TDCindex].enabled: 1
Rx: 2 ..... 
command: 700: 
TDC index: 0, op: 7: 
TDC[TDCindex].enabled? : 1
TDC[TDCindex].conf? : 0

Then the board froze; connection was lost.

I am thinking of adding a logic analyzer and re-synthesize the design so that I could have a way to look into what's happening on the gateware side.

koast18 commented 3 months ago

Hi, I happened found the repo which matches my current project, It helped me a lot, Thanks for @madamic sharing this! I saw the issue and I hope this comment does not bother you.

I found the server does not always send a ack after recv and deal with an op in the modified server in the switch case 0, 3, 4, 6 and 7. This will make the python socket client to wait for the reply all the time. And I think add this send(sock_client, &emptyWord, 8, MSG_NOSIGNAL); to each tail of the cases may solve this but I didn't test that.