Commit 17d365e7 by karudu

Väiksed parandused

parent 837bf1e0
......@@ -18,13 +18,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '0', '7',
'0', '0', '8',
'0', '0', '8',
'0', '0', '8',
'0', '0', '9',
'0', '0', '9',
'0', '1', '0',
'0', '1', '0',
'0', '1', '1',
'0', '1', '1',
'0', '1', '1',
'0', '1', '2',
'0', '1', '2',
'0', '1', '3',
......@@ -33,6 +33,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '1', '4',
'0', '1', '5',
'0', '1', '5',
'0', '1', '5',
'0', '1', '6',
'0', '1', '6',
'0', '1', '7',
......@@ -64,6 +65,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '2', '9',
'0', '3', '0',
'0', '3', '0',
'0', '3', '0',
'0', '3', '1',
'0', '3', '1',
'0', '3', '2',
......@@ -72,7 +74,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '3', '3',
'0', '3', '4',
'0', '3', '4',
'0', '3', '4',
'0', '3', '5',
'0', '3', '5',
'0', '3', '6',
......@@ -81,6 +82,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '3', '7',
'0', '3', '8',
'0', '3', '8',
'0', '3', '8',
'0', '3', '9',
'0', '3', '9',
'0', '4', '0',
......@@ -112,6 +114,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '5', '2',
'0', '5', '3',
'0', '5', '3',
'0', '5', '3',
'0', '5', '4',
'0', '5', '4',
'0', '5', '5',
......@@ -120,7 +123,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '5', '6',
'0', '5', '7',
'0', '5', '7',
'0', '5', '7',
'0', '5', '8',
'0', '5', '8',
'0', '5', '9',
......@@ -129,6 +131,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '6', '0',
'0', '6', '1',
'0', '6', '1',
'0', '6', '1',
'0', '6', '2',
'0', '6', '2',
'0', '6', '3',
......@@ -143,7 +146,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '6', '7',
'0', '6', '8',
'0', '6', '8',
'0', '6', '8',
'0', '6', '9',
'0', '6', '9',
'0', '6', '9',
'0', '7', '0',
......@@ -160,6 +163,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '7', '5',
'0', '7', '6',
'0', '7', '6',
'0', '7', '6',
'0', '7', '7',
'0', '7', '7',
'0', '7', '8',
......@@ -168,7 +172,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '7', '9',
'0', '8', '0',
'0', '8', '0',
'0', '8', '0',
'0', '8', '1',
'0', '8', '1',
'0', '8', '2',
......@@ -177,6 +180,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '8', '3',
'0', '8', '4',
'0', '8', '4',
'0', '8', '4',
'0', '8', '5',
'0', '8', '5',
'0', '8', '6',
......@@ -208,6 +212,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'0', '9', '8',
'0', '9', '9',
'0', '9', '9',
'0', '9', '9',
'1', '0', '0',
'1', '0', '0',
'1', '0', '1',
......@@ -216,7 +221,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '0', '2',
'1', '0', '3',
'1', '0', '3',
'1', '0', '3',
'1', '0', '4',
'1', '0', '4',
'1', '0', '5',
......@@ -225,6 +229,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '0', '6',
'1', '0', '7',
'1', '0', '7',
'1', '0', '7',
'1', '0', '8',
'1', '0', '8',
'1', '0', '9',
......@@ -256,13 +261,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '2', '1',
'1', '2', '2',
'1', '2', '2',
'1', '2', '2',
'1', '2', '3',
'1', '2', '3',
'1', '2', '4',
'1', '2', '4',
'1', '2', '5',
'1', '2', '5',
'1', '2', '5',
'1', '2', '6',
'1', '2', '6',
'1', '2', '7',
......@@ -273,6 +278,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '2', '9',
'1', '3', '0',
'1', '3', '0',
'1', '3', '0',
'1', '3', '1',
'1', '3', '1',
'1', '3', '2',
......@@ -304,13 +310,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '4', '4',
'1', '4', '5',
'1', '4', '5',
'1', '4', '5',
'1', '4', '6',
'1', '4', '6',
'1', '4', '7',
'1', '4', '7',
'1', '4', '8',
'1', '4', '8',
'1', '4', '8',
'1', '4', '9',
'1', '4', '9',
'1', '5', '0',
......@@ -319,6 +325,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '5', '1',
'1', '5', '2',
'1', '5', '2',
'1', '5', '2',
'1', '5', '3',
'1', '5', '3',
'1', '5', '4',
......@@ -352,13 +359,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '6', '7',
'1', '6', '8',
'1', '6', '8',
'1', '6', '8',
'1', '6', '9',
'1', '6', '9',
'1', '7', '0',
'1', '7', '0',
'1', '7', '1',
'1', '7', '1',
'1', '7', '1',
'1', '7', '2',
'1', '7', '2',
'1', '7', '3',
......@@ -367,6 +374,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '7', '4',
'1', '7', '5',
'1', '7', '5',
'1', '7', '5',
'1', '7', '6',
'1', '7', '6',
'1', '7', '7',
......@@ -381,7 +389,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '8', '1',
'1', '8', '2',
'1', '8', '2',
'1', '8', '2',
'1', '8', '3',
'1', '8', '3',
'1', '8', '3',
'1', '8', '4',
......@@ -398,6 +406,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '8', '9',
'1', '9', '0',
'1', '9', '0',
'1', '9', '0',
'1', '9', '1',
'1', '9', '1',
'1', '9', '2',
......@@ -406,7 +415,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '9', '3',
'1', '9', '4',
'1', '9', '4',
'1', '9', '4',
'1', '9', '5',
'1', '9', '5',
'1', '9', '6',
......@@ -415,6 +423,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'1', '9', '7',
'1', '9', '8',
'1', '9', '8',
'1', '9', '8',
'1', '9', '9',
'1', '9', '9',
'2', '0', '0',
......@@ -429,7 +438,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '0', '4',
'2', '0', '5',
'2', '0', '5',
'2', '0', '5',
'2', '0', '6',
'2', '0', '6',
'2', '0', '6',
'2', '0', '7',
......@@ -446,6 +455,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '1', '2',
'2', '1', '3',
'2', '1', '3',
'2', '1', '3',
'2', '1', '4',
'2', '1', '4',
'2', '1', '5',
......@@ -454,7 +464,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '1', '6',
'2', '1', '7',
'2', '1', '7',
'2', '1', '7',
'2', '1', '8',
'2', '1', '8',
'2', '1', '9',
......@@ -463,6 +472,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '2', '0',
'2', '2', '1',
'2', '2', '1',
'2', '2', '1',
'2', '2', '2',
'2', '2', '2',
'2', '2', '3',
......@@ -477,7 +487,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '2', '7',
'2', '2', '8',
'2', '2', '8',
'2', '2', '8',
'2', '2', '9',
'2', '2', '9',
'2', '2', '9',
'2', '3', '0',
......@@ -494,13 +504,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '3', '5',
'2', '3', '6',
'2', '3', '6',
'2', '3', '6',
'2', '3', '7',
'2', '3', '7',
'2', '3', '8',
'2', '3', '8',
'2', '3', '9',
'2', '3', '9',
'2', '3', '9',
'2', '4', '0',
'2', '4', '0',
'2', '4', '1',
......@@ -511,6 +521,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '4', '3',
'2', '4', '4',
'2', '4', '4',
'2', '4', '4',
'2', '4', '5',
'2', '4', '5',
'2', '4', '6',
......@@ -542,13 +553,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '5', '8',
'2', '5', '9',
'2', '5', '9',
'2', '5', '9',
'2', '6', '0',
'2', '6', '0',
'2', '6', '1',
'2', '6', '1',
'2', '6', '2',
'2', '6', '2',
'2', '6', '2',
'2', '6', '3',
'2', '6', '3',
'2', '6', '4',
......@@ -559,6 +570,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '6', '6',
'2', '6', '7',
'2', '6', '7',
'2', '6', '7',
'2', '6', '8',
'2', '6', '8',
'2', '6', '9',
......@@ -571,7 +583,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '7', '2',
'2', '7', '3',
'2', '7', '3',
'2', '7', '3',
'2', '7', '4',
'2', '7', '4',
'2', '7', '4',
'2', '7', '5',
......@@ -590,13 +602,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '8', '1',
'2', '8', '2',
'2', '8', '2',
'2', '8', '2',
'2', '8', '3',
'2', '8', '3',
'2', '8', '4',
'2', '8', '4',
'2', '8', '5',
'2', '8', '5',
'2', '8', '5',
'2', '8', '6',
'2', '8', '6',
'2', '8', '7',
......@@ -607,6 +619,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '8', '9',
'2', '9', '0',
'2', '9', '0',
'2', '9', '0',
'2', '9', '1',
'2', '9', '1',
'2', '9', '2',
......@@ -619,7 +632,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'2', '9', '5',
'2', '9', '6',
'2', '9', '6',
'2', '9', '6',
'2', '9', '7',
'2', '9', '7',
'2', '9', '7',
'2', '9', '8',
......@@ -638,13 +651,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '0', '4',
'3', '0', '5',
'3', '0', '5',
'3', '0', '5',
'3', '0', '6',
'3', '0', '6',
'3', '0', '7',
'3', '0', '7',
'3', '0', '8',
'3', '0', '8',
'3', '0', '8',
'3', '0', '9',
'3', '0', '9',
'3', '1', '0',
......@@ -653,6 +666,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '1', '1',
'3', '1', '2',
'3', '1', '2',
'3', '1', '2',
'3', '1', '3',
'3', '1', '3',
'3', '1', '4',
......@@ -667,7 +681,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '1', '8',
'3', '1', '9',
'3', '1', '9',
'3', '1', '9',
'3', '2', '0',
'3', '2', '0',
'3', '2', '0',
'3', '2', '1',
......@@ -686,11 +700,11 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '2', '7',
'3', '2', '8',
'3', '2', '8',
'3', '2', '8',
'3', '2', '9',
'3', '2', '9',
'3', '3', '0',
'3', '3', '0',
'3', '3', '0',
'3', '3', '1',
'3', '3', '1',
'3', '3', '2',
......@@ -701,6 +715,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '3', '4',
'3', '3', '5',
'3', '3', '5',
'3', '3', '5',
'3', '3', '6',
'3', '3', '6',
'3', '3', '7',
......@@ -715,7 +730,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '4', '1',
'3', '4', '2',
'3', '4', '2',
'3', '4', '2',
'3', '4', '3',
'3', '4', '3',
'3', '4', '3',
'3', '4', '4',
......@@ -732,13 +747,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '4', '9',
'3', '5', '0',
'3', '5', '0',
'3', '5', '0',
'3', '5', '1',
'3', '5', '1',
'3', '5', '2',
'3', '5', '2',
'3', '5', '3',
'3', '5', '3',
'3', '5', '3',
'3', '5', '4',
'3', '5', '4',
'3', '5', '5',
......@@ -749,6 +764,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '5', '7',
'3', '5', '8',
'3', '5', '8',
'3', '5', '8',
'3', '5', '9',
'3', '5', '9',
'3', '6', '0',
......@@ -763,7 +779,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '6', '4',
'3', '6', '5',
'3', '6', '5',
'3', '6', '5',
'3', '6', '6',
'3', '6', '6',
'3', '6', '6',
'3', '6', '7',
......@@ -780,13 +796,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '7', '2',
'3', '7', '3',
'3', '7', '3',
'3', '7', '3',
'3', '7', '4',
'3', '7', '4',
'3', '7', '5',
'3', '7', '5',
'3', '7', '6',
'3', '7', '6',
'3', '7', '6',
'3', '7', '7',
'3', '7', '7',
'3', '7', '8',
......@@ -797,6 +813,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '8', '0',
'3', '8', '1',
'3', '8', '1',
'3', '8', '1',
'3', '8', '2',
'3', '8', '2',
'3', '8', '3',
......@@ -809,11 +826,11 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '8', '6',
'3', '8', '7',
'3', '8', '7',
'3', '8', '7',
'3', '8', '8',
'3', '8', '8',
'3', '8', '9',
'3', '8', '9',
'3', '8', '9',
'3', '9', '0',
'3', '9', '0',
'3', '9', '1',
......@@ -828,13 +845,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'3', '9', '5',
'3', '9', '6',
'3', '9', '6',
'3', '9', '6',
'3', '9', '7',
'3', '9', '7',
'3', '9', '8',
'3', '9', '8',
'3', '9', '9',
'3', '9', '9',
'3', '9', '9',
'4', '0', '0',
'4', '0', '0',
'4', '0', '1',
......@@ -845,6 +862,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '0', '3',
'4', '0', '4',
'4', '0', '4',
'4', '0', '4',
'4', '0', '5',
'4', '0', '5',
'4', '0', '6',
......@@ -857,7 +875,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '0', '9',
'4', '1', '0',
'4', '1', '0',
'4', '1', '0',
'4', '1', '1',
'4', '1', '1',
'4', '1', '1',
'4', '1', '2',
......@@ -876,13 +894,13 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '1', '8',
'4', '1', '9',
'4', '1', '9',
'4', '1', '9',
'4', '2', '0',
'4', '2', '0',
'4', '2', '1',
'4', '2', '1',
'4', '2', '2',
'4', '2', '2',
'4', '2', '2',
'4', '2', '3',
'4', '2', '3',
'4', '2', '4',
......@@ -893,6 +911,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '2', '6',
'4', '2', '7',
'4', '2', '7',
'4', '2', '7',
'4', '2', '8',
'4', '2', '8',
'4', '2', '9',
......@@ -905,7 +924,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '3', '2',
'4', '3', '3',
'4', '3', '3',
'4', '3', '3',
'4', '3', '4',
'4', '3', '4',
'4', '3', '4',
'4', '3', '5',
......@@ -924,11 +943,11 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '4', '1',
'4', '4', '2',
'4', '4', '2',
'4', '4', '2',
'4', '4', '3',
'4', '4', '3',
'4', '4', '4',
'4', '4', '4',
'4', '4', '4',
'4', '4', '5',
'4', '4', '5',
'4', '4', '6',
......@@ -941,6 +960,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '4', '9',
'4', '5', '0',
'4', '5', '0',
'4', '5', '0',
'4', '5', '1',
'4', '5', '1',
'4', '5', '2',
......@@ -953,7 +973,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '5', '5',
'4', '5', '6',
'4', '5', '6',
'4', '5', '6',
'4', '5', '7',
'4', '5', '7',
'4', '5', '7',
'4', '5', '8',
......@@ -972,11 +992,11 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '6', '4',
'4', '6', '5',
'4', '6', '5',
'4', '6', '5',
'4', '6', '6',
'4', '6', '6',
'4', '6', '7',
'4', '6', '7',
'4', '6', '7',
'4', '6', '8',
'4', '6', '8',
'4', '6', '9',
......@@ -987,6 +1007,7 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '7', '1',
'4', '7', '2',
'4', '7', '2',
'4', '7', '2',
'4', '7', '3',
'4', '7', '3',
'4', '7', '4',
......@@ -1001,27 +1022,6 @@ const char FLASH_VoltageTable[1024 * 3] PROGMEM =
'4', '7', '8',
'4', '7', '9',
'4', '7', '9',
'4', '7', '9',
'4', '8', '0',
'4', '8', '0',
'4', '8', '1',
'4', '8', '1',
'4', '8', '2',
'4', '8', '2',
'4', '8', '3',
'4', '8', '3',
'4', '8', '4',
'4', '8', '4',
'4', '8', '5',
'4', '8', '5',
'4', '8', '6',
'4', '8', '6',
'4', '8', '7',
'4', '8', '7',
'4', '8', '8',
'4', '8', '8',
'4', '8', '9',
'4', '8', '9',
'4', '9', '0',
'4', '9', '0',
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE *File = fopen("adc_vtable.ino", "w");
printf("Enter max voltage\n");
double Max;
scanf("%lf", &Max);
fprintf(File, "const char FLASH_VoltageTable[1024 * 3] PROGMEM =\n");
fprintf(File, "{\n");
for(int i = 0; i < 1024; i++)
{
char Buf[16];
sprintf(Buf, "%.02f", ((double)i / 1023.0) * Max);
fprintf(File, "\t'%c', '%c', '%c',\n", Buf[0], Buf[2], Buf[3]);
}
fprintf(File, "};\n");
return 0;
}
\ No newline at end of file
......@@ -65,7 +65,7 @@ void Error()
void InitADC()
{
ADCSRA = bit(ADEN) | bit(ADIE) | bit(ADIF); // Enable the ADC and the read complete interrupt
ADCSRA |= bit(ADPS2); // Prescaler 16
ADCSRA |= bit(ADPS2) | bit(ADPS1); // Prescaler 64
ADMUX = bit(REFS0) | PIN_ADC;
ADCSRB = bit(ADTS0) | bit(ADTS2); // Timer 1 CompareB
ADCSRA |= bit(ADATE); // Enable auto trigger
......@@ -124,9 +124,13 @@ void SetTimerPeriod(int Period)
sei();
}
unsigned long AdcT = 0;
// ADC complete ISR
ISR(ADC_vect)
{
/*Serial.println(micros() - AdcT);
AdcT = micros();*/
//unsigned long tstart = micros();
//Serial.println((ADC / 1023.0) * 4.8);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment