Hi there!
Don't worry im glad to help you, and thanks for your comment about my english, you're very kind.
Im glad to hear, that you already had working the interface, good job!
I can imagine a sort of things about why, you only can write and then read data, and not viceversa.
When you use the functions
fwrite or
fprintf , and then
fread or other read function, i think it works fine, because the write function send the data and end the function, and then the read function if
asyncronous, wait for data until a data arrive or until the Timeout has reached or the InputBuffer in matlab is complete.
You can see the properties of your serial object created in matlab using ( once created ) the object
get(nameofobject). And you can see the Timeout and InputBufferSize.
Fo be clearly, the Timeout is the waiting time to complete a read or write operation ( If a time-out occurs, the read or write operation aborts), and the InputBufferSize is the amout of data that you are going to read ( in bytes, A read operation is terminated if the amount of data stored in the input buffer equals the InputBufferSize value or a time-out occur. ), if you are going to read only one byte put 1, if you don't know how many byte you are going to receive, put a large one or make some calculations.
So maybe when
you first do a read operation and no data is coming, or the data arrive after the timeout you will have an error (so you need more time in the read operation, the default timeout are 10 seconds, but you can change it), and tou can't continue with the script.
Well i hope this can help you.
If i was not very clearly plz let me know, to explain it better.
These are my hypothesis, about your problem in the matlab side. In the Pic side, there are too many posibilities, if you can give me more clues maybe we can solve that.
Au Revoir! MankManky
Have a nice day.
I leave you a picture where you can see a serial packages sending to matlab at rising and falling edges.
S5002953 on Flickr - Photo Sharing!
S5002951 on Flickr - Photo Sharing!
S5002926 on Flickr - Photo Sharing!