I need to make 16 AD measurements rapidly and to give this array of measurments a timestamp.
This package of 16 measurements is then repeated 300 times
and the time in ms or us is needed between the present and the very first package.
Can that be done in a smart way in Flowcode
with simplicity and speed
perhaps based on the internal processor clock ?
Best regards
BO
Exact timestamp on AD measurements ?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Exact timestamp on AD measurements ?
Hello,
If I were doing it I would probably do something like this.
Create a 16/32-bit count variable and initialise it to 0.
Enable a timer interrupt based off the internal clock, preferably a 16-bit timer such as Timer1 on an 8-bit PIC.
Inside the timer interrupt macro increment the count variable.
When taking ADC samples first take a copy of the count variable and the timer count register, this then makes up your time stamp.
Say the timer interrupt was interrupting at 1Hz (probably pretty unlikely unless you can provide the exact crystal frequency required).
The timer count register would represent 1:65536th of a second (16-bit timer)
The count variable would be the number of seconds.
A 16-bit count variable would give you a max time period of 18.2 hours with a 1s interrupt rate.
A 32-bit count variable would give you a max time period of 139 years with a 1s interrupt rate.
If I were doing it I would probably do something like this.
Create a 16/32-bit count variable and initialise it to 0.
Enable a timer interrupt based off the internal clock, preferably a 16-bit timer such as Timer1 on an 8-bit PIC.
Inside the timer interrupt macro increment the count variable.
When taking ADC samples first take a copy of the count variable and the timer count register, this then makes up your time stamp.
Say the timer interrupt was interrupting at 1Hz (probably pretty unlikely unless you can provide the exact crystal frequency required).
The timer count register would represent 1:65536th of a second (16-bit timer)
The count variable would be the number of seconds.
A 16-bit count variable would give you a max time period of 18.2 hours with a 1s interrupt rate.
A 32-bit count variable would give you a max time period of 139 years with a 1s interrupt rate.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
Re: Exact timestamp on AD measurements ?
What about the RTCC (Real-Time Clock/Calendar )? Some PIC have one included. If the timestamp is in seconds or minutes .... it's nice to use.
Is there a samplecode to use microchips rtcc?
Is there a samplecode to use microchips rtcc?