SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MOTOR

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MOTOR

Postby MYA_HIDAYAH » Sun Mar 18, 2012 4:49 pm

i would like to ask about how to read the encoder using pic 18f4550 and how to calculate the rpm value and display on lcd??

anyone can help me..
MYA_HIDAYAH
Greenhorn
 
Posts: 3
Joined: Sun Mar 18, 2012 4:42 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby A380 » Sun Mar 18, 2012 6:23 pm

If single channel, 3 pulses per rear shaft revolution.
Assumed 4x quadrature encoder is used, so 3 x 4 = 12 counts per rear shaft revolution.
Since you are using SPG-30E-30K (Gear ratio, 30:1), so 12 x 30 = 360 counts (quadrature encoder) per main shaft revolution.

You might need a internal timer to measure the speed of rotation. Let say the timer count the quadrature encoder every 0.1 second (10Hz),
RPM = (Count/360)/0.1 x 60
(1 minute = 60 seconds)
User avatar
A380
Discoverer
 
Posts: 120
Joined: Tue May 19, 2009 2:44 pm
Location: Malaysia

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby rain6271 » Wed Apr 04, 2012 10:49 pm

Dear sir, I am using SPG30E-20K. The user manual stated that there are 60 counts per revolution of main shaft. I was using Channel A of the encoder for capturing pulse. PIC16F877A used, RA4 as input for the captured encoder pulses with TMR0 as counter. But I get almost 240 counts per revolution of main shaft. Therefore, I hv to change the OPTION_REG from 28 to 21 in order to get the correct counts.

How is the quadarature encoder count? It should give 60 counts per revolution right? But how can it count 240 per revolution? What is the reason behind? Pls advice.
rain6271
Greenhorn
 
Posts: 3
Joined: Wed Jan 18, 2012 12:30 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby robosang » Thu Apr 05, 2012 9:00 am

I never use that motor from Cytron, but I did read the tutorial from them, let me search it..... Here is it, Quadrature Encoder.

Not really sure why you get 240 instead of 60, I din check the user's manual and the product, but based on your description, I can make assumption is:
1. The encoder is giving 12 pulses per motor rotation if the gear ratio is 20.
2. The gear ratio is 80 instead of 20.

Anyway, how do you know there is 240 in the timer0?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby MYA_HIDAYAH » Thu Apr 05, 2012 11:38 am

Hi there,

I have a motor speed controller project using Cytron SPG-E30-30k DC Gear Motor with Hall Effect Quadrature Encoder.


How can I calculate the actual rpm of the motor using PIC 18f4550 and display the rpm value at lcd?

From the motor spec, I know that the resolution of the motor is 90 counts per main shaft revolution for 1:30 geared motor

How to calculate or compute the rpm of the motor? Do I need pulse per revolution of motor to compute the rpm?
There is only count per revolution written in data sheet.
MYA_HIDAYAH
Greenhorn
 
Posts: 3
Joined: Sun Mar 18, 2012 4:42 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby rain6271 » Thu Apr 05, 2012 5:49 pm

I used TMR0 as counter. Initially set OPTION_REG = 0x28. Tested in Proteus get a good result. That means that 1 pulse captured will increment 1 on TMR0. Total amount pulses captured in 1 second is equal to the value in TMR0. But when tested actual motor spg30-20k, the main shaft turn faster. Some isolation were done and when I tried to change OPTION_REG = 0x21, the motor shaft speed match with the display speed.

Re-tested OPTION_REG = 0x21 on Proteus, it displayed 1/4 of the motor speed. So, I wonder the accuracy of the ratio given in the motor user manual.
rain6271
Greenhorn
 
Posts: 3
Joined: Wed Jan 18, 2012 12:30 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby rain6271 » Thu Apr 05, 2012 5:57 pm

Hi Hitayah,
I am using TMR0 as counter, RA4 as input port of the encoder pulse. Then, used isr() to make 1 sec interrupt to capture the encoder pulse in every 1 sec.
Can refer to the website below to hv a clear pic.
http://electricallabs.lakeheadu.ca/proj ... /speed.pdf
But I am not sure the compatibility of PIC18F4550. Can compare the data sheet.
rain6271
Greenhorn
 
Posts: 3
Joined: Wed Jan 18, 2012 12:30 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby MYA_HIDAYAH » Fri Apr 06, 2012 12:42 am

HI rain..

i understand the idea that u use the timer0.. but i'm do not understand the programming.. can u explain to me how to do simple programming to move the motor to 0,90,180,360 degree first.. and display the degree at lcd..
MYA_HIDAYAH
Greenhorn
 
Posts: 3
Joined: Sun Mar 18, 2012 4:42 pm

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby Idris » Tue Apr 10, 2012 12:27 pm

Hi Hidayah,
Its quite hard to control the motor angle using encoder DC motor compared to servo motor. Maybe you can try to do a simple program to count the encoder pulse first. If still hard, you need to control the motor movement first: forward, reverse, stop and control the PWM.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: SPG 30-30K (HOW TO READ THE ENCODER OF THIS GEARED DC MO

Postby A380 » Sat Apr 21, 2012 8:22 pm

rain6271,
Channel A will generates 3 pulse per channel if the motor rear shaft is rotated one round.
Channel B also will generates 3 pulse per channel if the motor rear shaft is rotated one round, but this pulses are lag or lead channel A for 90 degree phase different.

Let say SPG30E-20K, 20:1 gear ratio is used.
If you are using 4x quadrature encoder (which process the both channel A and channel B pulses), 12 counts at motor rear shaft, so 240 counts (12x20) per rotation for main shaft.
Since you just monitor one of the channel (let say channel A), only 3 pulses at motor rear shaft you can get, that's why 60 counts (3x20) per rotation for main shaft.

Below is the 4X quadrature explanation.
Image

Or this video might help you.
User avatar
A380
Discoverer
 
Posts: 120
Joined: Tue May 19, 2009 2:44 pm
Location: Malaysia

Next

Return to DC Motor

Who is online

Users browsing this forum: No registered users and 3 guests

cron