hdd motor and 16f675

Status
Not open for further replies.

MODCHIP

Junior Member level 3
Joined
Feb 13, 2008
Messages
29
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Visit site
Activity points
1,495
hello evrybody

i m trying to drive a 4 wire hdd motor with pic 16f675 so i try this schematic with the commun pin of the motor connected to 12v

i m asking if it will be working with this code



#include <12F675.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES BANDGAP_HIGH
#use delay(clock=4000000)

int8 count,delay,a;
#define data1 pin_A0
#define data2 pin_A4
#define data3 pin_A5
#int_RTCC
void RTCC_isr(void)
{
count++;
if (count==a*3){count=0;}

}

void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);

// TODO: USER CODE!!
a=10;
do
{


if(count<a){output_high (data1);output_low (data2);output_low (data3);}
if(count>=a&count<a*2){output_low (data1);output_high (data2);output_low (data3);}
if(count>a*2&count<a*3){output_low (data1);output_low (data2);output_high (data3);}

}while (1);
}
 

Attachments

  • spindle mot.bmp
    1.4 MB · Views: 76

Hello MODCHIP, already compiled the code? Showed errors or warnings? Which version of CCS you used? I don't know how a HDD motor works, but by the moment I see that possibly you are using bitwise operators where there should be logic operators here:

Code:
if(count>=a [B]&[/B] count<a*2)
if(count>a*2 [B]&[/B] count<a*3)

Perhaps it should be:

Code:
if(count>=a [B]&&[/B] count<a*2)
if(count>a*2 [B]&&[/B] count<a*3)

Regards!
 

hello bmb_10 yes it is alredy compiled and it give me the signal in the picture of my first post
i use ccs 4.057

thank you for all i will try logic operators && and tell you
 

hello bmb_10 yes it is alredy compiled and it give me the signal in the picture of my first post
i use ccs 4.057

thank you for all i will try logic operators && and tell you

your output already looks like what you wanted it to be, probably because of precedence of operators, where the LHS comparison (resulting in TRUE/FALSE) and RHS comparisons are done first, and only after this is the bitwise & performed. The resulting answer is hence correct even without &&

One further thing to note is that the speed at which you switch the signals is very important. This speed has to be synchronised with the physical position of your motor while it rotates, otherwise you will get very strange results. having a fixed rate of signal switching is not good enough.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…