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.

Rotary Encoder

Status
Not open for further replies.
hi
I see that you have placed the LCD's service call in the Idle loop, is this just temporary.?
You dont need to call the LCD until there has been an Interrupt, you could place a IntFlag in the ISR, so the LCD is only called if the IntFlag is set.

I dont have the floating point option from Oshonsoft, so I have changed Single to Word variable, the program runs OK.
E
 
Just a quickie,

This doesn't work

Select Case arg1
Case >= 7 and < 7.1

Is this type of syntax possible or do I need a lot of ifs?

Cheers - Paul
 
Interestingly when I take the LCD calls out and put them in the interrupt I get hardware stack overflow errors?
 

Attachments

  • Rotary Encoder.bas
    7.2 KB · Views: 486
Interestingly when I take the LCD calls out and put them in the interrupt I get hardware stack overflow errors?
hi,
Dont put the LCD in the ISR, the PIC Stack is only 8 deep.

Code:
Select Case var1     
        Case >= 7 ' allowed but =>7  is not, also only one Case Test is allowed per Case.
    ''''
        Case Else
    EndSelect
Goto main

You may find this revamped version of the Oshonsoft manual easier to use.
I rewrote the manual and posted it to the Oshonsoft site back in 2010
Eric
 

Attachments

  • BasicOSV7.doc
    178.5 KB · Views: 594
Well here's my version so far guys I hope it helps anyone that might be as stuck as I was.

Thanks for the updated manual Eric - Very useful :)

I have done quite a few alterations and added a bit more functionality. It's still a bit scrappy (I think I might need to tidy a few things up) but this is doing what I had hoped (in simulation).
How this performs in real life - well hopefully i'll get a test up and running over the weekend and get something on YouTube.
 

Attachments

  • Rotary Encoder.bas
    10.6 KB · Views: 511
hi Paul,
Ran your last Basic program OK.
My concern is the amount of time the program uses in servicing the LCD.
If the User turns the Encoder too quickly, you could get missed direction changes or get Stack overflows.

The CALL functions will use the Stack, also the LCD Basic uses the Stack.
E
 
Hi Eric. I aslo have these concerns but i'm not sure how to deal with it. Maybe i'll have to lose the analog display or do was many have done and split the operation for the LCD to another pic.

At present i'll go with it and see what happens.
 
hi Paul,
If you have the hardware 'sort of' built' try the program in a PIC, lets know what you get. [ dont forget to rem out the Define SIMULATION_WAITMS_VALUE = 1 or make = 0.]
Eric
 
Aghhhhh - It's driving me nuts! - Can anyone tell the correct configuration for the 16f876 please? I am using an external 4mhz OSC on pins 9 & 10. I tend to avoid using external xtals for just this reason. Always drives me mad. I just cant get the PIC to run :-(

Can anyone help please?
 
hi Paul,
You should have these two lines on your program Header.

Define CONFIG = 0x3d71 'Ext 4MHz Oscillator'
Define CLOCK_FREQUENCY = 4


To set/check the CONFIG for any Oshonsoft PIC.

Top Menu Bar, click.
Options/Configuration Bits

[Refer attached image]
Use the 'Toggle View [1/4]' button to Step thru the way the CONFIG labels are displayed.

Adjacent to each label is a drop down arrow, click and select your CONFIG options.

When done, Click 'Generate Basic Code' button, this will place the Define CONFIG xxxx at the head of your Basic program listing.
Click 'Accept' button when done.

You should have on your project board a 15pF or 22pF cap from each leg of the Xtal to 0v.

Post a photo of your project board if you have a problem.

Eric.

EDIT:
Ensure that the /MCLR pin if used, is correctly connected and not 'floating'
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    22.5 KB · Views: 417
Hello Eric. Many thanks for the speedy reply. I spent ages trying to sort this out last night and within 2 mins this morning I have it oscillating :)
This I have to admit was down to my eyesight and simple wood for the trees. It seems the circuit prefers 22pf and not 22nf. I now have the opening screen displayed on the LCD which is just sitting there doing nothing at present. I'll investigate further and post my findings for anyone else following this thread.

BTW - I found this datasheet most helpful --> https://ww1.microchip.com/downloads/en/DeviceDoc/31002a.pdf
I hope it's ok to post links here.

Cheers Paul
 
Hello Eric. Many thanks for the speedy reply. I spent ages trying to sort this out last night and within 2 mins this morning I have it oscillating :)
This I have to admit was down to my eyesight and simple wood for the trees. It seems the circuit prefers 22pf and not 22nf. I now have the opening screen displayed on the LCD which is just sitting there doing nothing at present. I'll investigate further and post my findings for anyone else following this thread.

BTW - I found this datasheet most helpful --> https://ww1.microchip.com/downloads/en/DeviceDoc/31002a.pdf
I hope it's ok to post links here.

Cheers Paul

Hi Paul,

Good that you have the Oascillator working. I was drawing this before you replied, so I've posted it anyway, it's for a Crystal, which I prefer if I'm making a 'proper' circuit.

Camerart
Hello Eric. Many thanks for the speedy reply. I spent ages trying to sort this out last night and within 2 mins this morning I have it oscillating :)
This I have to admit was down to my eyesight and simple wood for the trees. It seems the circuit prefers 22pf and not 22nf. I now have the opening screen displayed on the LCD which is just sitting there doing nothing at present. I'll investigate further and post my findings for anyone else following this thread.

BTW - I found this datasheet most helpful --> https://ww1.microchip.com/downloads/en/DeviceDoc/31002a.pdf
I hope it's ok to post links here.

Cheers Paul
Hi Paul,

Good that you have the Oascillator working. I was drawing this before you replied, so I've posted it anyway, it's for a Crystal, which I prefer if I'm making a 'proper' circuit.

Camerart
 

Attachments

  • XTAL.jpg
    XTAL.jpg
    27 KB · Views: 429
Hi everyone. After much messing with and learning about MCLR, pull up and pull down resistors here's what I have. It's still in it's infancy (sorry about the birds nest) but i seems to work. No debounce on the interrupt with a push button. Will be interesting to see how the encoder performs. Just waiting for a 4030B or a 7486 quad XOR gate. You can just see the bread board with the start of the encoder.


If it's ok i'll keep posting until I have the correct sine wave from the AD9850 for people to follow and i'll try and do something for an article Eric.

Cheers - Paul
 
hi Paul,
Thats looking good, it will make a great Article, but take your time.;)
Eric
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top