Quadrature and 18F4455

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Quadrature and 18F4455

Post by Bobw »

I have started a basic FC5 using a 18F4455
I have a Glcd hooked up to portA 0 to 3
The quadrature is on portB 0 an portB 1
I have created a single variable "pcount" as ulong (just want to count pulses)
When I set everything up to run the simulation, it runs, the display starts to count up, but the encoder disappears from the panel so I can not rotate it?

Bob

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Quadrature and 18F4455

Post by JohnCrow »

Hi Bob

The quadrature component is one of those that cannot be simulated, it only works on hardware.
1 in 10 people understand binary, the other one doesn't !

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Quadrature and 18F4455

Post by Bobw »

Begs the question of why they added it if it does nothing.
Was going to use two of them, one optical and one mechanical.
Back to the drawing board.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Quadrature and 18F4455

Post by JohnCrow »

Hi Bob
The quad component works fine when compiled to a chip.
Are you using the Matrix rotary encoder e-block or your own hardware?
Simple Rotary Encoder Test - Port B V1.fcf
(14.19 KiB) Downloaded 382 times
Ive attached a simple program which can show the encoder values on the LCD
1 in 10 people understand binary, the other one doesn't !

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Quadrature and 18F4455

Post by Bobw »

John,

I am using all my own hardware.
I just wanted to be able to see the encoder count up or down depending on which way I rotate it.
Will have to use a couple of switches to simulate it and see if that works.

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Quadrature and 18F4455

Post by Bobw »

John,

Thanks for the look at the encoder file.
Gave me a bit better understanding on how the encoder should work.
But not being able to simulate it is a major downfall.
My whole program is going to be based around reading the position based on pulses from the encoder. I was hoping to write most of the program before having to compile and test things out. But then I am still waiting for all of the electronic hardware to arrive from Digikey.

Bob :shock:

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: Quadrature and 18F4455

Post by saschech@gmx.de »

Hello Bobw

Have a look inside the pdf.I work with toggle interruption.Work well.

Regards Wolfgang
Attachments
drehgeber_01.pdf
(151.04 KiB) Downloaded 297 times

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Quadrature and 18F4455

Post by Bobw »

Wolfgang,

That's what I was working on in the simulator.
I set up 2 switches to represent the output of the encoder. I like your method for determining direction.

Once my hardware arrives I will need a simple program to just count up the pulses. I have no idea how many motor pulses will equal one revolution of the output shaft after the gear box. After that I will need to count up or down to depending on the direction going to keep your chart close by for a reference.

Thanks

Bob

benp
Posts: 155
Joined: Sat Mar 28, 2009 5:44 pm
Location: LYON FRANCE
Has thanked: 3 times
Been thanked: 41 times
Contact:

Easy encoder with only one magnet

Post by benp »

Austria microsystem manufacture a very simple to use encoder chip.
You only need to fix one magnet at the end of the rotating shaft and put the chip from 0.5 up to 2.5 mm from the rotating magnet.
The chip calculate the angle and output it when you ask it.
It is very easy to interface with flowcode, you can chain it and still need only 3 pins.

Here is my flowcode test program:
as5030testv2.fcf
(11.5 KiB) Downloaded 305 times
You can find the datasheet here and schematics here:
http://www.austriamicrosystems.com/cont ... load/12122

It is a SMT chip but it is easy to use with this adapter from farnell:
http://fr.farnell.com/roth-elektronik/r ... dp/1426182

With my test chip (AS5030), you can ask for the angle and the magnetic field. I will test the as5130 which can give the turn number in addition.

Here is a video demo:
[/youtube]

The AS5030 can count the angle up to 30000 rpm.
A quadrature encoder ask a high load from the microcontroler if the speed is high or the resolution is high.

If you really want to use quadature encoder, you can use the xor method. It's quick and simple to code.
I explained the method here.
http://www.matrixmultimedia.com/mmforum ... 589#p27781
Regards
INSA 1er cycle GCP projects with or without eblocks:
http://www.youtube.com/user/INSAgcp

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Quadrature and 18F4455

Post by Bobw »

Benp,

Thanks, will keep that in mind.
I do not for see any problems. This is a low speed AC motor (24VAC).
Being this is my first time dealing with a quad encoder,
I plan on a couple of test programs to see how many pulses per rev of the output shaft and test counting up and down.

Bob

Post Reply