diff --git a/software/DMMDataAcquisition/.idea/acquisitiondmm.iml b/software/DataAcquisitionFromDMM/.idea/acquisitiondmm.iml similarity index 100% rename from software/DMMDataAcquisition/.idea/acquisitiondmm.iml rename to software/DataAcquisitionFromDMM/.idea/acquisitiondmm.iml diff --git a/software/DMMDataAcquisition/DataParser.R b/software/DataAcquisitionFromDMM/DataParser.R similarity index 100% rename from software/DMMDataAcquisition/DataParser.R rename to software/DataAcquisitionFromDMM/DataParser.R diff --git a/software/DMMDataAcquisition/main.py b/software/DataAcquisitionFromDMM/main.py similarity index 100% rename from software/DMMDataAcquisition/main.py rename to software/DataAcquisitionFromDMM/main.py diff --git a/software/DataAcquisitionFromDevice/datalogger.py b/software/DataAcquisitionFromDevice/datalogger.py new file mode 100644 index 0000000..5bd7ab5 --- /dev/null +++ b/software/DataAcquisitionFromDevice/datalogger.py @@ -0,0 +1,20 @@ +from serial import Serial +import datetime + +myDeviceId = '/dev/ttyUSB0' +myBaudrate = 9600 +ser = Serial(myDeviceId, baudrate=9600) + +ser.isOpen() +logFile = open('data.log', 'w') +logFile.write("Time,Counter\n") + +while True: + dataIn = int(ord(ser.readline().strip())) + now = datetime.datetime.now() + logFile.write("{0},{1}\n".format(now, dataIn)) + logFile.flush() + + print(dataIn) + + diff --git a/software/DataAcquisitionFromDevice/script.R b/software/DataAcquisitionFromDevice/script.R new file mode 100644 index 0000000..bd9723a --- /dev/null +++ b/software/DataAcquisitionFromDevice/script.R @@ -0,0 +1,44 @@ +library(latticeExtra) +require(gridExtra) +require(grid) + +# set error messages test to english +Sys.setenv(LANG = "en") + +#load samples +samples <- read.delim("data.log", , sep=",") + +# date column should be type of date, not string, so parse it +png(filename = paste0("results-", format(Sys.time(), "%d_%b_%Y_%H_%M"), ".png"), width = 800, height = 900, bg = "white") + +# create graphs + +samples$Time = as.POSIXct(samples$Time, format="%Y-%m-%d %H:%M:%S.%OS") + +# create graphs +plotValueVsTime <- xyplot(Counter ~ Time, + data = samples, + type = "l", + grid = TRUE, + col.line = "black", + ylab = "counts per minute", + ylim=c(min(samples$Counter), max(samples$Counter)), + + xlim=c(min(samples$Time), max(samples$Time)), + main = "Change over time") + +plotHistogram <- histogram(samples$Counter, + color = "white", + col = "grey", + xlab = "counts", + ylab = "percentage", + main = "Histogram") + +# show graphs +grid.arrange(plotValueVsTime, plotHistogram, nrow = 2) + +# add timestamp +trellis.focus("toplevel") +pictureCreationTimestamp <- as.POSIXlt(Sys.time()) +panel.text(0.85, 0.03, pictureCreationTimestamp, cex = 1.2, font = 2) +trellis.unfocus() diff --git a/software/Firmware/Src/Logger.c b/software/Firmware/Src/Logger.c index 346f368..a659791 100644 --- a/software/Firmware/Src/Logger.c +++ b/software/Firmware/Src/Logger.c @@ -7,7 +7,7 @@ #include "Logger.h" -#define USE_PRINTF +//#define USE_PRINTF #if defined USE_PRINTF #include #endif @@ -20,7 +20,12 @@ static void GPIO_setup(void); static void UART1_setup(void); + +#if defined USE_PRINT int putchar(int c) +#else +void putchar(char c) +#endif { /* Write a character to the UART1 */ UART1_SendData8(c); @@ -38,8 +43,14 @@ void Logger_Init() void Logger_Print(uint8_t data) { +#if defined USE_PRINTF printf("%d\n\r", data); - //putchar(data); +#else + putchar(data); + putchar('\n'); + putchar('\r'); + +#endif } diff --git a/software/Firmware/Src/VoltageSensorActualValue.c b/software/Firmware/Src/VoltageSensorActualValue.c index d5473c8..eec9e53 100644 --- a/software/Firmware/Src/VoltageSensorActualValue.c +++ b/software/Firmware/Src/VoltageSensorActualValue.c @@ -30,7 +30,7 @@ void VoltageSensorActualValue_Init() bool VoltageSensorActualValue_GetMeasurementData(VoltageSensorActualValue_MeasurementData_t *measurementData) { - *measurementData = getRegisterValue(0x00); + *measurementData = getRegisterValue(0x0); if (*measurementData == 0) { @@ -76,11 +76,31 @@ uint8_t getRegisterValue(uint8_t registerId) I2C_SendData(registerId); while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED)); - //while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED)); + + + +// I2C_GenerateSTOP(ENABLE); +// while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY)); + + + I2C_GenerateSTART(ENABLE); + while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT)); + + I2C_Send7bitAddress(I2C_SLAVE_ADDRESS, I2C_DIRECTION_RX); + while(!I2C_CheckEvent(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); + + UserInterface_ShowMessage(USER_INTERFACE_COLLECTING_DATA_MSG); + + I2C_AcknowledgeConfig(DISABLE); + I2C_GenerateSTOP(ENABLE); + + while(!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED)); registerValue = I2C_ReceiveData(); - I2C_GenerateSTOP(ENABLE); - while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY)); + + I2C_AcknowledgeConfig(ENABLE); +// I2C_GenerateSTOP(ENABLE); +// while(I2C_GetFlagStatus(I2C_FLAG_BUSBUSY)); return registerValue; }