We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi I want to draw graphs of position of 2-phased QEI versus time. so I want to capture QEI position every time period. time gap between to position pulses is at least 7.2 microseconds. I think I have to choose one of these methods:
1-send position to USB during time overflow interrupt(TIM_INT)
2-send content of the timer when the situation changes. (I don't know if it is possible to sense the changes as an interrupt?)
I think there are some restrictions due to interrupt latancy. so what is the highest resolution for my system. and which method is better? How can I define interrupt for 2nd method? can i send data to buffer and send batch buffer to USB? Is it help me Reduce interrupt latancy effects? HOW? Please Help me Best Regards
"so what is the highest resolution for my system."
Aren't you a funny guy? You haven't even told us what processor you use. So we don't know if the processor have quadrature encoder support in hardware or if you will be using some capture functionality.
Oh sorry! I forgot to say that i'm using LPC1768! and use USBhostlite to send data to USB
and USBhostlite code is available here:
ics.nxp.com/.../
and I removed Uart from codes so that it just copies data to usb.
time gap between to position pulses is at least 7.2 microseconds.
very unlikely. When the encoder stop exactly over a border in the optical disc a minuscule vibration (which is there in any mechanical desogn) will cause a higher frequency of pulses. I have seen pulses in the Mhz range from 10ms encoders. Just another bit: the old nugget a = clock, b= direction does NOT old true
Erik
the Leaflet (for Thorlabs Z825) says:
Motor-mounted rotary encoder. 512 counts/rev of the motor. 34,304 counts/rev of leadscrew
the velocity is 4rev/sec(240rpm) that yields 137216 counts per second and 7.2us gap between two counts. (writing pulse instead of count is due to regional dialects ;-) )
Sorry for my weak English. thanks
the Leaflet (for Thorlabs Z825) says: ....
that does not change that When the encoder stop exactly over a border in the optical disc a minuscule vibration ........
I want to run the motor for 2 seconds and record the data during first 1.9 secs. does it affected by this vibration? I just want to plot the diagram in PC. I can ignore first and last pulses in my observations (due to my application). so does such high frequency pulses occurs during other middle counts? the moutor is mounted on an active vibration isolated table. does vibration from motor also causes high freqency pulses??
thanks
I want to run the motor for 2 seconds and record the data during first 1.9 secs. does it affected by this vibration? not likely, the main 'vibration pulsing' happen at stop and start
I can ignore first and last pulses in my observations then all you get is constant speed, why 'plot' that
thanks no its not constant. there is a transient state between on & off. I want to plot step response! do you have any idea about my first question at the top the page?
Best regards
> I want to draw graphs of position of 2-phased QEI versus time.
As of QEI unit of LPC17xx, an ENCLK_Int interrupt occurs at the every transition of the encoder. In this ISR, your firmware reads out a timer value, which runs freely, to know the interval of the every transition. Cortex-M3 NVIC has fixed interrupt latency of 12 cycle. You may get exact interval with this method.
Erik,
> When the encoder stop exactly over a border in the optical disc a minuscule vibration (which is there in any mechanical desogn) will cause a higher frequency of pulses.
Such a noise is filtered by, 1) R/C (or L/C) filter at the input pins of the QEI unit. And 2) The integrated digital filter of the LPC17xx QEI unit.
Tsuneo
thanks:
Such a noise is filtered by, 1) R/C (or L/C) filter at the input pins of the QEI unit. And 2) The integrated digital filter of the LPC17xx QEI unit. Is it embedded in the IC or Should I do ? LPC_QEI->FILTER =???(What should i put??)
As of QEI unit of LPC17xx, an ENCLK_Int interrupt occurs at the every transition of the encoder.... I have written below codes to send the data to usb using usbhost lite. FILE_Open, FILE_Write & FILE_Close belong to USBHostlite part:
void qei_main(){ //Basic Configuration: LPC_SC->PCONP |= (1<<18); LPC_SC->PCLKSEL1 |= (0x01); //configuration for the pins: LPC_PINCON->PINSEL3 |=((1<<8)|(1<<14)|(1<<16));//PH A&B & index LPC_QEI->QEICONF =(1<<2);//PhA and PhB function as quadrature encoder inputs.(4x) LPC_QEI->QEICON = 0x02;//Control register: Reset position counter on index.(RESPI) LPC_QEI->INXCMP = 0x00;//QEI Index Compare register LPC_QEI->QEILOAD = 0x00;//QEI Timer Reload register LPC_QEI->QEICLR = 0xFFFFFFFF; LPC_QEI->QEIIEC = 0xFFFFFFFF; LPC_QEI->QEIIES = 0x00000020;//enable ENCLK_EN } NVIC_EnableIRQ(QEI_IRQn); /*enable the interrupt*/ NVIC_SetPriority (USB_IRQn, 1); /*2nd priority--is it correct??*/ void QEI_IRQHandler(void){ USB_INT32S fdw; fdw = FILE_Open(FILENAME_W, RDWR); if (fdw>0) { *UserBuffer=LPC_QEI->QEITIME; FILE_Write(fdw,UserBuffer,4); FILE_Close(fdw); }else{ return; } LPC_QEI->QEICLR = 0xFFFFFFFF; // clear all interrupts }
Is it correct set priority of USB to 0 and QEI to 1??
kind regards
> LPC_QEI->FILTER =???(What should i put??
The time constant of the passive input RC (LC) filter is determined by the PCLK frequency of QEI. It's much less than (1/8 - 1/16) of PCLK QEI FILTER register holds a minimum expected interval of encoder transition, counted in PCLK scale.
> Is it correct set priority of USB to 0 and QEI to 1??
QEI should have the highest priority (0), and USB is assigned to lower priority than QEI.
> I have written below codes to send the data to usb using usbhost lite.
FILE_Open, FILE_Write and FILE_Close are too slow to run in the QEI ISR. Also, it is efficient to write data of sector size at a time.
In the QEI ISR, the timer value is written to a buffer of 1024 bytes. When the buffer holds 512 bytes (sector size) or more, one sector of data is written to the USB drive.
>The time constant of the passive input RC (LC) filter is determined by the PCLK frequency of QEI. It's much less than (1/8 - 1/16) of PCLK
So, if i want to filter pulses less than 2us, what should i write?(clk=100mhz) LPC_QEI->FILTER =0xc8; /*200*/ Is it correct?
>When the buffer holds 512 bytes (sector size) or more, one sector of data is written to the USB drive.
Oh, I am a beginner! I don't know how to access to the buffer. How can i get access to this Buffer? what should i write instead of *UserBuffer=LPC_QEI->QEITIME; ?? can you help me with the codes? thanks
Thanks Dr Tsuneo Chinzei
But how can i detect that number of bytes written in QEITIME is 512? And how to Empty the buffer after writing data?
An other Question: Is it correct to write LPC_QEI->FILTER =0xc8; /*200*/ to filter less than 2us when clock is 100mhz?
Best Regards?
I still haven't got answered my previous questions! I don't know how to get access to the buffer that included timer(QEITIME) values?
another question: what is the practical difference between set register & enable register(QEISET & QEIIES)? Can you give me an example please?
Amir hejazi1365[at]gmail[dot]com Best regards