Continue to Site

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.

  • 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.

Writing to database

Status
Not open for further replies.
Wow, that is awesome!!

I'm gonna try to look into pure C coding. And you're totally right that the Arduino IDE hides all that good stuff. I have made a small start, I did the uart initializations by writing directly to the registers. But i use this within the Arduino IDE.

Had work and stuff, so couldn't get a chance to test fully microtime with C. But i did test stopwatch, and still got varying time values. For the same 1000ms, i got a maximum of 2ms deviation, which isn't what i want. I feel I can be more accurate, until then I won't settle lol

I was looking into getting the database to add the microsecond timestamp and then I'll check the accuracy of that
 
Alright, here is the same C program to receive the serial data, but i changed the Arduino code like I said i would. I used a compare timer, and here are the results.
This is the C program that uses "now" lol. Surprising results coz i read, and even as misterT mentioned, stopwatch is the way to go for such a thing.

Did a test earlier, but didn't have time to post it, got a bit busy.

Again, ignore the nonsense, and look at the interval. I set it for 1Hz
new timing 2.jpg

Results are currently good. I will try some more tests working the a higher freq, and increasing the bps. Hopefully the results will be good as well :)
 
Why all the records are exactly the same? Even all the T1 and T2 values are identical.. do you have a bug in your code?

EDIT: Sorry, my mistake. The numbers are not identical. The change is only one digit because the timing is so accurate. Hard to spot the changing digit. That is why I first thought they are identical :)
 
Last edited:
Well, it seems, the pc has reached its limits when it comes to even reasonably accurate microsecond timing of events.
My pc can't handle anything above 10Hz! the deviation in time between each pulse at 10Hz is too much.

I've been working, and I've done some code for the arduino to capture the time between events.
Using the timers, I send the TCNT value to the pc with very accurate results. But I need to trim down the code, to avoid wasting clock pulses on nonsense.

I'm currently sending data at 115200 and at 1Khz it seems perfect
:)
 
Well, it seems, the pc has reached its limits when it comes to even reasonably accurate microsecond timing of events.
My pc can't handle anything above 10Hz! the deviation in time between each pulse at 10Hz is too much.

It is the operating systems fault. I think normal windows and linux clocks its task switching at 100Hz. There is too much code between hardware and your custom software that it is impossible to get accurate timing.
 
It is the operating systems fault. I think normal windows and linux clocks its task switching at 100Hz. There is too much code between hardware and your custom software that it is impossible to get accurate timing.

Yeah, its so bad at timing its not funny. I have realized i need to use low level code in order to get the timing correct, but that's difficult to accomplish - I've spoken to some programmers already.


The code I've written for the Arduino, could possibly yield me a result that has the potential to work at 1.5MHz with sending the time between each pulse to the pc over serial.

I want to make it into a neat little library, I'll post it when I'm done with it

:)
 
I'm taking a long time with the library. Between work and me wanting the library to have good functionality, it is time consuming. Will hopefully have it done soon though :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top