example: i want 234 on-off software states on a port and, at the same time, 400 on-off software states on another port. Both start and finish at the same so with different pauses but with not reciprocal influences, impossible?
example: i want 234 on-off software states on a port and, at the same time, 400 on-off software states on another port. Both start and finish at the same so with different pauses but with not reciprocal influences, impossible?
lutherblisset,
No not impossible at all, but it may depend on the clock speed that your micro is running at, AND your ability to dream up the code to make it happen
A couple of possibilities (depending on whether the two pulse rates are symmetrical with regard to themselves)
What I mean by that is... is the pulse rate for the first pin a fixed rate? can it be handled by a PWM peripheral within the PIC? (and the same question holds for the second port, is its rate also fixed and could it be handled by a second PWM peripheral?)
You could also use a couple of timer peripherals within your micro along with timer interrupts. Letting one timer control one output and the other timer control the second output. If the pulse rate is not symmetrical you could pre load each timer as it expires (and interrupts your micro telling it to change the state of the given output) with a new and if necessary, different value, so that it will roll over and interrupt the micro at a different time to change the output state as necessary to meet your requirements.
Can the PIC be running at a high enough clock rate such that it has time to set one port.pin high then go and set the second port.pin high then come back and set the first port.pin low then wait a given amount of time and then set the second port.pin low, etc. etc.
All the while keeping what ever time base and pulse rate that your application demands??
From my perspective (non professional programmer) Nothing ever happens "AT THE SAME TIME" within the PIC and the various port.pins. There will always be some delay or latency from one act (program directive) and the next, though this delay may be so short (a few microseconds) that it is as though it were "at the same time". The question for you to answer is, is the latency or delay (dependent on clock speed and program execution) "good enough"??
Using assembly code (or "machine language" as I used to call it) as opposed to PICBASIC code at certain points in your program may also shorten the latency and make things happen closer to "the same time".
Others may have better insight and you should try and provide more information as to time duration, pulse rate, pause duration, chosen microcontroller, etc. etc. so that we have enough information to better answer your specific question.
Just a few things to consider...
Last edited by Heckler; - 19th January 2016 at 17:25.
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
hi heckler, thank you for the answer. Every pulse have its rate time, i need pauses of of 200-400 microseconds (picbasic pauseus) between every single pulse. But if the first train with 300 pulses start and finish after 10 seconds the second train with 500 pulses start and finish in synchrony with the first after 10 seconds too. Maybe you think at the pic with the hardware pwm but with them i think its impossible to set the number of the pulses.....
What's the shortest time?
What's the longest time?
What's the needed resolution, ie will there be times that are 345us or is 200, 300, 400, that sort of thing enough?
What kind of error can you accept?
How many "channels"?
Since you're talking microseconds it's either going to get "in the ballpark" or very very tricky if you need precision on many "channels".
Do you have a PIC this needs to run and if so which one and at what Clock frequency is it runing? Or can you select the most optimal PIC for the task?
I'm not pretending I have an ready to go answer but it's of no use to either of us describing possible solutions which clearly won't work once we know the details.
So, more details are needed.
/Henrik.
the resolution its non critical, the range is from 200 to 600 us, at 50 microseconds steps possible rate ( 100,150,200 etc). i need two channels, the best i have is a pic16f876a with 20mhz quartz.
Last edited by lutherblisset; - 19th January 2016 at 18:38.
luther,
In your earlier comment you mentioned the word "pauseus" which is the picbasic command to halt the micro for a specific number of microseconds. Please be aware that this "pauseus" statement will prevent the micro from doing anything else. (except being interrupted, I believe)
The same goes for the "pause" statement. The micro is halted or "paused" for the specified duration. It will NOT continue on to the next instruction until the pause expires. So you may want to consider implementing the use of timers and interrupts. Such that the pic will just be servicing the timer interrupts and changing port.pin states as needed when the count of timer rollovers reaches your desired pulse duration.
At this point, if I were you, I would get out my breadboard, a PIC and start blinking some LED's (or pulsing some port.pins and watching the effect (time duration) on an O'Scope) and developing some code building blocks.
For me that is the only way to get going and learn.
How do you eat an elephant?? One bite (or is it Byte?) at a time!
good luck and keep asking questions
The more specific the better and with whatever code you have implemented so far.
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Bookmarks