Jump to content

ra68gi

EstablishedMember
  • Content count

    229
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ra68gi

  • Rank
    Super Enthusiast

Profile Information

  • Gender
    Male
  • Location
    India
  1. Tim, If u need to connect more than one LCD to ur mico connect them in parallel & multiplex them using some thing like using chip-select pin. Only one driver file can be used. May be u need to write ur own driver to support parallel devices working on different i/o pins. Most spi device will have chip-select pin. connect all devices in parallel(in, out & clk)& use different i/o pins for multiplexing the chip-select pin. Regards Raghunathan.P
  2. Hi, Have u not tried the picpack lib(pic_serial.c)? I tried it with 2550 & it works. Its such a waste of time trying to make a virtual serial port from ur usb device. USB is used for hi speed communication & u can make HID class device thro' which u can transfer data at a rate of 40-50 characters per millisecond. Sending variables from pic to PC is so easy using the HIDMAKER tools from tracesystem. try this out... http://tracesystemsinc.com/all-usb-product...ucts-alias.html Regards Raghunathan.P Edit : Sorry Harris I did'nt realise this was a very old thread.
  3. Long time ago I had asked Dr.Bob(Robert Miller) of Trace Systems if they could integrate BoostC compiler. I think Pavel & Dave should decide on this. HIDMAKER32 is shortly expected & they will support most USB microcontrollers from the 8bit to 32bit device. Regards Raghunathan.
  4. Hi, for all those who find USB difficult can try a simpler way of implimenting USB in ur PIC projects. http://tracesystemsinc.com/all-usb-product...ucts-alias.html Dave & Pavel, it will be nice if BoostC can be integrated in HID maker. Regards Raghunathan.P
  5. Hi Joli, acquiring 24bit signed data & storing it in 32bit signed can be a bit confusing. My approach is like this.. First I test if its MSB(24bit signed) is a 1. If its 1 then its a signed data. I store the rest of the bits in our normal 32bit(long) unsigned type. Then on the long data I do a 2's compiliment. finally to get the signed 32 bit data, I multiply it with -1. Here is an example done on 18bits of data. The rest of the adc bits where purposefully truncated. u can modify the code for 24bit signed. unsigned long adc_counter, adc_counter1; signed long adc_buff1; if(adc_digit_sign_flag==1) //If the MSB of the 24bit signed data is a 1 then..do 2's compliments. { adc_counter1 = adc_counter; adc_counter1 = ~ adc_counter1; // 1's compliment. adc_counter1 = adc_counter1 & 0x003FFFF; // 0x003ffff;0b00000000000000111111111111111111;rest of the bits other than the bits we use must be // forced to zero. adc_counter1 += 1; // 2's compliment. } if( adc_digit_sign_flag == 1) // set a flag for MSB of the 24bit signed data. convert it into 32bit signed l_adc_buff1 if the flag is 1. { adc_buff1 = (-1)* adc_counter1; } I hope the above code can help u come out with a method of storing 24bit signed data. Regards Raghunathan.P
  6. 24 bit floats ?? Regards Dave Some ADCs store the adc results (24bit) in signed 2s compliment format. The datas are usually sent out via SPI. In such case a it can be a little helpful if we could directly load the value into such data types. Regards Raghunathan.P
  7. Hi Dave, When can we expect the next release of Source Boost IDE? Will the the above device be included in the target device drop down menu? I have not yet down loaded the beta2 version. Regards Raghunathan.P
  8. Dear sir, Please allow me to differ with you here. I think its the time which becomes half of the total ccp. So the freq would be double. Please correct me if I am wrong as I am a novoice. I still think that the CCPR1L's value must be half of the value of period register value in order to get a 50% duty cycle. Am I wrong? Further more I was just wondering whether the ECCP o/p keeps on running in background, allowing me to do any other jobs with my pic (like continously monitering the adc channel, making some ports high or low etc?) Thanks for your efforts and support Regards Shree Some times things defy our reasoning so I suggest u program a device & see the wave forms on an oscilloscope. Regards Raghunathan.P
  9. Shree, The PWM output at the ccp pin is designed for 100hz and the two out of phase pulse generated in the ISR will have half the freq of the ccp pin ie.50hz. Now the pulse out at the ccp pin can have 0 to 100 % ON time by loading the ccpr1l & ccpr1h. This ccp pin pulse has to be ANDed with the 50hz pulse generated in the ISR. Then As the duty cycle changes from 0 to 100% in the ccp pin the 50hz pulse in ISR(RB0 & RB1) will vary from 0 to 50%. A graphical representation will make things better to understand. Try if u can figure out from the above information. Regards Raghunathan.P
  10. Hi Shree, I don't know about your code, but I can tell u how the PWM module works. First there are three important registers associated with it. they are 1) tmr2 or timer2 register 2) pr2 register also called the period register. 3) ccpr1l & ccpr1h which holds the 10bit duty cycle value. a)PWM generates a square wave form output at the ccp pin. b)Any square wave form has an ON time & OFF time. c) The ON time is called the duty or duty cycle. d) One ON time plus one OFF time is called the period or T. Frequency of the wave form is f = 1 / T . e) The ON time is decided by the duty cycle value(10bit ccpril & ccp1con<5:4>) register. f) The Period or frequency is controlled by the pr2 value. How it works? Two comparators keep comparing the pr2 register value & duty cycle value with timer2(tmr2) value which is free running. When the tmr2 value equals pr2 value the ccp pin is made high & next when it reaches ccpr1l + ccp1con<5:4> value it makes the pin low. Also when tmr2 value equals pr2 value a flag is set & the tmr2 is reset to zero. You can enable the interrupt bit TMR2IE. You can try to change the duty cycle value in the ISR. You can also toggle your i/o pins in the ISR. Use this sample code on PIC16F72 or similar. Use external RC. R value is 10k & C value is 68pf. You can see the output in ccp pin. Also two out of phase 50hz pulse in RB0 & RB1. #include <system.h> // Set clock frequency to 1MHz. #pragma CLOCK_FREQ 1000000 //set configuration fuse. #pragma DATA _CONFIG, _RC_OSC & _WDT_OFF & _CP_OFF & _PWRTE_OFF int duty_cycle; //global variable /*Interrupt service routine (ISR).On timer2 interrupt, program will jump to this code location. */ void interrupt( void ) { char pulse; /*generate two 50hz 180 degree out of phase pulses & externally AND it with the 100Hz pwm pin to get a modulated 50Hz to drive mosfets connected to a transformer in a push-pull configuration. A/D conversion of the the output voltage can act as feed back to adjust the duty-cycle ( not yet implemented in this code). */ pulse = portb; pulse.0 = ~ pulse.0; pulse.1 = ~ pulse.1; portb = pulse; pir1.1=0; //clear TMR2 to pr2 match interrupt flag } void load_duty_cycle(void) { ccpr1l.7 = duty_cycle.9; ccpr1l.6 = duty_cycle.8; ccpr1l.5 = duty_cycle.7; ccpr1l.4 = duty_cycle.6; ccpr1l.3 = duty_cycle.5; ccpr1l.2 = duty_cycle.4; ccpr1l.1 = duty_cycle.3; ccpr1l.0 = duty_cycle.2; ccp1con.5 = duty_cycle.1; ccp1con.4 = duty_cycle.0; } // The main code configures the pwm registers void main() { trisa = 255; trisb = 0; //configure port B as output trisc = 0; // portc as out put portb = 1; //set port B to 1 portc = 0; //clear portc // enable interrupts intcon.6=1; //enable peripheral interrupt intcon.7=1; //enable global interrupt pie1.1=1; //tmr2 to pr2 match interrupt //configure the ccp1con register to enable PWM module. /*ccpxm3:ccpxm0: mode select bits<3:0> 11xx = for PWM mode. */ ccp1con=0b00001100; // //PWM period=[(PR2)+1]*4*Tosc*(TMR2 prescaler value) /*our pmw period is 10ms(100Hz),Tosc is 1/1000,000Hz & prescaler is 16.For which PR2+1 works out to 156.25. Lets round it to 156 & make PR2 to 155. */ //load the period value into pr2 register. pr2 = 155; /*timer2 control register we have selected bit6-3...(0000) 1:1 for post scaler bit2.....(1) timer2 on bit1-0...(11) prescaler is 16 */ t2con = 0b00000111; /*PWM duty cycle = (ccpr1l:ccp1con<5:4>)*Tosc*(TMR2 prescaler value) Here i have taken 2ms as an example value for duty cycle, Tosc & pre- scaler are same as above.We will get 10 bit values when we work with larger duty cycle but for our example we get the value as 125. */ //load the duty cycle values while( 1 ) { int b0; for(b0=1;b0<563;b0++) { duty_cycle = b0; load_duty_cycle(); delay_ms(9); } } } hope this helps Regards Raghunathan.P
  11. I think we don't have. You can make your own function. I have a sample code made long back. see if it can help u. Its made for PIC16F72, 1mhz RC clock. #include <system.h> // Set clock frequency to 1MHz. #pragma CLOCK_FREQ 1000000 //set configuration fuse. #pragma DATA _CONFIG, _RC_OSC & _WDT_OFF & _CP_OFF & _PWRTE_OFF int duty_cycle; //global variable /*Interrupt service routine (ISR).On timer2 interrupt, program will jump to this code location. */ void interrupt( void ) { char pulse; /*generate two 50hz 180 degree out of phase pulses & externally AND it with the 100Hz pwm pin to get a modulated 50Hz to drive mosfets connected to a transformer in a push-pull configuration. A/D conversion of the the output voltage can act as feed back to adjust the duty-cycle ( not yet implemented in this code). */ pulse = portb; pulse.0 = ~ pulse.0; pulse.1 = ~ pulse.1; portb = pulse; pir1.1=0; //clear TMR2 to pr2 match interrupt flag } void load_duty_cycle(void) { ccpr1l.7 = duty_cycle.9; ccpr1l.6 = duty_cycle.8; ccpr1l.5 = duty_cycle.7; ccpr1l.4 = duty_cycle.6; ccpr1l.3 = duty_cycle.5; ccpr1l.2 = duty_cycle.4; ccpr1l.1 = duty_cycle.3; ccpr1l.0 = duty_cycle.2; ccp1con.5 = duty_cycle.1; ccp1con.4 = duty_cycle.0; } // The main code configures the pwm registers void main() { trisa = 255; trisb = 0; //configure port B as output trisc = 0; // portc as out put portb = 1; //set port B to 1 portc = 0; //clear portc // enable interrupts intcon.6=1; //enable peripheral interrupt intcon.7=1; //enable global interrupt pie1.1=1; //tmr2 to pr2 match interrupt //configure the ccp1con register to enable PWM module. /*ccpxm3:ccpxm0: mode select bits<3:0> 11xx = for PWM mode. */ ccp1con=0b00001100; // //PWM period=[(PR2)+1]*4*Tosc*(TMR2 prescaler value) /*our pmw period is 10ms(100Hz),Tosc is 1/1000,000Hz & prescaler is 16.For which PR2+1 works out to 156.25. Lets round it to 156 & make PR2 to 155. */ //load the period value into pr2 register. pr2 = 155; /*timer2 control register we have selected bit6-3...(0000) 1:1 for post scaler bit2.....(1) timer2 on bit1-0...(11) prescaler is 16 */ t2con = 0b00000111; /*PWM duty cycle = (ccpr1l:ccp1con<5:4>)*Tosc*(TMR2 prescaler value) Here i have taken 2ms as an example value for duty cycle, Tosc & pre- scaler are same as above.We will get 10 bit values when we work with larger duty cycle but for our example we get the value as 125. */ //load the duty cycle values while( 1 ) { int b0; for(b0=1;b0<563;b0++) { duty_cycle = b0; load_duty_cycle(); delay_ms(9); } } } Regards Raghunathan
  12. Well if they have a time/resource constraint, I would prefer they concentrate on getting a compiler for the 24bit device. Regards Raghunathan
  13. Thanks to Dave & Pavel, The 16F1937 is very attractively priced, so planning of using them in my new projects. Regards Raghunathan.
  14. Hi Dave, Do you intend to support the 16F193X series devices ? If so How soon? Regards Raghunathan.
×