CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

qei module

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 38

View user's profile Send private message

qei module
PostPosted: Mon Apr 15, 2019 11:43 am     Reply with quote

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: 9177
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Apr 15, 2019 1:58 pm     Reply with quote

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

View user's profile Send private message

Re: qei module
PostPosted: Mon Apr 15, 2019 5:23 pm     Reply with quote

raman00084@gmail.com 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.
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 38

View user's profile Send private message

PostPosted: Mon Apr 15, 2019 10:35 pm     Reply with quote

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.
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 38

View user's profile Send private message

Re: qei module
PostPosted: Mon Apr 15, 2019 10:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 15, 2019 11:09 pm     Reply with quote

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: 9177
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 16, 2019 5:49 am     Reply with quote

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: 19378

View user's profile Send private message

PostPosted: Tue Apr 16, 2019 11:26 am     Reply with quote

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: 19378

View user's profile Send private message

PostPosted: Thu Apr 18, 2019 12:09 am     Reply with quote

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?.
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 38

View user's profile Send private message

PostPosted: Thu Apr 18, 2019 12:27 am     Reply with quote

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.
raman00084@gmail.com



Joined: 28 Jul 2014
Posts: 38

View user's profile Send private message

PostPosted: Thu Apr 18, 2019 12:53 am     Reply with quote

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: 19378

View user's profile Send private message

PostPosted: Thu Apr 18, 2019 1:45 am     Reply with quote

I repeat:

post details of the module involved
temtronic



Joined: 01 Jul 2010
Posts: 9177
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 18, 2019 4:50 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group