• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Timing Issue? or I'm over my head again!

Status
Not open for further replies.

RonDumas

New Member
I just finished a project in Basic Pro,pic 16f876 where I read a pot on portA.0 and connected 4, 7-segment LED's to PortB.0-6,and portA.1-4

The pot position was stored in a variable where I then multiplexed it out to the LED's.

It all worked well.

I now want to connect an ultrasonic rangefinder to the pic, and store the data in a variable to put out to the LEDs.
I'm using pulsout and pulsin commands for the rangefinder. The problem I 'm having is the 4, 7-segment LEDs are now lighting up and going off about 3 times/sec. instead of strobing to look continuous.

My question is are there timing issues to using the pulsout/in commands that may be making the program run too slow to allow the multiplexing of the LEDs?
 

Eclipsed

New Member
Not sure what you mean by timing issues, but when using pulsin or pulsout program execution halts until those commands are done.Maybe you could post some code.
 

StupidDum

New Member
perhaps when your ultrasonic findranger is 'doing something', it affect the the status of the port that is connected to your LED
 

Exo

Active Member
RonDumas said:
I just finished a project in Basic Pro,pic 16f876 where I read a pot on portA.0 and connected 4, 7-segment LED's to PortB.0-6,and portA.1-4

The pot position was stored in a variable where I then multiplexed it out to the LED's.

It all worked well.

I now want to connect an ultrasonic rangefinder to the pic, and store the data in a variable to put out to the LEDs.
I'm using pulsout and pulsin commands for the rangefinder. The problem I 'm having is the 4, 7-segment LEDs are now lighting up and going off about 3 times/sec. instead of strobing to look continuous.

My question is are there timing issues to using the pulsout/in commands that may be making the program run too slow to allow the multiplexing of the LEDs?
It seems to me these pulsein commands just sit around taking processing cycles doing nothing while it waits for a pulse to arrive...

Your F877 has a CCP module - I would use its capture function
Look at the datasheet on how to do this

Capture sets Timer 1 running and then allows your program to continue running normally, but when a signal change is detected at the CCP input it will store the Timer1 value at that moment. with these values you should be able to calculate the time

you could also try and generate a Timer 0 interrupt for example 50 times a second, and use this interrupt to multiplex your leds
 

RonDumas

New Member
Thanks for the advice. I'll try the CCP idea. I did tinker with the TMRO interrupt a little but had no luck.I think I need a tutorial on interrupts.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top