Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Robotics Chat


Robotics Chat Specific to discussions about robots and the making of.

Reply
 
Thread Tools Display Modes
Old 9th December 2007, 08:44 PM   (permalink)
Default Port b output whilst reading porta.

I am a Noob but I am trying to learn from the datasheet and strugling.

I want to read in 5 pulses and then output one pulse for 1.5 seconds.
I can do both myself but I can not do them simultaneous. My program is a right mess now so I am going to start again. I have not used tmr0 yet but I am wondering if that is how I do it.
Currently I have F84 and F628 to choose from.

1....Count in five pulses
2....Now output a 1.5 sec high
3....Go back and read in five pulses but carry on output until 1.5 secs ends.
4....If five pulses are in before 1.5secs are over then refresh output back to 1.5secs and start output again.

My main problem is that I do not know how to carry on running my program whilst outputting and checking output to see if the 1.5secs are over.


Thank you
ukmxer is offline   Reply With Quote
Old 10th December 2007, 05:21 AM   (permalink)
Default

Quote:
I have not used tmr0 yet but I am wondering if that is how I do it.
Yes, use one of the timers to trigger an interrupt routine at a set rate; say 0.1 second. Then have a variable called COUNTER that you set to 15 (decimal) in your main routine when a string of 5 pulses is detected.
In your interrupt routine you'd decrement COUNTER if it is not zero and also output a "high" for the pulse. If COUNTER is zero, you'd just output a "low" for the end of the pulse (no decrementing COUNTER) and exit.
__________________
--- The days of the digital watch are numbered. ---
kchriste is offline   Reply With Quote
Old 10th December 2007, 06:40 AM   (permalink)
Default

Thank you for your guidance.

Is an interrupt routine something you code yourself or is it something you call that is already resident in the chip.

Going to work now so hope to read this later.
ukmxer is offline   Reply With Quote
Old 11th December 2007, 01:59 AM   (permalink)
Default

You code it yourself. You also have to set the PIC to generate interrupts when the timer overflows etc so your routine will run at a set interval. Look at the PIC docs for the INTCON, PIR1 and PIE1 registers for more info. Section 8 of the Mid-Range MCU Family manual has more details:
http://ww1.microchip.com/downloads/e...Doc/33023a.pdf
__________________
--- The days of the digital watch are numbered. ---
kchriste is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Need help badly on Inchworm and MPLAB thushy Micro Controllers 14 11th March 2007 06:05 PM
Effects stephenpic Micro Controllers 6 19th January 2004 11:57 AM
VERY low voltage on output pins, please help! New2PIC Micro Controllers 1 18th January 2004 03:21 AM
Question about reading bits from ports. Blueteeth Micro Controllers 5 5th January 2004 01:08 PM
Parallel Port output device to control low Voltage equipment Gabrielle Electronic Projects Design/Ideas/Reviews 8 7th August 2003 02:18 AM



All times are GMT. The time now is 04:28 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.