|
Hi Alp,
have you been able to control your PIC from another Windows application
- not MATLAB, not Real-Time Windows Target? What data format were you using?
From the PIC code below it looks like the device expects the data in
ASCII, so you would need to use Stream Output. Further, it looks like
you are expecting an integer decimal number, so you should set the
format string to '%d'. Of course, you must ensure that baud rate, bit
length, parity, etc. settings of the PIC match those of Real-Time
Windows Target (settable in Board Setup).
Other than this, I can't think of anything else at the moment. But I'd
definitely start from a working setup (if you have any) and gradually
change thing to the desired setup with Real-Time Windows Target.
Good Luck, Jan
Alp wrote:
> Thank you for your help. We tried your way ,but we cannot achived to get proper result. I am telling you our project with its details. I hope you can find our missings. We want to produce PWM signal (from B0 pin) from PIC according to coming signal from Simulink (0 to 1000). We used MAX232 IC for converting +12V,-12V to 5V,0V.
> CCS C Program of PIC16F877:
>
> #include <16f877.h>
> #include <stdlib.h>
> #fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
> #use delay (clock=4000000)
> #use rs232 (baud=9600, xmit=pin_C6, rcv=pin_C7, parity=N, stop=1)
> #use fast_io(b)
>
> long int A=63536;
> char klavye[16];
> int16 x=0;
> #int_rda
> void serihaberlesme_kesmesi ()
> {
> disable_interrupts(int_rda);
> output_high(pin_c5);
> gets(klavye);
> output_low(pin_c5);
> }
> //****************** Timer1 Interrupt (1-2 ms) ****
> #int_timer1
> void timer1_kesme ()
> {
> output_low(pin_b0);
> }
>
> //****************** Timer0 Interrupt (20 ms) *****
> #int_timer0
> void timer0_kesme ()
> {
> output_high(pin_b0);
> set_timer0(177); // TMR0
> set_timer1(A); // TMR1
> }
>
> void main ( )
> {
> setup_psp(PSP_DISABLED);
> setup_timer_2(T2_DISABLED,0,1);
> setup_CCP1(CCP_OFF);
> setup_CCP2(CCP_OFF);
> setup_adc_ports(NO_ANALOGS);
> setup_adc(ADC_OFF);
>
> set_tris_b(0x00);
> output_b(0x00);
>
> setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256); // Timer0
> set_timer0(177); // TMR0
> setup_timer_1(T1_INTERNAL | T1_DIV_BY_1); // Timer1
> enable_interrupts(INT_timer1);
> enable_interrupts(INT_timer0);
> enable_interrupts(GLOBAL);
>
>
> while(1)
> {
> x=atol(klavye);
> A=64536-x;
> enable_interrupts(int_rda);
> }
> }
>
> Simulink File:
>
> Constant-->Slider Gain-->Stream Output (or Packet Output)
>
> Thank you again..
--
--
Jan Houska HUMUSOFT s.r.o.
houska@humusoft.com Pobrezni 20
http://www.humusoft.com 186 00 Praha 8
tel: ++ 420 284 011 730 Czech Republic
fax: ++ 420 284 011 740
|