|
|
View previous topic :: View next topic |
Author |
Message |
victorcastro89
Joined: 31 Oct 2011 Posts: 11
|
HELP Speed Measuring for Brushless with sensor hall effect |
Posted: Tue Nov 15, 2011 7:33 pm |
|
|
I'm trying to do a speed meter, using three Hall-effect sensors 60 degrees out phase.
To do this just need to know the time between two edges of ascent or descent of the sensors.
The curves are as follows:
To measure the time between two edges thought about using 3 external interrupts, but first simulate in Proteus Isis a program to test such interruptions.
Code: |
#include <18F4550.H>
#fuses HSPLL, PLL5, CPUDIV1, NOWDT, noPUT, BROWNOUT
#use delay(clock=48000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#INT_EXT
void inter0()
{
printf(" int0 ");
}
#INT_EXT1
void inter1()
{
printf(" int1 ");
}
#INT_EXT2
void inter2()
{
printf(" int2 ");
}
main()
{
//setup_timer_0 ( T0_INTERNAL | T0_DIV_1); // 1 contagem 666.666ns
enable_interrupts(INT_EXT);
enable_interrupts(INT_EXT1);
enable_interrupts(INT_EXT2);
clear_interrupt(INT_EXT);clear_interrupt(INT_EXT1);clear_interrupt(INT_EXT2);
enable_interrupts(GLOBAL);
while(1);
}
|
When time between interrupt was 8ms worked properly. But when I used a time of 1ms, it only worked if I used only two hall effect sensors.
Anyone have any better suggestions for measuring the speed of this Brushless Motor, or a solution to my problem?
Thanks! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Nov 15, 2011 7:51 pm |
|
|
problem #1 is Proteus..full of bugs ,errors and bad DRCs.
problem #2, ADD 'errors' to the USE RS232(...) options.
problem #3 , printing within an ISR is very, very bad programming.
ISRs are meant to be short and sweet. Set a flag and get out FAST ! |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Nov 16, 2011 12:14 am |
|
|
Think again! Serial output of 6 characters @ 9600 Baud takes about 6 ms. |
|
|
|
|
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
|