Yes.
I do like text editors with syntax highlighting but even windows notepad will work. If I remember correctly that is what Melanie uses, just plain 'ol notepad.
Yes.
I do like text editors with syntax highlighting but even windows notepad will work. If I remember correctly that is what Melanie uses, just plain 'ol notepad.
Dave
Always wear safety glasses while programming.
Goes to show then...........If I remember correctly that is what Melanie uses, just plain 'ol notepad.
Dave
Ah, almost forgot, the Badger re-appeared last night I'm very pleased to say.
Below is a part of a simple little program I've been experimenting with to generate a 'random' pause but of known maximum and minimum time period(average maximum wait about 12secs for the LED to flash as the program stands).
The pause occurs randomly but because there are a maximum of 65535 'lenghts' if you will of a given time (be it clock cycles etc (I'm not sure how RANDOM works) it should be possible to my mind to work out how long the longest and shortest pause times will be when they occur (1 or 65535 lenghts) I think.
So my question is this: How long does it take the PIC processor to calculate 1 lenght? At the moment the maximum and minimum pause times occur at 12secs max 1sec min.
I hope this makes sense
DaveCode:X VAR WORD main: RANDOM x PAUSE X /4 HIGH PORTA.2 PAUSE 1000 low PORTA.2 GOTO MAIN:
Last edited by LEDave; - 8th July 2010 at 00:22.
Can you setup a LCD or have the value of x sent to a terminal? I would think you should have at times a longer pause than 12 seconds??
You may want to look at this also.
http://www.picbasic.co.uk/forum/showthread.php?t=9350
Dave
Always wear safety glasses while programming.
Hi mackrackit,
I've been working really hard on this. I've taken your idea of:
And done this:Can you setup a LCD or have the value of x sent to a terminal?
What I've done is change the original code to measure the time the LED is on rather than measure the time the program was 'PAUSED' because to my mind you can only use 'PULSIN' on a active pin. I've then tried to output that 'PULSIN' number using 'SEROUT2' to the Serial communicator.
It nearly works I think, what it does is output a series of zeros, instead of the time in micro_secs. I suspect I've made an error here:
I think it could be the Decimal value of Z that's causing the problem (I hope) being as it should be measuring in blocks of Micro_secs.Code:SEROUT2 PORTC.3, 16780, [DEC Z, 10 ,13] 'The measured RANDOM time sent to S/Communicator
Here's the program, I feel I'm close, but am I?. If you could look the program over and give me a pointer that would be really appreciated. The chip is a 16F684.
DaveCode:ANSEL = %00000000 'Disable analog select so ports work as digital i/o. CMCON0 = %00000111 'Disable analog comparators. TRISA = %00000000 'Set PORTA as OUTPUT. PORTA = %00000000 'Set PORTA pins all low. TRISC = %00000000 'Set PORTC as OUTPUT. PORTC = %00000000 'Set PORTC pins all low. DEFINE OSC 4 X VAR WORD 'Number between 1 & 65535 Y var WORD 'Scaled down value of X Z VAR BYTE 'The PAUSED value of Y in 10us Increments main: RANDOM X 'Random number between 1 & 65535 LET Y = (x /14) 'Scaled down value of X HIGH PORTA.2 'LED PORTA.2 lights up PAUSE Y 'LED on for time period of RAN_X_OVER_14 PULSIN PORTA.2,1,Z 'The paused RANDOM time period stored in VAR Z SEROUT2 PORTC.3, 16780, [DEC Z, 10 ,13] 'The measured RANDOM time sent to S/Communicator 'in 10us incremets low PORTA.2 'LED off GOTO MAIN: 'Do it all again
Last edited by LEDave; - 8th July 2010 at 21:47.
Ah, have I got 'PULSIN' in the right place in the program? Might it be better in front of HIGH PORTA.2 ?
Nope, still outputting zero's.
The manual says of zero's:
Now I'm thinking the pulse must happen because the LED lights and with a 'RANDOM' delay but could it be to big to measure?If the pulse edge never happens or the width of the pulse is too great to measure, Var is set to zero
How big is too big to measure for a pulse?
Dave
Last edited by LEDave; - 8th July 2010 at 23:20.
As far as I know PULSIN is for reading a pulse on a pin from the outside not a pulse from the inside.
It has been a long day so maybe I am missing something... What exactly are you wanting to do?
Dave
Always wear safety glasses while programming.
Bookmarks