Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Has anyone had problems with QEI affecting the rest of the CODE?

Status
Not open for further replies.

camerart

Well-Known Member
Hi,
I am using an 18F4431 with a QEI and an incremental encoder.
On it's own it works perfectly, and I use it for degrees so 0 to 359 then over to 0 again.

I've now added a second section for reading a GPS module, which also works ok, but when the QEI goes over 359, then it stalls the program.
Any ideas please?
Cheers, Camerart
 
Last edited:
No it's a statement - previously you had interrupts enabled, sending your code off to 'who knows where' - you've now disabled them.
Hi N,
I've been using this QEI for years and thought I understood it, but eveidently I don't!
I work through it with a mate at the weekends, and we both guess it works without any INTERRUPTs, which it does, but perhaps that's just lucky?

I looked back into programs where I first used it. (an aerial aiming tracker) and saw this in the INTERRUPT section:
--------------------------------------------------
On High Interrupt
Save System
PIR3.IC2QEIF = 0 'poscnt=maxcnt
PORTA.4 = 0 'QEA PIN
PORTA.4 = 1 'QEB PIN
PIE3.IC2QEIE = 1 'qei intr enb
-------------------------------------------------------------------
Is this what you're thinking of?

NOTE: When used earler, QEI ran on it's own, and appeared to use HIGH INTERRUPT
This time there is a GPS input INTERRUPT, and it is also set to HIGH INTERRUPT, and with the QEI set as DISABLED, both work ok.
EDIT: Is there any possibility, that OSHONSOFT is setting INTERRUPTs in the background?
C
 
Last edited:
Hi N,
I've been using this QEI for years and thought I understood it, but eveidently I don't!
I work through it with a mate at the weekends, and we both guess it works without any INTERRUPTs, which it does, but perhaps that's just lucky?

I looked back into programs where I first used it. (an aerial aiming tracker) and saw this in the INTERRUPT section:
--------------------------------------------------
On High Interrupt
Save System
PIR3.IC2QEIF = 0 'poscnt=maxcnt
PORTA.4 = 0 'QEA PIN
PORTA.4 = 1 'QEB PIN
PIE3.IC2QEIE = 1 'qei intr enb
-------------------------------------------------------------------
Is this what you're thinking of?

NOTE: When used earler, QEI ran on it's own, and appeared to use HIGH INTERRUPT
This time there is a GPS input INTERRUPT, and it is also set to HIGH INTERRUPT, and with the QEI set as DISABLED, both work ok.
EDIT: Is there any possibility, that OSHONSOFT is setting INTERRUPTs in the background?
C
Yes "PIE3.IC2QEIE = 1"

You MUST NOT enable interrupts unless you have an ISR - where do you think they are jumping to?, check the Oshosoft helpfile.

However, the section you've just posted looks to be part of an ISR (On High Interrupt), which you didn't have in the code you posted here.
 
Yes "PIE3.IC2QEIE = 1"

You MUST NOT enable interrupts unless you have an ISR - where do you think they are jumping to?, check the Oshosoft helpfile.

However, the section you've just posted looks to be part of an ISR (On High Interrupt), which you didn't have in the code you posted here.
Hi N,
Where I said " I looked back into my programs" the 'high interrupt' section was from 2019.

"Where are they jumping to"? I've no idea! Most of this is a mystery to me, although I have looked closer in the past, but that's faded away.

So even though it's working fine along with the 'GPS interrupt', do you still think I have to add the QEI one? (It always broke, when they both ran together)
C
 
Hi N,
Where I said " I looked back into my programs" the 'high interrupt' section was from 2019.

"Where are they jumping to"? I've no idea! Most of this is a mystery to me, although I have looked closer in the past, but that's faded away.

So even though it's working fine along with the 'GPS interrupt', do you still think I have to add the QEI one? (It always broke, when they both ran together)
C
The same still applies - WHERE ARE THEY JUMPING TO - if you enable interrupts you must have code for them to jump to, such as in post #23. As you've never posted any GPS code, we've no idea what you're doing.

It's no good posting just bits of code, or code from old projects, you need the to post the entire code from what you're trying to do. Although, as I mentioned before, no one here much uses OshonSoft anyway.
 
The same still applies - WHERE ARE THEY JUMPING TO - if you enable interrupts you must have code for them to jump to, such as in post #23. As you've never posted any GPS code, we've no idea what you're doing.

