CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

HELP Speed Measuring for Brushless with sensor hall effect

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
victorcastro89



Joined: 31 Oct 2011
Posts: 11

View user's profile Send private message

HELP Speed Measuring for Brushless with sensor hall effect
PostPosted: Tue Nov 15, 2011 7:33 pm     Reply with quote

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: 9197
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 7:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 16, 2011 12:14 am     Reply with quote

Think again! Serial output of 6 characters @ 9600 Baud takes about 6 ms.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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