Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by ra68gi

  1. Hi runep, Basic stamp is very good for beginners and hobbiest not for serious professional. Now that you have a feel of the microcontrollers try the power of source boost C compiler. Its compact code resulting in much less program memory space and improved speed are some of the major advantages over B.S. Down load a free version of source boost, with which you can write code upto 2k that too on any PIC microcontroller of your choice. The source Boost ide has got a beautiful simulator, very useful for beginners to check if your code is functioning properly. If you wish you can integra
  2. I have never used extern in my programming so far. But i think you should have No problem defining the bits of a global character variable. Just remove "extern char error_flag;" in your functions. Declare the error_flag as global by writing them outside the functions. char error_flag; #define BCD_fail error_flag.0 Pls let me know if your program is working properly & if the flag bits work as expected. Regards, Raghunathan.
  3. There seems to be a lot of people wanting to use PWM module to control their servos. I think i should make a project and post it on my thread. Regards, Raghunathan.
  4. You definitely can call it PWM signal. A PWM signal has a period value and a duty cycle value. In the case of servo the period is 20ms and to generate this period you need to load the PR2 register with the appropriate value given by the formula in the data sheet [(PR2)+1]*4*Tosc*(TMR2 prescaler value). Similarly the duty cycle for the servo can vary from 1ms to 2ms & this value is calculated as a 10 bit value from the formula (CCPR1L:CCP1CON<5:4>)*Tosc*(TMR2 prescaler). You will see that the percentage of ON time & OFF time is controlled or changed by changing the dutycycle
  5. Yes, As cac says, servo motors can't be used for precise angle measurements. You can use stepper motors for such applications. You can experiment with your servo by varying the pulse width from 1ms -2ms and verifying the postion/ angle. repeat the experiment several times to see if your servo behaves the same always. If its consistent and satisfies your purpose, use it. Stepper motors have higher torque and a very precise angular movement. The only draw back being the complex drive circuitry. Servos has no such problems. regards Raghunathan.
  6. robomaker, This subject has been discussed in an earlier threadservo motor control Here i have given examples using the delay commands of compiler. If you still wish to generate your pulses using PWM module, you can't use a crystal larger then 1.25mhz to generate 50 hz pulses. I have a sightly different program which generates 100hz pwm for inverter application, but you can modify it for 50 hz. you can change the duty cycle value for the various sero positions. PWM generation for low frequency regards Raghunathan.
  7. I understand that you are using int0 or interrupt on RB0(INTE) to read the pulse, but where is the option register config bits? YOU need to set the edge trigger bit INTEDG of option register (rising edge or falling edge). Regards. Raghunathan
  8. Measuring the number of pulses for 1sec(RPS) & then multiplying with 60 to get RPM will result in a lot of error especially when the RPM of the motor gets low, say 300 RPM. Let's say we get 50 RPS on one occasion & 51 RPS in the next then your RPM meter will jump from 300RPM to 360 RPM which is unacceptable. To get a precise RPM reading you need to determine the time between two pulses. Once you have this time t, frecuency can be calculated using f=1/t. If this results in floating point calculation then make it 1000000/t or try using the fp library available as down load. You ca
  9. Hi guys, Some more progress in the inverter project. I have included the adc module, adc is performed on the battery supply, the adc value is checked for low battery, annunciation is done by switching portb pins. If the the battery voltage gets too low, the inverter is switched off & a trip flag is set, which gets cleared only on resetting the micro. adc is also done on inverter feed back voltage. The initial (minimum) pulse width is made 3ms. As the inverter feed back voltage drops( due to loading or drop in battery voltage) the adc value will also drop. The difference in the drop betwee
  10. Now you raise the bar to what he wants: The only issue left is do you believe that the code does what he described? You should be able to figure this one out yourself. I am happy to accept any conclusion you honestly arrive at. <{POST_SNAPBACK}> O.K cac, I will keep my word. Send me your contact thro' a personal mail. I will not promise any time frame. But cash definitely will reach you. Regards, Raghunathan.
  11. hmmm, Where are you? you are the only one who can save me from losing a $100. Is this what you want? Raghunathan.
  12. Only after testing it fully will i post it. When i post my project i definitely will warn them of dangerous voltages and precaution they need to take. Regards Raghunathan.
  13. Programming is not difficult. You write your code and post it, we will help you debug it. This forum is a very friendly one & iam sure there will be many people to help you. If you are a beginner in programming then see this thread.."pic micro programming in boostc for beginners". Its got examples on using PIC's adc. Regards Raghunathan.
  14. manasir, You have asked to many questions at one go. But let me try answering it one by one. I have a scheme for IR object detection. See if its useful. If you feel you need to use your IR receiver which gives analog output then you need to use the adc. 1. What IR transmitter_receiver are you using? I guess 38 khz must be the carrier frequency for IR communication. This carrier frequency has to be modulated with data signal. I have used a simple 555 timer ic to generate the 38Khz for Driving an IR LED( you should get an IR LED that has max sensitivity in this freq range, others may w
  15. I need $50.00.Which will get what they need sooner? <{POST_SNAPBACK}> cac001, I will give you $100.00 if you write a code from what he has described. Raghunathan.
  16. Hi guys, Its working! I forgot to configure the ccp1con register to PWM mode. The modified code is written below. The ccp module is a superb hardware function with which we can obtain true multi tasking feature or call it parallel processing. With built-in adc & PWM modules one can construct wonderful automatic feed back control systems. This project is a design of an inverter which will convert 12v dc to 230v, 50Hz ac using iron core transformer similar to the APC UPS( uninterrupted power supply) that powers the computers. Now i have successfully produced the 50Hz 180 degree ou
  17. Hi guys, Is it possible to view or see the state of pwm pin( RC2) on the source boost simulator? I have a sample code written for PIC16F72 at 1Mhz. When i built the code i didn't see the the change on the simulator. Have i missed any thing in the code? #include <system.h> // Set clock frequency to 1MHz. #pragma CLOCK_FREQ 1000000 //set configuration fuse. #pragma DATA _CONFIG, _XT_OSC & _WDT_OFF & _CP_OFF & _PWRTE_OFF /*Interrupt service routine (ISR).On timer2 interrupt, program will jump to this code location. */ void interrupt( void ) { char pulse; /
  18. Sorry Elvis75, My code is for PIC16f series of micro & not 18f. I have not used the 18 series, so can't help. Please look into the microchip data sheet & set the bits associated with INT2. Looks like int2 works on RB2 which is also an anolog input. So make sure to configure it to digital mode before you use it. On seeing the data sheet this is what i found. The registers and bits associated with int2 are.. 1. rcon- & the bit rcon.7 has to be cleared 2. intcon- & the bit(gie) intcon.7 has to be set. 3. intcon2- & the bit(intedg2) intcon2.4 ( make your c
  19. Elvis75, As far as i know we have got external interrupt on only one pin ie. RB0/INT pin & its edge triggered( either rising edge or falling edge decided by option_reg.6. This interrupt can be enabled by setting the INTE bit(intcon.4).The associated interrupt flag for this is INTF or intcon.1, which should be cleared in the interrupt service routine before re-enabling the interrupt. Next we have got portb input change interrupt. This can happen only on portb pins 7,6,5, & 4. So a change in state of RB2 will not cause an interrupt to occur. To use this interrupt you need to en
  20. Instead of using macros why don't you try direct bit access. Its much more easy and universal. You can use it on any compiler. say you want to set RB port change interrupt enable bit (RBIE), simply write.. intcon.3 = 1; say you want to clear the RB port change interrupt flag bit in your ISR then.. intcon.0 = 0; will do the job. you want to enable the global interrupt enable.. intcon.7 = 1; You dont need to use the tmr0 interrupt flag in your code if you are generating an interrupt only by a switch ( or change in portb state).
  21. /* timer0_interrupt.c In this project we make the timer0 of the PIC microcontroller to measure a time interval of 250 micro seconds.The timer0(tmr0) is made to generate an interrupt every 250us.We then count 4000 of such interrupts to get a precise 1 second interval. We change the state of an LED once we finish counting 4000. So the LED will be lit for a duration of 1sec & off for the next 1sec & it keeps switching on & off. The idea behind this project is to help you understand as to how the tmr0 can be set to generate an accurate 1sec interval.This code will turn out to b
  22. Thanks Andrew, for that nice bit of information. Regards Raghunathan
  23. I believe 1 us at 4 MHz is 1 cycle, so if you wanted to be safe, you could put a nop there instead. I don't see the purpose either, so it would still be fine to run at other frequencies. <{POST_SNAPBACK}> Yes. I did see the 1us delay in the code. I will try replacing it with a nop and see if it works. Regards Raghunathan,
  24. To change the delays in rs232_driver.h file is a very difficult task for me. Since i haven't understood the code completely. I will sit back and wait for the release of v6.70. Mean while i will keep working with 20Mhz chips. At this stage i think its going to be good form me see some asm program examples(Microcontrol'n Apps written by David Benson & serial communication by Roger Stevens) ) Regards Raghunathan.
  25. The above code builds when i changed the clock frequency to 20MHz. Does that mean i wouldn't be able to implement SB's suart or huart lib on PICs operating on less than 20MHz ? Is there anyway i can get it to work with a 4MHz clock ? Raghunathan
  • Create New...