View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 28 Jul 2014 Posts: 38
|
qei module |
Posted: Mon Apr 15, 2019 11:43 am |
|
|
I am using dspic33ep512mu810 for interfacing a linear magnetic scale in qei inputs of the controller. Under normal conditions if i move the scale i am getting correct pulses. If input is sensed and if i read the qei then there is fluctuation of around 10 to 15 pulses. See attached code:
Code: |
qei_value = qei_get_count(1)+block_offset_pulse;
lcd_gotoxy(1,1);
printf(lcd_putc1, "SCALE PULSE: %05ld",qei_value); // printing string
print_mm(1,22,qei_value);
IF(INPUT(IN_9)==0)
{
qei_value = qei_get_count(1)+block_offset_pulse;
print_job_mm(2,1,qei_value);
if((qei_value<=(BIG_LENGTH_PULSE+big_length_tolurance_pul))&&(qei_value>=(BIG_LENGTH_PULSE-big_length_tolurance_pul)))
{
lcd_gotoxy(2,25);
printf(lcd_putc2, "RESULT: OK"); // printing string
play_audio("4");/// OK
}
ELSE IF ((qei_value<=(SHOT_LENGTH_PULSE+SHOT_length_tolurance_pul))&&(qei_value>=(SHOT_LENGTH_PULSE-SHOT_length_tolurance_pul)))
{
lcd_gotoxy(2,25);
printf(lcd_putc2, "RESULT: OK"); // printing string
play_audio("4");/// OK
}
ELSE
{
lcd_gotoxy(2,25);
printf(lcd_putc2, "RESULT: NG"); // printing string
play_audio("3");/// NG
}
JOB_COUNT=JOB_COUNT+1;
pcs_minute_count=pcs_minute_count+1;
WRITE_fram_32(get_fram_addr_GENERAL(1),JOB_COUNT);
WHILE(INPUT(IN_9)==0);
DELAY_MS(500);
}
|
Whenever the input in9 is true the pulses are fluctuated. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9272 Location: Greensville,Ontario
|
|
Posted: Mon Apr 15, 2019 1:58 pm |
|
|
Quote: | If input is sensed and if i read the qei then there is fluctuation of around 10 to 15 pulses. |
OK, what 'input' ? If it's a switch, what kind of debounce are you using?
Since the encoder/QEI work fine otherwise, I suspect a 'noisy' switch is causing the 10-15 miscount. Also 10 counts out of how many ? 1024, 4096, 512 ?
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: qei module |
Posted: Mon Apr 15, 2019 5:23 pm |
|
|
[email protected] wrote: | I am using dspic33ep512mu810 for interfacing a linear magnetic scale in qei inputs of the controller. Under normal conditions if i move the scale i am getting correct pulses. If input is sensed and if i read the qei then there is fluctuation of around 10 to 15 pulses.
Whenever the input in9 is true the pulses are fluctuated.
|
There are two QEI errata for that PIC. Read them and see if they apply
to you.
Quote: |
26. Module: QEI
QEI Index Counter - The QEI Index Counter does not
count correctly in Quadrature Detector mode.
In QEI mode (QEIxCON<CMM> = 00), the Index
Counter registers (INDXxCNTH and INDXxCNTL)
cannot be relied upon to increment when the last
known direction was positive and an index pulse
occurs. The Index register can decrement even if
the last known direction was positive. This does not
apply to external clock or internal timer QEI modes.
Work-around:
The index event can be used to implement a
software counter. The direction could be
determined by comparing the current POSxCNT
value to that of the previous index event.
|
Quote: |
27. Module: QEI
Modulo mode functionality is incorrect when
the Count Polarity bit is set.
When Modulo Count mode (Mode 6) is selected for
the position counter (QEIxCON<PIMOD> = 110)
and the counter direction is set to negative
(QEIxCON<CNTPOL> = 1), the functions of the
QEIxLEC and QEIxGEC registers are reversed.
Work-around:
When using Modulo Count mode in conjunction
with a negative count direction (polarity), use the
QEIxLEC register as the upper count limit and the
QEIxGEC register as the lower count limit.
|
|
|
|
[email protected]
Joined: 28 Jul 2014 Posts: 38
|
|
Posted: Mon Apr 15, 2019 10:35 pm |
|
|
temtronic wrote: | Quote: | If input is sensed and if i read the qei then there is fluctuation of around 10 to 15 pulses. |
OK, what 'input' ? If it's a switch, what kind of debounce are you using?
Since the encoder/QEI work fine otherwise, I suspect a 'noisy' switch is causing the 10-15 miscount. Also 10 counts out of how many ? 1024, 4096, 512 ?
Jay |
I am just making a io pin low with the help of a push button for checking. |
|
|
[email protected]
Joined: 28 Jul 2014 Posts: 38
|
Re: qei module |
Posted: Mon Apr 15, 2019 10:37 pm |
|
|
PCM programmer wrote: |
There are two QEI errata for that PIC. Read them and see if they apply
to you.
|
Can you suggest any dsPIC that has less number of silicon errata ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 15, 2019 11:09 pm |
|
|
No. According to Microchip MAPS, at least 95 dsPICs exist that have
at least 2 QEI modules. I don't want to look at 95 errata sheets to
see which ones don't have errata on the QEI.
https://www.microchip.com/maps/Microcontroller.aspx |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9272 Location: Greensville,Ontario
|
|
Posted: Tue Apr 16, 2019 5:49 am |
|
|
I've always used US Digital's QEI modules. Never, ever had one fail in 2+ decades. Their encoders are superior to HP units as well.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19592
|
|
Posted: Tue Apr 16, 2019 11:26 am |
|
|
Since he is just using a switch for testing, I'd suggest the problem is bounce.
QEI modules are designed not to give switch bounce. Switches are not.
Add a small capacitor to the signal input and see if this helps. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19592
|
|
Posted: Thu Apr 18, 2019 12:09 am |
|
|
As a comment, in the earlier thread about an encoder, you were asked to
post details of the module involved. I will repeat this. To give really sensible
replies, we need to know what the quadrature signal is actually coming from?. |
|
|
[email protected]
Joined: 28 Jul 2014 Posts: 38
|
|
Posted: Thu Apr 18, 2019 12:27 am |
|
|
temtronic wrote: | I've always used US Digital's QEI modules. Never, ever had one fail in 2+ decades. Their encoders are superior to HP units as well.
Jay |
How to communicate to pic micro, i2c or spi ? Please suggest any U.S. Digital chip number for 1 axis, 32 bit qei. |
|
|
[email protected]
Joined: 28 Jul 2014 Posts: 38
|
|
Posted: Thu Apr 18, 2019 12:53 am |
|
|
Ttelmah wrote: | Since he is just using a switch for testing, I'd suggest the problem is bounce.
QEI modules are designed not to give switch bounce. Switches are not.
Add a small capacitor to the signal input and see if this helps. |
I have connected a incremental linear scale. The scale's moving head and the fixed block piece are connected to contact sensor of microcontroller. Initially the head and the block will be kept in contact. If I switch on the power, the qei will be 0 at this point.
If I move forward it will show some reading and if I hit the block the touch sensor will sense the input. Now after 100 ms delay i am reading the qei. Now i must get 0 but in this case the value is fluctuating by about 20 counts.
Now case 2, I removed the touch sensor. The qei get count function and LCD print is running continuously in while loop. If I hit the block it is showing exactly 0. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19592
|
|
Posted: Thu Apr 18, 2019 1:45 am |
|
|
I repeat:
post details of the module involved |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9272 Location: Greensville,Ontario
|
|
Posted: Thu Apr 18, 2019 4:50 am |
|
|
https://www.usdigital.com/products/interfaces/ics/LS7366R-S
This is the 32 bit version. I've only used the 24bit/ dual version with their encoders, again 20 +years ago. Rock stable counts, never had a chopper crash !
Again you're telling us it works fine EXCEPT when the 'sensor', a 'touch sensor' is added to the program.
We really need that sensor's datasheet and schematic. Also what power supply are you using.
Also show us your curent test program.
The more information you supply, the better/faster we can help.
Without that information, we really can't decide if it's hardware or software and I for one, while I do like challenges, will go help others.
Jay |
|
|
|