06-23-2008 05:53 PM
06-23-2008 06:26 PM
06-23-2008 06:38 PM - edited 06-23-2008 06:38 PM
I've modified your code and provide explanation with reference to the attached image.
Let's look at a few scenarios:
1. A1 is first, B1 then B2 followed by A2 repeat.
Sends OFF, 10 ms later Sends ON, 0ms sends OFF 10ms later sends ON... And then it might be 5ms ON then OFF 5ms then ON.. and random after that.
2. B1 first, A1 next, followed by A2 followed by B2, repeat.
Waits 5 ms, then OFF command, 0 ms turn ON waits 10 ms then OFF, etc.
For the other scenarios, just use random possibilities.. which is what was going on..
RayR
06-23-2008 06:50 PM
06-23-2008 07:06 PM
I suspected that would happen.. 😞
It is because there is an element that we omitted from the equation, which is the reponse time from the instrument.
So you need to implement the code in such a way that the time between the ON & OFF times need to be relative to a constant timestamp.
I'll modify the example to illustrate.
RayR
06-23-2008 07:14 PM - edited 06-23-2008 07:16 PM
06-24-2008 02:16 PM
06-24-2008 04:43 PM
I would be curious if you get error messages.
I changed it to a state machine which will automatically stop if there is an error detected.
I also show the current state. For both examples (this one and the last one) I suggest changing the delay to something big like 500 ms so that you can see the transitions. Which is why I changed the constant form 5 to 500 and made it a control.
I suspect that it 5 ms is way to small a value, so we need to find out when it becomes unstable.
Try it out and post feedback
RayR
06-24-2008 05:20 PM
06-24-2008 06:41 PM
I may have forgotten to mention that the Windows clock (PC) is not very accurate, especially when dealing with milliseconds.
I looked at your code and doubt that having a For Loop running 10000 iterations doing nothing will help.
Did you try the last example I posted? Did it give any error message(s)? What wait time did you try? Did you try a range of values? Did you start with 500ms?
I was thinking of putting an indicator which would show the time deltas between the ON & OFF periods. This way, you could monitor where the instability resides.
RayR