Jump to content

ra68gi

EstablishedMember
  • Content Count

    229
  • Joined

  • Last visited

Everything posted by ra68gi

  1. You can also try this.. unsigned int x = 0xf0f1; unsigned char xlo; unsigned char xhi; xlo = x; xhi = x / 256; you can check it with the simulator.
  2. Less software required, you are not tieing up the processor to some bit bashing routine. Make cyclic buffers for your RX and TX data and service in interrupt time. <{POST_SNAPBACK}> Hi Picxie, I have not used the hardware uart so far. I suppose Huart will take less code space compared to Suart. Picxie, can you explain the second advantage regarding servicing in interrut time with any example. Thanks, Raghunathan.
  3. Hi guys, Can any one tell me the advantages of using hardware uart over software uart? Raghunathan.
  4. Yes, for measuring frequency in the range you have mentioned its fine, but if your frequency is less then 15 hz then i think my technique will be better. Infact you can get very good accuracy upto 300hz with my method. Trying to use the highest possible clock frequency will result in best accuracy. Make sure that the time period of your signal is larger then the time taken to attend to the ISR.If a second capture pulse occurs before you read the value from ccpr, the old captured value is over written with the new captured value, resulting in wrong frequency value. Regards Raghunathan.
  5. OrmatEli, Why don't you start a new thread on this topic? Don't you think this thread has got a bit too old & long? In the capture mode the 16 bit value of the timer1 gets latched to the ccpr2h & ccpr2l registers every time a ccp pin senses a pulse. When do you intend to start the timer1? in the first capture interrupt or do you just wish to keep it running right from the beginning? How will you know if the timer1 has over flowed or not ? are you setting the timer1 interrupt also? I had written code for a similar project. It lacks explaination. but if you follow it closely you will
  6. Hi Pavel, Generally the libc.lib gets automatically linked & i have never added exept for the fp lib on my SB6.6. Then why is this happening? Does he have to add the libc.lib for every project he makes?
  7. I am sorry. I got a bit confused with the ccp module. Yes as a timer the settings for the tmr2 module looks fine. But try t2con = 0B01111111; & disable the ccp module. Regards Raghunathan.
  8. Hello emte, We can't test it until you give us your code. I can see you have used the period register(pr2) & so i assume you are using the tmr2 in the PWM mode. Have you configured which mode you are using in the ccpcon1 register in your main()? I am talking with respect to 16F pics but that should hold good even for pic18. Also bit 7 of t2con is unimplemented & the data sheet suggests that you write it as 0 instead of 1. make it.. t2con = 0b01111111; I assume you are using 1:16 post scaler & prescaler. Regards Raghunathan.
  9. 60% of your project is already here...programming pic micro in BoostC for beginners. Atleast for the rest of the project you need to make some effort. Use my code as a template & make adjustments by adding serial routines. You can use the same wiring circuit details i have mentioned. I did it on a bread board. You too can do the same. Good luck! Regards Raghunathan.
  10. Did you first check it up on a hyper-terminal? Regards Raghunathan
  11. Dave, i have version 6.6. In the above code example you have not use sprintf32 function, which is used for long. I think thats available only in version 6.7. Regards Raghunathan.
  12. Dave i got lprintf("%u",x); to work upto 65535. but i was not successful in converting it into string using sprintf32 & displaying it using lprintf. I first tried lprintf (sprintf32(x)); & it didn't work. Can you please show me how its done. <{POST_SNAPBACK}> extract from the BoostC compiler user manual: unsigned char sprintf32( char* buffer, const char *format, unsigned long val ) Outputs a numerical value to a string in the specified format. The buffer must be long enough to hold the result. Only one numerical value can be output at a time. Declared in
  13. Dave i got lprintf("%u",x); to work upto 65535. but i was not successful in converting it into string using sprintf32 & displaying it using lprintf. I first tried lprintf (sprintf32(x)); & it didn't work. Can you please show me how its done. Regards Raghunathan.
  14. Use: lprintf("%u",x); Or use sprintf32 to convert number to a string and then display using lprintf. Regards Dave <{POST_SNAPBACK}> Thanks Dave, I searched the SB user's manual but didn't find sprintf32. is it written this way... lprintf (sprintf32(x)); ? Raghunathan.
  15. Hi guys, How do i display values larger than 32767 on LCD . beyond this value the lcd displays negative numbers & it starts to wrap(+32767 to-32768). I am using the boostC lcd command lprintf("%d",x); I had declared x as unsigned int. I would like it to display upto 65535 or probably a long variable. Regards Raghunathan.
  16. Here is a example for a flow control regulator. Regards /J├Ârgen void DFlowPID(void) { float e; // The controller error float up; // Output signals float awc; // Anti windup compensation float IState; // I state (integrated error) float DState; // D state (last error) short Ticks; // Ticks short ScanRate; // Scan rate ScanRate = XXX; Ticks = 0; // Check if time to run if ((++Ticks % ScanRate) != 0) return; // Get current control parameters
  17. Are you talking about proportional, integral , derivative used in feed back control systems? Rigt now i am working on a project with feed back control using PIC. If you are interested i will post it & we can discuss. Regards, Raghunathan.
  18. If you are looking for an example of multiple interrupts, i can give you an example i am right now working on. Its an frequency/RPM meter. It measures the time interval between two pulses of a optical or proximity sensor. There are two interrupt generating source, they are timer1 over flow flag & ccp capture flag. An LCD is use to display the RPM. I am using PIC16F72. I have tested it on the SB simulator & it works fine. code.. #include <system.h> #include "lcd_driver.h" // Set clock frequency to 4MHz. #pragma CLOCK_FREQ 4000000 //set configuration fuse. #pragma DATA _CON
  19. Thanks guys, I will start working on this project & will inform you of its progress. Reagards Raghunathan.
  20. Hi cac001, I am not having doubt on the communication part. My doubt is about the total bit weight and how i should calculate the total adc value. In the data sheet they say that the bit weight is in two's compliment. You say that i can make the choice. Then can I store the bit value in long var & use the same binary weight to the bits instead of two's compliment ? If i were to use the two's compliment, then i need to multiply the msb with 1/2, the next significant bit with 1/4 and so on, which will be very cumbersome. Will it not alter the precision in calculation if i used the binar
  21. Hi friends, I want to interface cirrus logic's cs5550 analog to digital converter to the PIC. The output adc result register is a 24 bit one. The most significant bit is the sign bit which will indicate whether the bit is + or -. The rest of the bit values are in two's compliment notation. ie. 1/2, 1/4, 1/8, 1/16, 1/32,.........& so on until the least significant bit. Is there any way in BoostC that i can load the value onto a variable at one go instead of having to multiply these value and add them up ? Like say for binary we write 0bxxxxxxxx, for hex its 0xXX . Those of you wh
  22. Being instigated by an earlier post on this topic i set out to write a program for this project. I have used the capture module of PIC16F72 to capture the pulses from any sensor( optical or proximity ) connected to the engine/motor. Its connected to the ccp pin RC2. I have used the timer1 to measure the time T elapsed between two pulses from which i calculate the frequency(1/T). The RPM is calculated & displayed on a LCD. This will display the instantaneous RPM value only. I have not done any averaging to keep coding simple. This project will be posted on my thread once i have tested
  23. Hi guys, I am using the ccp module in the capture mode to measure time interval between two pulses or (frequency) of a signal. This is possible if the period is smaller than the 16 bit timer1 value. in the case of low frequency one needs to count the no.of interrupts the timer1 produces and multiply that with 65536 & add that value to the final timer1 value. So i decided to use capture module just to generate an interrupt when the ccp pin reads a pulse( either falling edge or rising edge of thepulse) & i would read the tmr1 directly instead of the ccppr1h &ccpr1l. Now th
  24. /* digital_clock.c Now that you know how to configure the timer0 to generate accurate time interval, let's construct a digital clock that will display hours, minutes and seconds on six led segment display. We will use the same common cathode segment used in our earlier projects. We will use PIC16F72 for this project because it has 22 i/o pins. The main features of this project at a glance. a)Uses tmr0 for time keeping. b)We use PIC16F72 c)4MHZ crystal frequency d)six no. of 7-segment display, to display hours, minutes & seconds. e)two button switch to set hours and minutes. f)six BC547(NP
×
×
  • Create New...