It's no good posting just bits of code, or code from old projects, you need the to post the entire code from what you're trying to do. Although, as I mentioned before, no one here much uses OshonSoft anyway.
Hi N,
Some people don't like full CODE, and I was told to just post snippets.
Here is the full todays CODE:
NOTE: It's still being worked on!
C
 

Attachments

  • 18F4431 32MHz XTL BASE_SLAVE RX_QEI 271122.bas
    19.8 KB · Views: 169
Except it didn't, because you enabled QEI interrupts without any code for them.
Hi N,
This I don't understand?
As it is at #27 (on PIC 2), it is reading the QEI and passing it into PIC1 via SPI, which is converts the 2x BYTEs into degrees and displays accurately, so to me it's working, other than that I don't understand?
C
 
Hi N,
This I don't understand?
As it is at #27 (on PIC 2), it is reading the QEI and passing it into PIC1 via SPI, which is converts the 2x BYTEs into degrees and displays accurately, so to me it's working, other than that I don't understand?
C
In the full code you've posted, presumably modified via your friend?, the QEI interrupts are disabled - your original code enabled them.

I'll give you a simple 'example' :D

Your mother has three friends - Mr. Uart, Mrs Timer and Miss QEI.

She tells you to go to Mr. Uart's house, and do what he tells you - he gives you a cake, and tells you to take it back to your mother.

Next, she tells you to go to Mrs. Timer's house, and do what she tells you - she gives you a loaf of bread, and tells you to take it back to your mother.

Finally, she tells you to go to Miss QEI's house, and do what she tells you - you get there, and no one is in - so you spend the rest of your live standing outside waiting for instructions from her.

That's a VERY crude and simple example of what you were doing.
 
In the full code you've posted, presumably modified via your friend?, the QEI interrupts are disabled - your original code enabled them.

I'll give you a simple 'example' :D

Your mother has three friends - Mr. Uart, Mrs Timer and Miss QEI.

She tells you to go to Mr. Uart's house, and do what he tells you - he gives you a cake, and tells you to take it back to your mother.

Next, she tells you to go to Mrs. Timer's house, and do what she tells you - she gives you a loaf of bread, and tells you to take it back to your mother.

Finally, she tells you to go to Miss QEI's house, and do what she tells you - you get there, and no one is in - so you spend the rest of your live standing outside waiting for instructions from her.

That's a VERY crude and simple example of what you were doing.
Hi N,
Now I understand!
I've done lots of hanging around waiting for stuff, and I'd probaly eat a bit of cake, and face the concequences later.

I assume then that I've got to I've got to figure out which flags and enables bits to put in order? Is that something like you'd expect?
C
 
Hi N,
Now I understand!
I've done lots of hanging around waiting for stuff, and I'd probaly eat a bit of cake, and face the concequences later.

I assume then that I've got to I've got to figure out which flags and enables bits to put in order? Is that something like you'd expect?
C
As you're not using QEI interrupts, then simply don't enable them.
 
Yes - but in your original post they WERE enabled.
Hi N,
Yes they were, but my mate said he doesn't think they need to be, so we switched them off and tried test.

We mark suspect changes with '&' and if errors appear this is where we look at first.

Ok, no cake then :)
Thanks, for a long exchange.
C
 
Hi,
Just remembered!
When I posted the earlier CODE, with the interrupts, in another part of the program, I had disabled HIGH INTERRUPT. I'm sure this confused everyone, as I missed it out.
This is the way I program, and each time I come to an issue like this this is the sort of tangle I get into.
C
 
Hi,
I'm still stuck and had forgotten this thread, and asked the same question at AAC.
I'm trying to understand how ISR work, and what actually happens at the very high speeds, I'm having difficulty understanding.

As mentioned, I'll concentrate on the ISR with my mate, who can go through it with me.

One question though is, when moving the QEI input (which needs to not miss any counts) do all other interrupts need to be off?
C.
 
Hi,
I think we've sorted out the INTERRUPT problem!
There are 3x INTERRUPTS 1x for position, 1x for speed, and 1x for rotation count.
As this project doesn't need any of them, they can be disregarded.

The error seems to be:
ADCON0
ADCON1
Since these were placed in the INCLUDE, is when the intermittent error started, I'm not sure why, but I went along the wrong fork with INTERRUPTS.
Thanks for all of the effort, much appreciated.
C
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top