09-24-2008 11:44 AM
I want to clear the input buffer for all my tasks at the start of an acquisition. I can stop and then start the analog input voltage task to achive this. However I don't think I can stop and then start the position task again because I will the lose the position of the encoder at that time.
At the end of the acquisition, I clear out the buffer because I've had problems with different acquisitions pulling different amounts of data out of the buffer for the same task, so I clear it out to make sure all data is read. However, now the analog buffers are clear and returning zeros but the encoder is returning a value.
09-25-2008 12:44 PM
Hi Linkster,
I was wondering if you could clarify your question. After reading your post, I understand that you have a buffered analog input task and and buffered counter input task. You mentioned that you are clearing the analog buffer by restarting the task and that works well. However, you do not want to restart the counter task and because of this, you are still reading values from the counter. Please expand on this if you still need assistance.
Regards,
Kent
Applications Engineer
09-25-2008 01:19 PM
09-26-2008 11:04 AM
Hi Linkster,
I apologize if I am missing something that you said. I understand that your counter is currently reading the position and this is what you need it to do. If you do reset it, you will lose the current position. From what you have mentioned, it seems like everything is working well and as expected.
Regards,
Kent
Applications Engineer
09-26-2008 12:14 PM - edited 09-26-2008 12:15 PM
Linkster,
Use a shift register to keep track of the encoder counts. When the counter task restarts, add the previous value to the new value. Some thought will need to be put into this to make sure that the addition only occurs after the task restarts and not each time the counter is read. Thus, the value in the shift register will be the position and the counter output will be a change in the position.
If the counter can be preset, preset it from the last value in the shift register rather than maintaining a separate count in software.
Both of these techniques assume the program does not get stopped. If that happens you would need to write to a file.
Lynn