PSoC6 Data Collection to CSV log file
1. Collect dataset using Eclipse ModusToolbox






2. Convert .txt dataset to .csv dataset






Last updated
Was this helpful?
Was this helpful?
#define GESTURE_DATA_COLLECTION_MODE 1uSHIELD_DATA_COLLECTION = CY_028_SENSE_SHIELD_v1SHIELD_DATA_COLLECTION = CY_028_SENSE_SHIELD_v2pip install -r requirements.txt./collect.sh <COM PORT> <GESTURE NAME> <PERSON./collect.sh COM6 circle Chhun!pip install tsaugimport matplotlib.pyplot as plt
# Define the file name
filename = '<your .txt file location'
# Initialize lists to store data
gyro_x, gyro_y, gyro_z, accel_x, accel_y, accel_z = [], [], [], [], [], []
# Read data from the file
with open(filename, 'r') as file:
for line in file:
# Split the line by comma
data = line.strip().split(',')
# Check if the line has 6 values
if len(data) == 6:
# Check if all values in the line are not '-'
if all(value != '-' for value in data):
# Append data to respective lists
gyro_x.append(float(data[0]))
gyro_y.append(float(data[1]))
gyro_z.append(float(data[2]))
accel_x.append(float(data[3]))
accel_y.append(float(data[4]))
accel_z.append(float(data[5]))
# Create time values (assuming each line represents a time step)
time = list(range(len(accel_x)))
# Plot accelerometer and gyroscope data with a wider figure
plt.figure(figsize=(16, 8)) # Increase width for a longer x-axis
# Set a main title for the entire figure
plt.suptitle('Square Dataset', fontsize=20)
# Plot accelerometer data
plt.subplot(2, 1, 1)
plt.plot(time, accel_x, label='Accel X')
plt.plot(time, accel_y, label='Accel Y')
plt.plot(time, accel_z, label='Accel Z')
plt.title('Accelerometer Data', fontsize=16) # Title for this subplot
plt.xlabel('Time', fontsize=12)
plt.ylabel('Acceleration', fontsize=12)
plt.legend()
# Plot gyroscope data
plt.subplot(2, 1, 2)
plt.plot(time, gyro_x, label='Gyro X')
plt.plot(time, gyro_y, label='Gyro Y')
plt.plot(time, gyro_z, label='Gyro Z')
plt.title('Gyroscope Data', fontsize=16) # Title for this subplot
plt.xlabel('Time', fontsize=12)
plt.ylabel('Angular Velocity', fontsize=12)
plt.legend()
# Adjust layout to prevent overlap
plt.tight_layout(rect=[0, 0, 1, 0.95]) # Leave space for main title
plt.show()