04-05-2011 09:47 AM
I'm not sure, but I think my problem was coming from using the VISAClear just before the VISAWrite.... Seems when I took that out ( and used all references to the VISA, and moved the VISA defnition to Outside the While loop) it seems to work. Strangely, when I rean the VI by pressing run just after a cycle completion, the thing operated properly, but when I ran is slow, it did not...
04-05-2011 09:50 AM
Maybe you should post the VI.........
04-05-2011 09:57 AM
Here's the Driver in it's present state... I've just got it in a loop with the VISA control outside of the while loop just passing through to the end and out to the VISAClose... You'll see I have some code in the DisableDiagram structure... that's what I just removed... it was installed just before the Write, right before the CaseStructure.
04-05-2011 10:19 AM
@ Kees:
I am trying to adjust the program now. I figured out that the "Bytes at port" when running my program alone givs always 10, but when I run it with the measurements program here it goes from 10 to zero sometimes!
@ Tobias: The event structure I need here is mainly to change the speed, so whenever I increase or decrease this numerical element this should be sent to the converter.I also want to read speed and Torque continuously, so I put it in the "time out". Actually when I put zero to the timeout of the event structure the waveform of the received data is perfect, and if I put any number higher the program isn't working!!. I also can put a seperate time delay inside the "time out " event or outside it and it worked also good!! I want to know why?!
04-05-2011 12:37 PM
Hi Momosuwan,
Looks like you found the problem. It is aesy to solve. Let us see what you come up with.
The time-out value other than zero is only to prevent that the event structure will decrease the CPU performance.
04-05-2011 12:43 PM
Hi JFerrara,
Also my mistake to answer you in this thread. Next time please open a new thread. Now we two stories in one thread.
Your VI. I assume that you initialize the COM port in an upper VI.
You write date and read data immediately after the write without knowing if and how much there is.
Please read the other answers I gave. Basically the same mistake but yours is worse. You should get the number of bytes available at the COM port before you do a read.
Kees
04-05-2011 02:51 PM
Thanks for the help! I thought my stuff was highly related, so it wouldn't be much trouble... Anyhow, I put in a while loop just after the write, to check for the number of bits. I wire the comparison to an OR that is also looking at the loop count (like a time out)... The thing looks like it's working... we'll see for how long.
04-06-2011 05:48 AM
Hello Kees,
So the good news : I modified the program and connected 100ms time out to the event structure and it's working good, I also modified the read data sub VI's pls check the attachment, is my use of time elapsed correct?
The bad news! when I run the 2 programs together (or integrated in one program) the "bytes by port" fluctuate between zero and 10 (am reading here 10 Characters) and the elapsed time reachs 1 sec (which I defined as error as you said)! what can be the cause and what can I do to solve this problem?
04-06-2011 06:38 AM
Increase the time-out to 10 sec. just to see what happens.
04-11-2011 08:38 AM
Hello again,
I am sorry that I could not work on this project recently. I had a tough week dealing with other tasks in other location !! I hope you still remember the problem. So I cnaged the elapsed time for 10 sec and I noticed that the "Bytes on port" is shuffling quickly between 0 and 10 and the "elapsed time is less that 0,03" but after a few seconds "Bytes at port" become zero and the time reaches 10 sec and gives the erroe .. I tried to change the time delay between write and read but its doing the same! I also tried to flush the buffer after each read operation but but it gives the same result.