kopia lustrzana https://github.com/RobertGawron/IonizationChamber
Merge pull request #99 from RobertGawron/feature/basic_sw_components_implementation
Feature/basic sw components implementationpull/101/head
commit
5346c6f2d6
|
@ -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)
|
||||
|
||||
|
|
@ -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()
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "Logger.h"
|
||||
|
||||
#define USE_PRINTF
|
||||
//#define USE_PRINTF
|
||||
#if defined USE_PRINTF
|
||||
#include <stdio.h>
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue